VBS向终端交互式写入多个命令

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.SendKeys "python{ENTER}"  
WScript.Sleep 1000  

WshShell.SendKeys "123456{ENTER}"
WScript.Sleep 1000 

WshShell.SendKeys "exit{(}{)}"
WScript.Sleep 1000 

WshShell.SendKeys "{ENTER}"
WScript.Sleep 1000 

WshShell.SendKeys "systeminfo{ENTER}"
WScript.Sleep 1000 

C:\Users\xxx\Desktop>cscript send_cmd.vbs
Microsoft (R) Windows Script Host Version 5.812
版权所有(C) Microsoft Corporation。保留所有权利。


C:\Users\xxx\Desktop>python
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Help on built-in function ShellExecute in module win32api:

ShellExecute(...)

None
>>> 123456
123456
>>> exit()

C:\Users\23798\Desktop>systeminfo

主机名: DESKTOP-xxxxx
OS 名称: Microsoft Windows 10 家庭中文版

 

posted @ 2025-06-17 22:51  我的腹肌不见了  阅读(14)  评论(0)    收藏  举报