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!

Parameters with spaces

Status
Not open for further replies.

cmead

Programmer
Jun 27, 2003
2
0
0
US
Hi,

I am trying to figure out how to pass filenames/paths into VBScripts that have spaces in their names. For example:

CScript shrtct.vbs c:\sol.exe

works fine. (The script makes shortcuts to the filename passed in and stores them on the desktop.)

However, I cannot do this:

CScript shrtct.vbs "c:\sol two.exe"

(cannot use parentheses when calling a sub)

Any ideas are greatly appreciated.

Thanks,

Chris
 
cmead,

Have you tried using single quotes?

CScript shrtct.vbs 'c:\sol two.exe'


fengshui_1998
 
Try creating a variable i.e.

dim MyVar
MyVar= "C:\program files\directory"
CScript shrtct.vbs MyVar
 
The problem is not with reading the command line parameters, using double-quotes is the correct way to pass in a parameter that contains spaces. The error message you posted suggests the problem is elsewhere. Try to isolate which subroutine you are calling with parentheses and get rid of them. If you need more help, post some of your code.

- xift
 
Thank you xift, woodhead, & FengShui1998,

All of your suggestions were helpful, but xift hit the nail on the head. I had an error elsewhere in the script which I mistakenly assumed was the fault of the new parameters I was adding. The problem is behind me now.

Thank you very much,

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top