开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜