Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

Hide Command Window of .BAT file that Executes Another .EXE File

This is a batch file in Windows.

Here is my .bat file

@echo off
copy "C:Remoting.config-Training" "C:Remoting.config"

"C:ThirdParty.exe"

This works fine except the .bat file leaves the command window open the whole time the "ThirdParty" application is running.
I need the command window to close.

I would use the short-cut for the application but I must be able to run this copy command first (it actually changes which data base and server to use for the application).

The ThirdParty application does not allow the user to change the source of the db or the application server.

We're doing this to allow users to change from a test environment to the production environment.

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

Using start works for me:

@echo off
copy "C:Remoting.config-Training" "C:Remoting.config"
start C:ThirdParty.exe

EDIT: Ok, looking more closely, start seems to interpret the first parameter as the new window title if quoted. So, if you need to quote the path to your ThirdParty.exe you must supply a title string as well.

Examples:

:: Title not needed:
start C:ThirdParty.exe

:: Title needed
start "Third Party App" "C:Program FilesVendorThirdParty.exe"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...