VBscript自动命令行“是/否”问题

时间:2012-10-02 18:47:48

标签: shell command-line vbscript automation shell-exec

我有一个VBscript可以停止进程并启动它。

在命令行中弹出一个Yes / No问题,我需要回答“是” 我怎么能务实地做到这一点?

到目前为止,我有:

Option Explicit
Dim wshShell
On Error Resume Next
   Set wshShell = WScript.CreateObject("WSCript.shell")
   If Err.Number <> 0 Then
      Wscript.Quit
   End If
   wshShell.Run  "cmd.exe /C cd C:\WINDOWS\system32 & process.exe STOP"
   WScript.Sleep 15000
   wshShell.Run  "cmd.exe /C cd C:\WINDOWS\system32 & process.exe START"
On Error Goto 0

1 个答案:

答案 0 :(得分:1)

在想要输入的程序中使用此示例:

wshShell.Run  "cmd.exe /C cd C:\WINDOWS\system32 & ( echo Yes|process.exe STOP )"

echo Yes命令将包含ENTER密钥。即:Y + e + s + ENTER