如何用VBS往dos窗口输入字符

来源:百度知道 编辑:UC知道 时间:2024/09/23 12:09:53
就是怎么用vbs或SendKeys往DOS窗口输入字符例如往DOS窗口输入:cd.. dir
之类的~~`哪为大侠教教我把
麻烦各位大虾尽快帮我弄出答案啊~~~~谢谢了~~~~~

For Each p In GetObject("WinMgmts:").ExecQuery("select * from Win32_Process where name='cmd.exe'")
With GetObject("", "WScript.Shell")
.AppActivate p.ProcessID
.SendKeys "cd..~"
.SendKeys "dir~"
End With
Exit For
Next

不一定要用sendkey来做
下面就是一个例子

set obshell=wscript.createobjext(wscript.shell)
obshell.run "cmd.exe dir c:\ > c:\a.txt",,true