In an HTA file I have the code shown below.

It used to run in a directory other than "My Report". The old folder
name had spaces and there were no problems.

When it runs in the "My Report" directory a message appears saying
"System can not find the file specified".

The string being sent to WSH.Run is:

C:\My%20Folder\script.vbs "C:\My Report\a.txt" "C:\My Report\b.txt"

Changing the string to

C:\My%20Folder\script.vbs ""C:\My Report\a.txt"" "C:\My Report\b.txt""

and

"C:\My%20Folder\script.vbs "C:\My Report\a.txt" "C:\My Report\b.txt" "

and

"C:\My%20Folder\script.vbs ""C:\My Report\a.txt"" ""C:\My Report
\b.txt"" "

and other permutations didn't work.

What do I need to do? Thanks.



<script language="VBScript">

Function CreateReport
File1 = "C:\My Report\a.txt"
File2 = "C:\My Report\b.txt"
Set WSH = CreateObject("WScript.Shell")
WSH.Run GetPath(document.location.pathname) & "my.vbs" & _
Chr(34) & File1 & Chr(34) & " " & _
Chr(34) & File2 & Chr(34)
Window.Close
End Function


Function GetPath(Path)
ix=InstrRev(Path,"\")
Path=Left(Path,ix)
GetPath = Path
End Function

</script>

Re: Calling a WSH application where arguments refer to folder names that have spaces by Michael

Michael
Mon Feb 26 15:57:46 CST 2007

> ---snip---
> What do I need to do? Thanks.
>
>
>
> <script language="VBScript">
>
> Function CreateReport
> File1 = "C:\My Report\a.txt"
> File2 = "C:\My Report\b.txt"
> Set WSH = CreateObject("WScript.Shell")
> WSH.Run GetPath(document.location.pathname) & "my.vbs" & _

add a space after the .vbs

WSH.Run GetPath(document.location.pathname) & "my.vbs " & _
--------------------------------------------------------^

> Chr(34) & File1 & Chr(34) & " " & _
> Chr(34) & File2 & Chr(34)
> Window.Close
> End Function
>
>
> Function GetPath(Path)
> ix=InstrRev(Path,"\")
> Path=Left(Path,ix)
> GetPath = Path
> End Function
>
> </script>

--
Michael Harris
Microsoft.MVP.Scripting



Re: Calling a WSH application where arguments refer to folder names by Ayush

Ayush
Mon Feb 26 16:35:53 CST 2007

Replied to [gimme_this_gimme_that@yahoo.com]s message :
> <script language="VBScript">

> Function CreateReport
> File1 = "C:\My Report\a.txt"
> File2 = "C:\My Report\b.txt"
> Set WSH = CreateObject("WScript.Shell")
> WSH.Run GetPath(document.location.pathname) & "my.vbs" & _
> Chr(34) & File1 & Chr(34) & " " & _
> Chr(34) & File2 & Chr(34)
> Window.Close
> End Function


> Function GetPath(Path)
> ix=InstrRev(Path,"\")
> Path=Left(Path,ix)
> GetPath = Path
> End Function

> </script>


Add a space after my.vbs :
WSH.Run GetPath(document.location.pathname) & "my.vbs " & _
Chr(34) & File1 & Chr(34) & " " & _
Chr(34) & File2 & Chr(34)

You can use my.vbs without the path if my.vbs is in the same folder :

WSH.Run "my.vbs " & _
Chr(34) & File1 & Chr(34) & " " & _
Chr(34) & File2 & Chr(34)


Good Luck, Ayush.
--
VBScript, JScript, WSH Reference : http://www.devguru.com/

Re: Calling a WSH application where arguments refer to folder names that have spaces by gimme_this_gimme_that

gimme_this_gimme_that
Mon Feb 26 16:55:41 CST 2007

Thanks guys. The missing space was a type-o in my post. I had
that ....

What fix things for me was removing the path to my.vbs.

Great tip.

Thanks.

> You can use my.vbs without the path if my.vbs is in the same folder :
>


Re: Calling a WSH application where arguments refer to folder names by Ayush

Ayush
Mon Feb 26 17:11:25 CST 2007

Replied to [gimme_this_gimme_that@yahoo.com]s message :
> Thanks guys. The missing space was a type-o in my post. I had
> that ....

> What fix things for me was removing the path to my.vbs.

just tested that run method doesn't work with %20 so If you replace those
%20 with [space] then that will work.

> Great tip.
> Thanks.

You are welcome.

Good Luck, Ayush.
--
Script Center : http://microsoft.com/technet/scriptcenter/default.mspx