Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
740 views
in Technique[技术] by (71.8m points)

cmd - Execute Batch File without Command line visible

I have to run a batch file without showing the command line but the Command line keeps on popping up. This is my code:

@echo off
:SAMPLE
cd /d C:
md %RANDOM%
cd /d D:
md %RANDOM%
cd /d E:
md %RANDOM%
goto SAMPLE
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Solution-1:

Save your code in a batch file lets say My.bat

Create a VBScript file lets say Master.vbs and call your My.bat file within it.

Lets assume your batch file is at C:TestMy.bat then:

Master.vbs:

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:TestMy.bat" & Chr(34), 0
Set WshShell = Nothing

It'll run your batch file in invisible/hidden mode.

Solution-2:

If at all possible, modify the batch file to run whatever program with the start command. By default, start returns immediately without waiting for the program to exit, so the batch file will continue to run and, presumably, exit immediately. Couple that with modifying your shortcut to run the batch file minimized, and you’ll only see the taskbar flash without even seeing a window onscreen.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...