某个服务可以通过telnet登录并且执行命令后退出。vbs的实现方式如下:
set sh=WScript.CreateObject(“WScript.Shell”)
WScript.Sleep 2000
sh.SendKeys “open 127.0.0.1 8080{ENTER}”
WScript.Sleep 3000
sh.SendKeys “admin{ENTER}”
WScript.Sleep 4000
sh.SendKeys “123456{ENTER}”
WScript.Sleep 4000
sh.SendKeys “reload{ENTER}”
WScript.Sleep 4000
sh.SendKeys “exit{ENTER}”
WScript.Sleep 3000
sh.SendKeys “{ENTER}”
WScript.Sleep 3000
sh.SendKeys “quit{ENTER}”
rem 启动telnet
start telnet.exe
rem batch telnet
cscript //nologo telnet.vbs
那么使用powershell的方式如何实现呢?
1 Answers
和服务没有关系,你其实就是启动了一个进程telnet,然后通过send keys的方式进行命令交互:
https://stackoverflow.com/questions/17142389/powershell-sending-keystrokes-e-g-f5-after-opening-an-application
嗯,值得参考,但是不是想要的结果