Forum Discussion

egbea's avatar
egbea
Occasional Contributor
15 years ago

Commandline input parameter

Hello Everyone,

I am  trying to execute  the following command line arguments in vbscript that I generally run via the cmd prompt

C:\>"C:\Program Files (x86)\Sciemetric\QualityWorX\Archive\Archive.exe" -r "c:\Test001.saj".

Here is my how I implemented it in vbscript and it throws the error message "The system cannot find the file specified"



Set WshShellExecObj = WshShellObj.Exec("C:\%Program Files (x86)%\Sciemetric\QualityWorX\Archive\Archive.exe"" -r ""C:\Test001.saj")




I will appreciate it, if anyone can point out what I am doing wrong or give me a hint either by the correct code how I can accomplish this.

I am appended herein a a portion of my code


.....


Set WshShellObj = Sys.OleObject("WScript.Shell")


 
getOSType =   FindApplicationPath()


 
Log.Message(getOSType)


 
CmdPara = WshShellObj.Run("cmd.exe")


 
If (Sys.Process("cmd").Exists = True) Then


       Set CmdDialog = Sys.Process("cmd")


     Set
WshShellExecObj = WshShellObj.Exec("C:\%Program Files  (x86)%\Sciemetric\QualityWorX\Archive\Archive.exe""
-r ""C:\Test001.saj") 


 
End If


 
If  WshShellExecObj.Status
= 1 Then


    Do While
WshShellExecObj.Status = 1


        'WScript.Sleep 100


        Delay(100)


       
WshShellExecObj.StdErr.Write(WshShellExecObj.StdErr.ReadAll())


     Loop


     Exit Function


 
else


       Do While
WshShellExecObj.Status = 0


              Delay(100)


         
WshShellExecObj.StdOut.Write(WshShellExecObj.StdOut.ReadAll())


        Loop


  End if


.....


Thanking you in advance.

Egbe.

1 Reply

  • Hello Egbe,



    To output a quotation mark in VBScript, you need to use two quotes. Also, either percent symbols should be removed from the command, or the environment variable value should be retrieved by using the ExpandEnvironmentStrings method:



    or