HEELPBOOK - How To - Executing an EXE from a VBScript file that has spaces in the path ############################ ########## SCENARIO ############# Trying to execute a file in a directory with a spaces in the path would bomb. I googled and found a thing that has me put [] inside to fix it but it didn’t work. Here is what i was trying to do, if there is no spaces in the path to the EXE including any directories, the script works fine. ######## SOLUTION ########### Here is an example to a path for an EXE: C:\winnt\system32\Ica PassThrough\pn.exe. Here is the script code: Set wshShell = WScript.CreateObject ("WSCript.shell") wshshell.run "c:\winnt\system32\Ica PassThrough\pn.exe", 6, True set wshshell = nothing Of course, this code would BOMB! (This code is wrong!) The script would return an error complaining it couldn’t find the file. Your .run command is trying to run something called "C:\winnt\system32\ica" and pass it a parameter called "PassThrough\pn.exe". This is the same thing you would get if you typed the following at a command prompt: C:\winnt\system32\Ica PassThrough\pn.exe If the name of the file to run is actually "c:\winnt\system32\Ica PassThrough\pn.exe", you would enter it at the command prompt as: "C:\winnt\system32\Ica PassThrough\pn.exe" The double quotes in your code do not form part of the filename string being passed to the .run method, they are required to indicate a literal string. You can prove this is the case by changing your script to look like this: > Set wshShell = WScript.CreateObject ("WSCript.shell") > wshshell.run c:\winnt\system32\Ica PassThrough\pn.exe, 6, True > set wshshell = nothing Which will throw a syntax error (for rather obvious reasons). (Also this code is wrong!) You need to pass a string that actually contains the quoted filename, which can be done this way: > wshshell.run """c:\winnt\system32\Ica PassThrough\pn.exe""", 6, True Within a literal string, a single double-quote character is represented by two double-quote characters. Notice the Three double quotes around the string, This worked! Thought I’d pass this tip along. ############ ARTICLE INFO ############# Article Month: April Article Date: 11/04/2012 Permalink: http://heelpbook.altervista.org/2012/how-to-executing-an-exe-from-a-vbscript-file-that-has-spaces-in-the-path/ Source: http://www.iislogs.com/steveschofield/89240 Language: English View more articles on: http://www.heelpbook.net/ Follow us on Facebook: http://it-it.facebook.com/pages/HeelpBook/100790870008832 Follow us on Twitter: https://twitter.com/#!/HeelpBook Follow us on RSS Feed: http://feeds.feedburner.com/Heelpbook Follow us on Delicious: http://delicious.com/heelpbook