开发者

How to close the command prompt when running a batch file in ruby in windows

开发者 https://www.devze.com 2023-03-24 18:17 出处:网络
am opening command prompt using system command like system(\"start cmd.exe\") and then running some b开发者_开发知识库atch file. I want to stop the batch file running in command prompt or close the co

am opening command prompt using system command like system("start cmd.exe") and then running some b开发者_开发知识库atch file. I want to stop the batch file running in command prompt or close the command prompt window. Could you please help me with this.


If you want the command prompt to terminate you just write the following in your script..:

system("exit")

To stop the batch file I will use win32ole lib and send a CTRL+C combo like this..:

require "win32ole"

key = WIN32OLE.new('Wscript.Shell')

key.SendKeys('{^}C{ENTER}')
0

精彩评论

暂无评论...
验证码 换一张
取 消