Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Wshshell.run

Status
Not open for further replies.

dosun

Programmer
Oct 15, 2003
11
US
When I execute the commands below in vbscript, I get
vbscript error 2147024894 - system cannot find the file
specified. (If I change "Test Company" to
"TestCompany", the script runs OK. I would prefer to
not have to do that.)

Note: The reason I included "1, TRUE" is so that the
VB6 Program I am executing will be allowed to
complete processing before the script continues.

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "C:\Test Company\vb6program.exe", 1, TRUE

I tried making the change shown below, and I got vbscript
error number 1044 - "Cannot use parentheses when calling
a sub.

WshShell.Run ("C:\Test Company\vb6program.exe", 1, TRUE)

Does anyone know how to make this work, without removing
the space in the path of program being called ?
 
Try variablizing the .exe statement:

runThis = "C:\Test Company\vb6program.exe"
result = WshShell.Run (runThis, 1, TRUE)


result can then be tested after the fact (anything other than 0, usually indicates unsuccessful command.

Hope that helps
 
When you're trying to run a program where there are spaces in the path, you need to include the command to be run in quotes. There are two ways:

..using three quotes where each single quote would go, like this-
WshShell.Run """C:\Test Company\vb6program.exe""", 1, TRUE

..which is ugly, or use ansi characters-
WshShell.Run chr(34) & "C:\Test Company\vb6program.exe" & chr(34), 1, TRUE

Enjoy!
kh
 
That solved the problem. Thanks for quick response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top