Re: basic help to run an application from WSH



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.



.



Relevant Pages

  • Re: How to pass string in command line argument.
    ... > I want to pass a command argument to perl script with double quotes (" ... > just a straight string is geeting passed ...
    (perl.beginners)
  • Re: basic help to run an application from WSH
    ... string values must be enclosed in quotes. ... The Run method will execute on c:\notepad.exe. ... I'm just learning vbscript for wsh and here is my first script, ... Also if I cut and paste the exact file path from the script into the ...
    (microsoft.public.scripting.vbscript)
  • Re: How to pass string in command line argument.
    ... Perl Pra wrote: ... i have perl script that searches given string (the string should be passed ... The string should be sent to the script with double quotes attached to it ...
    (perl.beginners)
  • Re: Dynamically switch Javascript
    ... A call gets made to a server, and it returns a string. ... I need to be able to execute this Javascript and place its contents inside the "div" tag. ... I have tried using "eval" and also constructing a script node dynamically and both have not worked for me. ... The only browser that executes script blocks that are inserted via innerHTML is NS6 and not all releases of NS6 execute them. ...
    (comp.lang.javascript)
  • Re: Creation of DSN
    ... Build a text string from the input data. ... rather execute the string that was just built. ... script file has been processed. ... > I'm using directly a Command, ...
    (microsoft.public.vb.database.ado)