开发者

batch file: hide console when using start /wait

开发者 https://www.devze.com 2023-03-24 02:35 出处:网络
@echo off start /wait notepad.exe somefile.txt if exist somefile.txt echo it exists. this will display the normal console screen as well as notepad until notepad is closed. i don\'t want the console
@echo off
start /wait notepad.exe somefile.txt
if exist somefile.txt echo it exists.

this will display the normal console screen as well as notepad until notepad is closed. i don't want the console screen to appear; notepad must have focus; the 'if exist' line must not run until notepad is closed. the script is run from 'total commander' but running it from 'start/run' returns same results. the second line of code is irr开发者_如何学Pythonelevant for this example.

cmd.exe /k does same thing.

internal batch commands only. thanks!

win 7 64 bit


You can use Windows Script Host to run your batch file. For example, create the file "startmybatch.vbs" with the following content:

Set ws = WScript.CreateObject("WScript.Shell")
cmd = "c:\mypath\mybatch.bat"
ret = ws.Run(cmd, 0, True)
Set ws = Nothing

then run "startmybatch.vbs" directly, or using "wscript startmybatch.vbs". At least on XP this works (console window is not visible). I think this will work on all Windows versions >= Win98.

0

精彩评论

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