Discussion:
wscript.shell Run file with space in path
(too old to reply)
r***@gmail.com
2008-03-11 14:35:09 UTC
Permalink
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)
ekkehard.horner
2008-03-11 14:41:41 UTC
Permalink
Post by r***@gmail.com
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 ...
r***@gmail.com
2008-03-11 14:54:59 UTC
Permalink
Post by ekkehard.horner
Post by r***@gmail.com
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)
ekkehard.horner
2008-03-11 15:06:10 UTC
Permalink
Post by r***@gmail.com
Post by ekkehard.horner
Post by r***@gmail.com
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
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.
Corey Thomas - MCSE/MCSA/MCDBA
2008-03-11 16:15:00 UTC
Permalink
Corrected your code below. The double quotes are needed on the entire string
since it has whitespace:

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)


-Corey
Post by r***@gmail.com
Post by ekkehard.horner
Post by r***@gmail.com
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
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)
Pegasus (MVP)
2008-03-11 17:03:01 UTC
Permalink
If you follow Ekkehard's recommendation and turn the command
into a string then you will see immediately that your code cannot
possibly work:

Set WSHShell = CreateObject("Wscript.Shell")
wscript.echo """C:\Program Files\7-Zip\7z.exe e
C:\ziptest\test.zip -y -oc:\ziptest *.txt -r"""


"Corey Thomas - MCSE/MCSA/MCDBA"
Post by Corey Thomas - MCSE/MCSA/MCDBA
Corrected your code below. The double quotes are needed on the entire string
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)
-Corey
Post by r***@gmail.com
Post by r***@gmail.com
always receive an error due to
Post by r***@gmail.com
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
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)
ekkehard.horner
2008-03-11 17:48:59 UTC
Permalink
Post by Pegasus (MVP)
If you follow Ekkehard's recommendation and turn the command
into a string then you will see immediately that your code cannot
Set WSHShell = CreateObject("Wscript.Shell")
wscript.echo """C:\Program Files\7-Zip\7z.exe e
C:\ziptest\test.zip -y -oc:\ziptest *.txt -r"""
"Corey Thomas - MCSE/MCSA/MCDBA"
Post by Corey Thomas - MCSE/MCSA/MCDBA
Corrected your code below. The double quotes are needed on the entire string
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)
[...]
It won't work, if the whole command line (pathes and options)
is enclosed in " (written as ""), but putting the " where they
are needed (the full file spec for 7z.exe) should be correct.
n***@gmail.com
2014-09-11 07:48:48 UTC
Permalink
Dim WshShell

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """C:\Program Files\abc_edf\cde\qw.exe""",1,true
set WshShell = Nothing


I am still getting "the system cannot find the file specified.
it is because of spaces.
I tried using double quotes as well.

Please help
Evertjan.
2014-09-11 08:20:43 UTC
Permalink
Post by n***@gmail.com
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """C:\Program Files\abc_edf\cde\qw.exe""",1,true
set WshShell = Nothing
I don't thing the tripple quote will help you.
Post by n***@gmail.com
I am still getting "the system cannot find the file specified.
ok
Post by n***@gmail.com
it is because of spaces.
Why do you think that, what is the error you get?

Try a string that does not contain the _
perhaps the _ is a stand-in for a space?
Post by n***@gmail.com
I tried using double quotes as well.
Please quote what you are replying on,
this is usenet, not Google groups or email.

Read:

Run Method (Windows Script Host)
<http://msdn.microsoft.com/en-us/library/d5fk67ky(v=vs.84).aspx>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dave "Crash" Dummy
2014-09-11 11:09:40 UTC
Permalink
Post by n***@gmail.com
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """C:\Program Files\abc_edf\cde\qw.exe""",1,true
set WshShell = Nothing
I am still getting "the system cannot find the file specified.
it is because of spaces.
I tried using double quotes as well.
Please help
This thread is so screwed up I'm not sure where to respond. Use the
"exec" method, not the "run" method, and get out of Google.

Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("C:\Program Files\abc_edf\cde\qw.exe")
set WshShell = Nothing

See the VBScript manual for details on the "exec" method.
--
Crash

"The future ain't what it used to be."
~ Yogi Berra ~
GS
2014-09-11 11:35:39 UTC
Permalink
Post by Dave "Crash" Dummy
Post by n***@gmail.com
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """C:\Program Files\abc_edf\cde\qw.exe""",1,true
set WshShell = Nothing
I am still getting "the system cannot find the file specified.
it is because of spaces.
I tried using double quotes as well.
Please help
This thread is so screwed up I'm not sure where to respond. Use the
"exec" method, not the "run" method, and get out of Google.
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("C:\Program Files\abc_edf\cde\qw.exe")
set WshShell = Nothing
See the VBScript manual for details on the "exec" method.
The 'exec' method has a different purpose than the 'run' method! The
'run' method is the correct choice here and works just fine...
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Mayayana
2014-09-11 16:49:54 UTC
Permalink
| This thread is so screwed up I'm
| not sure where to respond.

I'm guessing that nancya85 is Google's
latest foray into the field of AI. They're
testing it on us. The first test is to see
if it will pass for human in a newsgroup.
If that works out then they try having it
play online chess. :)
Dave "Crash" Dummy
2014-09-11 18:28:15 UTC
Permalink
Post by Mayayana
| This thread is so screwed up I'm
| not sure where to respond.
I'm guessing that nancya85 is Google's
latest foray into the field of AI. They're
testing it on us. The first test is to see
if it will pass for human in a newsgroup.
If that works out then they try having it
play online chess. :)
I want to see it up against Watson on Jeopardy.
--
Crash

Committed to the search for intraterrestrial intelligence.
Todd Vargo
2014-09-11 16:22:48 UTC
Permalink
Post by n***@gmail.com
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """C:\Program Files\abc_edf\cde\qw.exe""",1,true
set WshShell = Nothing
I am still getting "the system cannot find the file specified.
it is because of spaces.
I tried using double quotes as well.
Please help
Why did you add "SOLVED" to the subject line? That is very confusing.

Please confirm that "C:\Program Files\abc_edf\cde\qw.exe" leads to an
actual executable file. In other words, the abc_edf folder appears to be
a made up folder name in code only that does not actually exist.
--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
n***@gmail.com
2014-09-11 08:33:16 UTC
Permalink
Post by r***@gmail.com
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)
no the underscore is not the space . it is name of folder.
n***@gmail.com
2014-09-11 09:09:06 UTC
Permalink
The error is due to folder name contains underscore. can anyone help what shall be done?
R.Wieser
2014-09-11 10:13:29 UTC
Permalink
Nancy,
Post by n***@gmail.com
The error is due to folder name contains underscore.
I don't think so. An underscore is a quite normal character that may be
used in folder as well as filenames, just as most other characters.

1) Have you tried creating such a foldername yourself, and see if it fails
too (copy use something like "notepad.exe" into the folder for the
executable) ? If not ... :-)

2) Have you tried to run the script in the "cde" folder (using
"""cde\qw.exe""") ? Maybe the program itself refuses to run.

Next, try accessing that folder from within a DOS- or CMD-box and see if you
can DIR and/or CD on that "abc_edf" folder. If that does not work the
underscore may be a viewing-only replacement of an undisplayable character
(read: the foldername itself has been damaged).

And that would mean you've got a problem: You could rename the folder, but
that could mean the "gw.exe" program could fail to work properly (it expects
a path that does not exist anymore). The only thing to do than is to
un-install and re-install the program again, assuming that that will replace
the damaged foldername.

Regards,
Rudy Wieser


-- Origional message
Post by n***@gmail.com
The error is due to folder name contains underscore. can anyone help what shall be done?
GS
2014-09-11 11:27:35 UTC
Permalink
Post by n***@gmail.com
The error is due to folder name contains underscore. can anyone help what shall be done?
Both these work for me...

Set oSH = CreateObject("WScript.Shell")
oSH.Run """C:\Program Files\Textpad_7\Textpad.exe"""
Set oSH = Nothing

Set oSH = CreateObject("WScript.Shell")
oSH.Run """C:\Program Files\Textpad 7\Textpad.exe"""
Set oSH = Nothing
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Loading...