我写的是从Silk bdh调用一个VBScript,并从Silk传递参数。我的第一个问题是有超过1个参数(总共4个参数)。我的第二个问题是这些参数包含空格。
下面是程序:
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程序是:
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")发布于 2014-03-28 21:21:20
您总是用空格引用参数。这是基本的Windows,是19年前引入的。除了chdir和记事本之外,所有其他命令和解析命令行的代码都希望对包含空格的内容加引号。
dir "c:\some folder\some file.txt" /a在vbs中,我们会写上上面的字符串来执行(chr(34)是一个引号字符)
"dir " & chr(34) & "c:\some folder\some file.txt" & chr(34) & " /a"https://stackoverflow.com/questions/22705845
复制相似问题