Spaces in Folders 
Author Message
 Spaces in Folders

Hi,

I need help: I can't start programs in folders containing spaces. When I use
the following little vbs-Script:

set oShell=WScript.CreateObject("WScript.Shell")

oShell.Run "C:\Program Files\Test.Exe",1,True

I get the error-message: "File not found", because there are spaces in the
folder "Program Files".

On www.winscripter.com I got the hint to change the 2. command-Line as
follows:

oShell.Run "\"C:\\Program Files\\Test.Exe\"",1,True

When I do so, I get the error-message "Anweisungsende erwartet" (maybe in
english: end of command/expression expected)

Can anybody tell me, how to change the progam ?

Thanks beforehand,

Michael



Fri, 18 Apr 2003 13:59:47 GMT  
 Spaces in Folders

why not try:

oShell.Run "C:\Progra~1\Test.Exe",1,True

christophe, team partners group


Quote:
> Hi,

> I need help: I can't start programs in folders containing spaces. When I
use
> the following little vbs-Script:

> set oShell=WScript.CreateObject("WScript.Shell")

> oShell.Run "C:\Program Files\Test.Exe",1,True

> I get the error-message: "File not found", because there are spaces in the
> folder "Program Files".

> On www.winscripter.com I got the hint to change the 2. command-Line as
> follows:

> oShell.Run "\"C:\\Program Files\\Test.Exe\"",1,True

> When I do so, I get the error-message "Anweisungsende erwartet" (maybe in
> english: end of command/expression expected)

> Can anybody tell me, how to change the progam ?

> Thanks beforehand,

> Michael



Fri, 18 Apr 2003 18:34:51 GMT  
 Spaces in Folders

WScript sees the space as the end of the string.  There are several ways to work around this.

1) Use triple double quotes

    oShell.Run """C:\Program Files\Test.Exe""",1,True

2) Use the ANSI character code for a double quote:

    oShell.Run Chr(34) & "C:\Program Files\Test.Exe" & Chr(34),1,True

Several other ways, but you get the idea.

--

Bill James
Microsoft MVPDTS

?Win9x VBScript Utilities?
www.billsway.com/vbspage/

Quote:

> Hi,

> I need help: I can't start programs in folders containing spaces. When I use
> the following little vbs-Script:

> set oShell=WScript.CreateObject("WScript.Shell")

> oShell.Run "C:\Program Files\Test.Exe",1,True

> I get the error-message: "File not found", because there are spaces in the
> folder "Program Files".

> On www.winscripter.com I got the hint to change the 2. command-Line as
> follows:

> oShell.Run "\"C:\\Program Files\\Test.Exe\"",1,True

> When I do so, I get the error-message "Anweisungsende erwartet" (maybe in
> english: end of command/expression expected)

> Can anybody tell me, how to change the progam ?

> Thanks beforehand,

> Michael



Fri, 18 Apr 2003 19:10:30 GMT  
 Spaces in Folders
I would have thought that it was the Run method of the Wshshell object (or
even the execute program code within windows), not wscript, that sees the
space as the delimiter of the name of the program to be run, not the end of
string. Try typing that same command at a DOS prompt, and I think you will
see the same result.

Note that the docs refer to the first parameter as "strCommand", not
"strExecutableProgram". Also note other examples given in the NG where
actual parameters are passed by delimiting them with spaces in the
strCommand parameter.

/Al


WScript sees the space as the end of the string.  There are several ways to
work around this.

1) Use triple double quotes

    oShell.Run """C:\Program Files\Test.Exe""",1,True

2) Use the ANSI character code for a double quote:

    oShell.Run Chr(34) & "C:\Program Files\Test.Exe" & Chr(34),1,True

Several other ways, but you get the idea.

--

Bill James
Microsoft MVPDTS

?Win9x VBScript Utilities?
www.billsway.com/vbspage/


Quote:
> Hi,

> I need help: I can't start programs in folders containing spaces. When I
use
> the following little vbs-Script:

> set oShell=WScript.CreateObject("WScript.Shell")

> oShell.Run "C:\Program Files\Test.Exe",1,True

> I get the error-message: "File not found", because there are spaces in the
> folder "Program Files".

> On www.winscripter.com I got the hint to change the 2. command-Line as
> follows:

> oShell.Run "\"C:\\Program Files\\Test.Exe\"",1,True

> When I do so, I get the error-message "Anweisungsende erwartet" (maybe in
> english: end of command/expression expected)

> Can anybody tell me, how to change the progam ?

> Thanks beforehand,

> Michael



Sun, 20 Apr 2003 13:48:24 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Help Spaces in folder names

2. used space in a folder

3. Browse.WshKit Won't Work On Folders Names with Spaces

4. Calculate Space on users folders

5. Calculate space on users folders

6. JScript & Folders with Spaces

7. JScript and Folders with Spaces

8. Function to Squeeze multiple spaces in a string to one space

9. Default User Space coords from User Space coords

10. spacing vs non-spacing accents--violl\'a!

11. jscript in folder.htt - size of files within folder

12. create a folder or find default temp folder

 

 
Powered by phpBB® Forum Software