Nếu bạn cần làm việc với các tham số trong vbscript, bạn có thể truy xuất chúng qua 1 mảng array
If Wscript.Arguments.Count = 0 Then
‘ Do Proceed as Normal
Else
If Wscript.Arguments(0) = “/something” Then
RunFunctionA
End If
End If
Trong trường hợp bạn cần xử lý với từng tham số cụ thể (vd -stop hay -start). Cách dễ nhất là dùng mệnh đề If trong vòng lặp để bắt tham số.
If Wscript.Arguments.Count = 0 Then
‘ Do Proceed as Normal
Else
For i = 0 to Wscript.Arguments.Count – 1
If Wscript.Arguments(i) = “/reset” Then
resetflag=1 ’Turn on the reset flag
ElseIf Wscript.Arguments(i) = “/nolog” Then
loggingflag = 0 ‘Turn off the logging flag
End If
Next
End If
If loggingFlag =0 Then
‘Don’t log
Else
LogMyStuff ‘ Call the function you want
End If
Câu trả lời của bạn