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

Trying to run a file through a directory with spacing.

Status
Not open for further replies.

deathxorz

Programmer
Nov 12, 2007
1
CA
Hey,

I'm trying to run a file using vbs and keep getting an error stating "The system cannot find the file specified. I've searched around for about 2 hours now and think it must have something to do with double quotes, but still cannot get it to work. My code is posted below. Any help would be appreciated.

Thanks in advance,
Mark

'**************Code*****************
Set wshshell = wscript.createobject("wscript.shell")
Set wshenv = wshshell.environment("Process")
Set wshNetwork = CreateObject("WScript.Network")

Set fsobject = wscript.createobject("scripting.filesystemobject")
Set systemdrive = fsobject.getdrive(wshenv("SYSTEMDRIVE"))

Target = systemdrive & "\Documents and Settings\" & wshNetwork.UserName & "\Start Menu\Programs\Crimson Editor\cedt.exe"

set wshshell = wscript.createobject("wscript.shell")
wshshell.run Target
'****************End Code***************************
 
Code:
Target =  """" & systemdrive & "\Documents and Settings\" & wshNetwork.UserName & "\Start Menu\Programs\Crimson Editor\cedt.exe"""
 
Code:
target = """" & systemdrive ... cedt.exe"""
 
Alternatively:
wshshell.Run Chr(34) & Target & Chr(34)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top