我想运行一个脚本,该脚本发送一些从数组中获取输入的命令。对于数组的每个元素,我希望打印到另一个日志文件。
我到目前为止制作的剧本如下,但不起作用。似乎只存储发送的最后一个命令的打印。
请问正确的方法怎么样?
#$language = "VBScript"
#$interface = "1.0"
crt.Screen.Synchronous = True
Sub Main
arr = "1,2,3"
a = Split(arr, ",")
For i = LBound(a) To UBound(a)
crt.Session.Log False 'Turn off log session
crt.Session.LogFileName = "C:\Users\Path\MyLogfile No." & a(i) & ".log" 'Define log file name
crt.Session.LogUsingSessionOptions 'Turn on log session
crt.Screen.Send "some command" & a(i) & ";" & Chr(13) 'Some command sent to each arr element, this part works fine
Next
crt.Session.Log False
'Restore the default log file
crt.Session.LogFileName = "C:\Users\myuser\Documents\default.log"
End Sub