Jump to content

CMD command with parameter and space in file path


Recommended Posts

Hi All,

I have written a simple script to run cmd command but they contain space in file path and parameter. I would like to seek advice on how to correct phase them.

Thanks

If @OSArch = "X86" Then
   ;x86 installation
RunWait(@ComSpec & " /c " & '"C:\Program Files\Symantec\Symantec Endpoint Protection\SMC.exe" -stop -p 123445', "", @SW_HIDE)
ElseIf @OSArch = "X64" Then
   ;else x64 installation
RunWait(@ComSpec & " /c " & '"C:\Program Files (x86)\Symantec\Symantec Endpoint Protection\SMC.exe" -stop -p 123445', "", @SW_HIDE)
Endif
Link to comment
Share on other sites

Those look correct to me.  Do they fail to run? 

 

I corrected this code in the afternoon but not sure if it's correct. Previously is as below which does not work

If @OSArch = "X86" Then    
;x86 installation 
RunWait(@ComSpec & " /c " & '"C:\Program Files\Symantec\Symantec Endpoint Protection\SMC.exe" -stop -p 123445"', "", @SW_HIDE) 
ElseIf 
@OSArch = "X64" Then    
;else
 x64 installation RunWait(@ComSpec & " /c " & '"C:\Program Files (x86)\Symantec\Symantec Endpoint Protection\SMC.exe" -stop -p 123445"', "", @SW_HIDE) 
Endif

But i just browse the forum and found out that using ShellExecute also works. Mind advising on the code below?

If @OSArch = "X86" Then
   ;x86 installation
Shellexecute('C:\Program Files\Symantec\Symantec Endpoint Protection\SMC.exe','-p "12334567" -stop',"", "", @SW_HIDE)
ElseIf @OSArch = "X64" Then
   ;else x64 installation
Shellexecute('C:\Program Files (x86)\Symantec\Symantec Endpoint Protection\SMC.exe','-p "12345678" -stop',"", "", @SW_HIDE)
Endif
Edited by DevilChris
Link to comment
Share on other sites

Use a /k switch, rather than a /c, and don't hide the console...see what's the issue with the command.  Looks fine.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...