Re: wscript.shell Run file with space in path by ekkehard
ekkehard
Tue Mar 11 10:06:10 CDT 2008
requeth@gmail.com schrieb:
> On Mar 11, 9:41 am, "ekkehard.horner" <ekkehard.hor...@arcor.de>
> wrote:
>> requ...@gmail.com schrieb:> I'm trying to run the following, but I always receive an error due to
>>> the space between Program Files. I've tried quoting it in standard
>>> style and in ascii but then the file cannot be found. The file is at
>>> the path specified. Anyone see the error?
>>> Set WSHShell = CreateObject("Wscript.Shell")
>>> return = WSHShell.run ("C:\Program Files\7-Zip\7z.exe e C:\ziptest
>>> \test.zip -y -oc:\ziptest *.txt -r",1,true)
>> One method to get " into a literal string is to 'escape it' the VBScript
>> way: use "" (where you would use \" in C/C++).
>>
>> return = WSHShell.run( """C:\Program Files\7-Zip\7z.exe"" e ...
>
> I'm still receiving the error that the file cannot be found. I'm
> tyring:
>
> Set WSHShell = CreateObject("Wscript.Shell")
> return = WSHShell.run ("C:\""Program Files""\7-Zip\7z.exe e C:\ziptest
> \test.zip -y -oc:\ziptest *.txt -r",1,true)
return = WSHShell.run( """C:\Program Files\7-Zip\7z.exe"" e C:\ziptest\test.zip
-y -oc:\ziptest *.txt -r",1,true)
One line; the full path has to be quoted. You would make it easier for yourself
if you'd store the command into a variable and WScript.Echo it to check/compare
against a working command line.