4,008
社区成员
发帖
与我相关
我的任务
分享
Set ws = WScript.CreateObject ("WSCript.shell")
cmd = "C:\a.exe"
//启动控制台应用
Set oExec = ws.Exec(cmd)
Do While oExec.Status = 0
WScript.Sleep 100
Loop
WScript.Echo oExec.Status
wscript.sleep 3000
//在启动后的控制台应用中输入a选项(这个控制台里都是选项 输入a是为了模拟选择a项)
oexec.StdIn.WriteLine "a"
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("cmd.exe")
WScript.Sleep 2000
oExec.StdIn.WriteLine "title testing"
WScript.Sleep 10000
Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("calc")
Do While oExec.Status = 0
WScript.Sleep 100
Loop
WScript.Echo oExec.Status
我以前为了用runas命令也研究过这个问题。exec确实是可以用的,但由于runas命令的特殊性,在输入密码时还是不成功。后来有找到一个别人写的runas的替代品,不用手工输入密码了,所以也没再研究了。