Making CMD Go Away After Task Is Done


  1. Posts : 7
    Windows 10
       #1

    Making CMD Go Away After Task Is Done


    Hello,

    I have a scheduled task set to run once per week. It executes a batch file that uses 7zip commands to zip a folder. It looks like:

    Code:
    @echo off
    
    
    taskkill /im "plex media server.exe"
    
    
    7za u "D:\odrive\Amazon Cloud Drive\Plex\plexbackup.7z" D:\plexdata -mx0 -up1q0r2x1y2z1w2
    
    
    "C:\Program Files (x86)\Plex\Plex Media Server\plex media server.exe"
    The script works exactly as I want to, and it runs on schedule once per week in the middle of the night, according to the settings in Windows Task Scheduler. The final line that displays in the CMD window is "Everything is OK" which is the 7zip signal that everything went as expected. My problem is that the CMD window that displays the progress while the script is running does not disappear after it is done. This is annoying for me because the machine is a home theater PC, and the prompt appears on top of my home theater app. In order to get rid of it, I have to hook up my remote keyboard and mouse.

    How can I make the CMD window go away when it is done?

    Thanks
      My Computer


  2. Posts : 0
    Dual Boot 10 Pro v1607 10 Pro rs2 build 14971
       #2

    Use exit as the last line of the script should do it.
      My Computer


  3. Posts : 7
    Windows 10
    Thread Starter
       #3

    Exit is not doing it.

    Normally typing exit in the CMD will shut it down, but in this case it doesn't.

    The last line displaying in the window is: "Everything is OK"

    It remains at that, so I don't think it is processing the exit command.

    There must be another way to make this happen.
      My Computer


  4. Posts : 201
    Kernel 4.x.x
       #4

    7Zip returns after it's finished executing, Which means a command window will exit.

    Are you sure that Plex media server.exe isn't holding the command prompt open? Try this instead.

    Code:
    @ECHO OFF
    TASKKILL /IM "plex media server.exe"
    7za u "D:\odrive\Amazon Cloud Drive\Plex\plexbackup.7z" D:\plexdata -mx0 -up1q0r2x1y2z1w2
    START "" /B "C:\Program Files (x86)\Plex\Plex Media Server\plex media server.exe"
      My Computers


  5. Posts : 7
    Windows 10
    Thread Starter
       #5

    Thanks. This worked. What is different about using the start command instead of just calling it?
      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 15:22.
Find Us




Windows 10 Forums