Re: basic help to run an application from WSH
- From: georgeoliverGO@xxxxxxxxx
- Date: 10 Oct 2006 17:44:52 -0700
Thanks Richard and Tom, nowhere did I find as clear an explanation as
you guys just gave me. Thank you!
Richard Mueller wrote:
Hi.
The Run method requires at least one argument, which is a string. The value
of the string is the path and filename of a program to be executed. All
string values must be enclosed in quotes. If a path and filename has spaces,
the value must be enclosed in quotes. Any embedded quotes in a quoted string
must be doubled. For example:
WshShell.Run "c:\notepad.exe"
will work. The Run method will execute on c:\notepad.exe. However:
WshShell.Run "c:\My Folder\notepad.exe"
will not work, because c:\My Folder\notepad.exe is not understood. You want
the run method to execute "c:\My Folder\notepad.exe". So, to pass the
embedded quotes, you must double them. This will work:
WshShell.Run """c:\My Folder\notepad.exe"""
The WSH interpreter resolves the embedded double quotes into single quotes
and passes the following to the Run method:
"c:\My Folder\notepad.exe"
which is a valid statement to execute.
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
<georgeoliverGO@xxxxxxxxx> wrote in message
news:1160491239.242671.123500@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
OK, I found that enclosing the file path in -three- sets of quotation
marks, such as
"""<file path"""
works.
What I don't understand is why you need three sets, any help?
(I suppose I didn't look everywhere, then...)
georgeoliverGO@xxxxxxxxx wrote:
hello,
Apologies for such a basic question, but I've looked everywhere and
nothing is helping.
I'm just learning vbscript for wsh and here is my first script, saved
in file "<file>.vbs":
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "<file path of file.vbs>"
Where <...> is a full file path such as "c:\documents and
settings\[...]" etc.
When I run this by selecting the file I always get a
Script: <script file path>
Line: 2
Char: 1
Error: THe system cannot find the file specified.
Code: 80070002
Source: (null)
However if I just move the file to c:\, so the path is "c:\<file>" the
file opens.
Also if I cut and paste the exact file path from the script into the
Run box on the start menu, the file opens.
Any help with this?
Many thanks.
.
- References:
- basic help to run an application from WSH
- From: georgeoliverGO
- Re: basic help to run an application from WSH
- From: georgeoliverGO
- Re: basic help to run an application from WSH
- From: Richard Mueller
- basic help to run an application from WSH
- Prev by Date: Re: Run remote process
- Next by Date: Re: Script To Log Moved Files
- Previous by thread: Re: basic help to run an application from WSH
- Next by thread: Modifying AD users with an INPUT file
- Index(es):
Relevant Pages
|