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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable substitution in WScript.shell Run 1

Status
Not open for further replies.

malaygal

IS-IT--Management
Feb 22, 2006
192
US
I have been stuggling with this code for the past few days.
I have been getting The system cannot find the file specified.

scPath = "C:\Program Files\"
scName = "days.vbs"
strCommand = scPath&scName
set shell = CreateObject("Wscript.shell")
shell.run strCommand

Any help will be greatly appreciated.
 
The problem is the space between Program and Files.
Try this.....
Code:
scPath = "C:\Program Files\"
scName = "days.vbs"
strCommand = scPath&scName
Set shell = CreateObject("Wscript.shell")
shell.run AddQuotes(strCommand)

Function AddQuotes(strInput)
	AddQuotes = Chr(34) & strInput & Chr(34)
End Function

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
great idea using the function for wrapping in quotes dm4ever. So often in a script you need to do that, I really like that concept.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
I picked that idea up from EBGreen...it does help in keeping the code easy to read and inserting the necessary extra quotes.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
The wrapper idea is slick... Mind if I take that and use it about a hundred thousand times?

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top