How to hide command prompt for batch file

前端 未结 3 1804
小蘑菇
小蘑菇 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: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.

提交回复
热议问题