将多个输入传递给命令窗口,在vbscript中调用shell [英] Pass multiple inputs to command window, invoking shell in vbscript

查看:84
本文介绍了将多个输入传递给命令窗口,在vbscript中调用shell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望通过命令提示符安装.exe文件,在运行每个阶段时,它会询问详细信息,例如计算机名称,密码等,我想使用shell命令通过Vbscript。这是我的剧本。

使用;要拆分命令,每个命令必须在上一个命令成功运行后运行。这种方法不起作用。任何人都可以帮助我。



我尝试过:



Dim ObjWB,ObjWS,ObjXL,CompName,Pasword

设置WShell = CreateObject(WScript.Shell)

Dim shell:设置shell = CreateObject(Shell.Application )

设置ObjXL = CreateObject(Excel.Application)

设置ObjWB = ObjXL.Workbooks.open(FilePath)

设置ObjWS = ObjWB.Worksheets(1)

服务器= msgbox(它是服务器,vbYesNo,环境详细信息)

选择案例服务器

case6

Wshell.run(cmd /KC:\temp\run.exe&;& CompName&;& Pasword)

结束选择

I am looking to install an .exe file through command prompt, while running each stage it will ask for details such as computer name, password etc,which I want to pass through Vbscript using shell commmand. Here is my script.
Am using ";" to split the command, Every command has to run after previous commend runs successfully. This method is not working. Can any one help me out.

What I have tried:

Dim ObjWB,ObjWS,ObjXL,CompName,Pasword
Set WShell = CreateObject("WScript.Shell")
Dim shell : Set shell = CreateObject("Shell.Application")
Set ObjXL = CreateObject("Excel.Application")
Set ObjWB = ObjXL.Workbooks.open(FilePath)
Set ObjWS = ObjWB.Worksheets(1)
Server = msgbox("Is it a Server",vbYesNo,"Environment Details")
Select case Server
case "6"
Wshell.run("cmd /K C:\temp\run.exe &";"& CompName &";"& Pasword )
End Select

推荐答案

你不能将多个字符串传递给一个带外壳的进程。好吧,不管怎样你的Wshell.Run()调用。



你只是通过命令行将参数传递给run.exe。只是试图在Run调用中提供多个字符串是NO我要做一个开始 - >运行 - > run.exe,然后等待进程启动并在其上键入ComputerName,再次等待,然后键入密码。这不是Windows的工作方式,也不是其他任何操作系统。



你的run.exe可以接受你想要的东西的命令行参数传入或者您将不得不找到输入该ComputerName和密码的其他方式,具体取决于run.exe的应用程序类型。
You cannot "pass multiple strings" to a shelled process. Well, not like your Wshell.Run() call anyway.

You're only going to pass arguments to the run.exe through the command line. Just trying to provide multiple strings in the Run call is NOT going to do a Start->Run -> run.exe, then wait for the process to start and "type" a ComputerName at it, wait again and then "type" a password. That's not how Windows works, nor any other O/S for that matter.

Either your run.exe can accept command line parameters for the stuff your'e trying to pass in or you're going to have to find other ways of inputting that ComputerName and Password, depending on the type of application run.exe is.


这篇关于将多个输入传递给命令窗口,在vbscript中调用shell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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