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

前端 未结 15 1945
猫巷女王i
猫巷女王i 2020-12-02 12:50

This is a batch file in Windows.

Here is my .bat file

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

\"C:\\ThirdPar         


        
相关标签:
15条回答
  • 2020-12-02 13:18

    I used this to start a cmd file from C#:

    Process proc = new Process();
    proc.StartInfo.WorkingDirectory = "myWorkingDirectory";
    proc.StartInfo.FileName = "myFileName.cmd";
    proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    proc.Start();
    proc.WaitForExit();
    
    0 讨论(0)
  • 2020-12-02 13:20

    You might be interested in trying my silentbatch program, which will run a .bat/.cmd script, suppress creation of the Command Prompt window entirely (so you won't see it appear and then disappear), and optionally log the output to a specified file.

    0 讨论(0)
  • 2020-12-02 13:21

    To make the command window of a .bat file that executes a .exe file exit out as fast as possible, use the line @start before the file you're trying to execute. Here is an example:

    (insert other code here)
    @start executable.exe
    (insert other code here)
    

    You don't have to use other code with @start executable.exe.

    0 讨论(0)
  • 2020-12-02 13:22

    Great tip. It works with batch files that are running a java program also.

    start javaw -classpath "%CP%" main.Main
    
    0 讨论(0)
  • 2020-12-02 13:23

    Create a .vbs file with this code:

    CreateObject("Wscript.Shell").Run "your_batch.bat",0,True
    

    This .vbs will run your_batch.bat hidden.

    Works fine for me.

    0 讨论(0)
  • 2020-12-02 13:25

    Using start works fine, unless you are using a scripting language. Fortunately, there's a way out for Python - just use pythonw.exe instead of python.exe:

    :: Title not needed:
    start pythonw.exe application.py
    

    In case you need quotes, do this:

    :: Title needed
    start "Great Python App" pythonw.exe "C:\Program Files\Vendor\App\application.py"
    
    0 讨论(0)
提交回复
热议问题