CreateObject("WScript.Shell").Run Path with spaces can not find file

1.6k Views Asked by At

I am receiving a error when running a WScript.Shell Run with a path that has a spaces in it.

I've tried several different variations that result in the same error.

CreateObject("WScript.Shell").Run """Program Files\scripts\exe\PsExec64.exe -accepteula -realtime -d c:\windows\system32\RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 264"" ", 0, True
CreateObject("WScript.Shell").Run "Program Files\scripts\exe\PsExec64.exe -accepteula -realtime -d c:\windows\system32\RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 264", 0, True
CreateObject("WScript.Shell").Run "'Program Files\scripts\exe\PsExec64.exe -accepteula -realtime -d c:\windows\system32\RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 264'", 0, True
CreateObject("WScript.Shell").Run("Program Files\scripts\exe\PsExec64.exe -accepteula -realtime -d c:\windows\system32\RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 264", 0, True)

I understand the space in the path is causing an error, I just cant wrap my head around wrapping with quotes correctly.

1

There are 1 best solutions below

0
On

you need to specify the drive letter, e.g. c:\program files