Can I Run Batch File without CMD.exe window popping up?

Page 1 of 2 12 LastLast

  1. Posts : 52
    Windows 22H2
       #1

    Can I Run Batch File without CMD.exe window popping up?


    Hi
    I have a batch file to start streaming radio. When I double clicking on the batch file, Windows will pop up two windows: (1) a ffplay graphical UI and (2) a CMD.exe window.
    The latter CMD.exe window does nothing useful, but if I close this CMD.exe window, it also kill the ffplay UI window.

    Is there a way to make CMD.exe window not show up?

    Thanks!

    Code:
    @echo off
    @echo off
    \Users\mas\ffmpeg\bin\ffplay.exe  -v quiet http://stm.rthk.hk/radio1
      My Computer


  2. Posts : 23,413
    Win 10 Home ♦♦♦19045.4355 (x64) [22H2]
       #2

    @Massarelda

    I'm not the batch file type, but @Paul Black may be able to help.
    My mentioning his account name will notify him, when he comes online.

    I think there's something you need to add to your batch file, that will close the command prompt, but leave your program running.
    I know I've "used" batch files... that close the command prompt window, but leave the program running.
      My Computer


  3. Posts : 18,034
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #3

    Hello @Massarelda,

    It is NOT something that I use to be honest, but, you could use something like the below. Replace echo Hello Massarelda with your commands. Test the below by creating a .bat file and executing it. It will briefly flash and then become Minimized:

    Code:
    
    @echo off
    
    if not "%Minimized%"=="" goto :Minimized
    set Minimized=True
    start /min cmd /C "%~dpnx0"
    goto :EOF
    :Minimized
    
    echo Hello Massarelda
    
    pause & exit

    I think @garlin has a wrapper VBS Script that would also work.

    I hope this helps.
    Last edited by Paul Black; 10 Oct 2023 at 15:16.
      My Computer


  4. Posts : 43,146
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #4

    More in this thread:
    How to minimize a batch file running at startup via Task Scheduler?

    Ok that refers to the task scheduler, but doesn't have to be that..
      My Computers


  5. Posts : 1,196
    Windows 10
       #5

    Code:
    start /B
      My Computer


  6. Posts : 753
    Windows 10/11
       #6

    Massarelda said:
    Is there a way to make CMD.exe window not show up?
    Code:
    @echo off
    \Users\mas\ffmpeg\bin\ffplay.exe  -v quiet http://stm.rthk.hk/radio1
    You can run anything with no command window at all (not even a flash) using VBScript (or JScript). Since it's a one-liner, it's a very easy translation (you could even ask ChatGPT to translate it). For example:
    Code:
    Set oWSH = CreateObject("WScript.Shell")
    oWSH.Run "C:\Users\mas\ffmpeg\bin\ffplay.exe -v quiet http://stm.rthk.hk/radio1",1,False

    The above version is typical, but you can reduce it to a single line like this:
    Code:
    CreateObject("WScript.Shell").Run "C:\Users\mas\ffmpeg\bin\ffplay.exe -v quiet http://stm.rthk.hk/radio1",1,False

    If you want to hide the ffplay.exe window as well, just change the "1" to a "0", but I think for this application, running it minimized (and not activated) is probably your best option. That would be a "7":
    Code:
    CreateObject("WScript.Shell").Run "C:\Users\mas\ffmpeg\bin\ffplay.exe -v quiet http://stm.rthk.hk/radio1",7,False

    Save the script with a .vbs extension. Something like Radio.vbs will work.

    P.S. Here's the documentation.
    Last edited by LesFerch; 11 Oct 2023 at 08:55.
      My Computer


  7. Posts : 18,034
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #7

    Hello @Massarelda,

    Paul Black said:
    It is NOT something that I use to be honest, but, you could use something like the below. Replace echo Hello Massarelda with your commands. Test the below by creating a .bat file and executing it. It will briefly flash and then become Minimized:

    Code:
    
    @echo off
    
    if not "%Minimized%"=="" goto :Minimized
    set Minimized=True
    start /min cmd /C "%~dpnx0"
    goto :EOF
    :Minimized
    
    echo Hello Massarelda
    
    pause & exit
    Shorter version:

    Code:
    
    @echo off
    if not "%1"=="min" start /min cmd /c %0 min & Exit /b
    echo Hello Massarelda
    pause & exit

    I hope this helps.
      My Computer


  8. Posts : 18,034
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #8

    Hello @Malneb,

    Malneb said:
    Code:
    start /B
    Is there some code missing from your command as that doesn't work ?
      My Computer


  9. Posts : 1,196
    Windows 10
       #9

    Code:
    start /B "\Users\mas\ffmpeg\bin\ffplay.exe  -v quiet http://stm.rthk.hk/radio1"
      My Computer


  10. Posts : 16,978
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #10

    Massarelda said:
    Can I Run Batch File without CMD.exe window popping up?
    Yes.
    I do it the same way LesFerch does [post #6], launch it using a VBScript that makes the batch file run in a hidden window.
    I have experimented with using the Start command but I found the results unreliable.

    I make batch files run minimised rather than hidden most of the time so I get an indication when they are in progress.
    Make Task scheduler run a batch file minimised and with a specific icon - TenForums
    For example, StartCoreFilesBackup.vbs
    Code:
    CreateObject("WScript.Shell").Run chr(34) & "C:\Tools\Backup\CoreFiles\CoreFilesBackup.lnk" & Chr(34), 7
    ' runs minimised  ...., 7
    ' runs hidden ...., 0


    By the way, I notice that you repeated the command @echo off I suppose that was just an error that crept in when writing the post.



    All the best,
    Denis
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 12:46.
Find Us




Windows 10 Forums