从另一个传递参数的 vbscript 文件调用 vbscript [英] calling vbscript from another vbscript file passing arguments

查看:23
本文介绍了从另一个传递参数的 vbscript 文件调用 vbscript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用下面的脚本来调用另一个脚本.问题是我必须将通过 WScript.Arguments 检索到的参数传递给我正在调用的第二个脚本.有人可以告诉我怎么做吗.

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

推荐答案

您需要通过正确引用参数来构建参数列表.您还需要区分命名参数和未命名参数.至少,所有带有空格的参数都必须放在双引号之间.不过,简单地引用所有参数并没有什么坏处,因此您可以执行以下操作:

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

这篇关于从另一个传递参数的 vbscript 文件调用 vbscript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆