I'm writing to call a VBScript from Silk bdh and passing arguments from Silk. My first problem is there are more than 1 argument (total 4 arguments). My second problem is these arguments contain white space.
Below is the program:
sCmdLine := "cscript.exe";
//sParms := "C:\\QK\\test1_old.vbs \" \"" +string(error_counter)+"\" \"" +error_timer ;
sParms := "C:\\QK\\test1.vbs \" 2\string(error_counter)+
error_timer+error_details+error_time;
hProcessId := ProcessInitialize(sCmdLine, PROCESS_PIPED, sParms,"C:\\WINDOWS\\System32\\");
ProcessSetOutputBuffer(hProcessId, reportedTo, STRING_COMPLETE);
ProcessStart(hProcessId);
StrSearchDelimited(reportedTo,STRING_COMPLETE,reportedTo,"reserved.",1,NULL,1,STR_SEARCH_FIRST);
print("reportedTo*****"+reportedTo);
VBS program is:
dim captcha
errorcounter=Wscript.Arguments(0)
errortimer=Wscript.Arguments(1)
errordetails=Wscript.Arguments(2)
errortime=Wscript.Arguments(3)
text= "Level : " & errorcounter
text= text & vbNewline
text = text & "Page : " & errortimer
text= text & vbNewline
text = text & "Error : " & errordetails
text= text & vbNewline
text = text & "Error Time : " & errortime
reportedto=inputbox( text,"ReportedTo")
You always quote parameters with spaces. This is basic Windows and was introduced 19 years ago. With the exception of chdir and notepad, all other commands and code that parses command lines expect things containing spaces to be quoted.
In vbs we would write the above string to execute as (chr(34) is a quote char)