How to hide command prompt for batch file

前端 未结 3 1704
小蘑菇
小蘑菇 2021-01-22 22:51

I have a batch file that runs some commands and open some files in explorer. I want to happen these actions without opening any command prompt. Is it possible? If so, how?

相关标签:
3条回答
  • 2021-01-22 23:15

    You can use Bat to exe file converter to convert the file to run in invisible mode as enunciated in this stackoverflow answer, image as follows

    0 讨论(0)
  • 2021-01-22 23:22

    Not exactly your answer as you probably don't wanna use VBS but yes, it'll make command prompt completely invisible.

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

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

    Lets assume your batch file is at C:\Test\My.bat then:

    Master.vbs:

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

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

    0 讨论(0)
  • 2021-01-22 23:31

    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.

    0 讨论(0)
提交回复
热议问题