通过丝绸在vbs中传递参数(包含空格)

时间:2014-03-28 06:37:40

标签: vbscript silk-performer

我写信从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")

1 个答案:

答案 0 :(得分:0)

您始终引用带空格的参数。这是基本的Windows,并于19年前推出。除了chdir和notepad之外,解析命令行的所有其他命令和代码都需要引用包含空格的内容。

dir "c:\some folder\some file.txt" /a

在vbs中我们会写上面的字符串来执行,因为(chr(34)是一个引号char)

"dir " & chr(34) & "c:\some folder\some file.txt" & chr(34) & " /a"