Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am using the below script to call another script .The issue is I have to pass the arguments which I retrieve by WScript.Arguments to the second script that I am calling .can someone please tell me how to do that.

Dim objShell
Set objShell = Wscript.CreateObject("WScript.Shell")

objShell.Run "TestScript.vbs"    

Set objShell = Nothing
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
696 views
Welcome To Ask or Share your Answers For Others

1 Answer

You need to build your argument list with proper quoting of the arguments. You also need to differentiate between named and unnamed arguments. At the very minimum, all arguments with spaces in them must be put between double quotes. It doesn't hurt, though, to simply quote all arguments, so you could do something like this:

Function qq(str)
  qq = Chr(34) & str & Chr(34)
End Function

arglist = ""
With WScript.Arguments
  For Each arg In .Named
    arglist = arglist & " /" & arg & ":" & qq(.Named(arg))
  Next
  For Each arg In .Unnamed
    arglist = arglist & " " & qq(arg)
  Next
End With

CreateObject("WScript.Shell").Run "TestScript.vbs " & Trim(arglist), 0, True

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...