Close a command prompt CMD?

Solved
Hello,

I wrote a small batch script intended to restart a program as simply as possible:
@echo off taskkill /im software.exe /F "C:\Program Files\folder\software.exe" exit 


The program restarts in 1/10 of a second, no problem...
Well, yes!

As soon as the "taskkill" executes, it opens a command prompt just to tell me
"Operation successful: the process "software.exe" with PID 9999 has been terminated."

How can I close this window directly (or even prevent it from appearing at all)? Its appearance breaks the simple principle of my script...

Thank you!

Configuration: Windows 7 / Chrome 54.0.2840.59

5 answers

  1. Moderator
    Hello,

    To close
    :quit

    Or quit without the :

    Or you can convert a .bat to .exe with bat to exe converter

    It seems to me that the cmd window doesn't show up, or if you don't want it to.

    https://www.commentcamarche.net/telecharger/developpement/4555-bat-to-exe-converter/
    1. Hello,

      the :quit doesn't change anything, it still opens a cmd window to tell me that the operation is successful

      the quit (without the :) simply tells me that "quit is not a valid Windows command"

      I'm testing by converting the .bat to .exe and I'll keep you updated
    2. Well, that's great, it's restarting everything without any issues, perfect ^^

      Thank you very much
      I’ll mark the topic as "resolved"
  2. Moderator
    Hello,

    Try this:

    @echo off taskkill /im software.exe /F >nul "C:\Program Files\folder\software.exe" exit
    1. I had seen it on another page, the ">nul", I tried but nothing works...
      It always opens a CMD, which is empty (instead of displaying "Operation successful, etc.", but it appears anyway)
    2. Moderator
      @Dkeagle1911Strange, I do it at home and the CMD opens up, runs the program, then closes (with the Exit command).

      Do you end up with a cmd open with your command and that's it?
      Can you send a screenshot?
    3. Moderator
      @Dkeagle1911Don't you have the same video with the >nul?
      Because yes, the cmd window opens and closes automatically, right?!

      If so, that's normal behavior!
    4. No, I don't have a video with the >null, but the only change is that the cmd window, instead of displaying "Operation successful" etc., simply shows nothing
      but it is still there and unfortunately does not close by itself
      I have to go and close it myself by clicking on it,

      for an operation that I wanted to be simple and quick with a .bat file, that's one click too many xD
  3. Hello, I don’t know if I can help you, but here’s how I personally use my taskkill on Windows 10:

    C:\Windows\System32\taskkill.exe /F /FI "USERNAME eq *session_name* /FI "IMAGENAME ne explorer.exe" /FI "IMAGENAME ne dwm.exe" /FI "IMAGENAME ne sihost.exe"

    This has the effect of closing EVERYTHING except explorer.exe / dwm.exe and sihost.exe

    and I don't have any window left open

    In doubt, reboot! When it fails, format!
    LePetitJimmy
    1. I just made a short video of the problem, so that everyone understands exactly WHERE it is...

      The code executes fine, Rainmeter, which manages my desktop, restarts properly (you can see it restarting in the video)
      but the code opens a CMD just to confirm that it has indeed closed the process before restarting it, and this window, I have to close it manually

      https://www.youtube.com/watch?v=6dH0EHp5f1M&feature=youtu.be

      Thank you ^^
      1. /F >null
      2. As I mentioned in my response to Crapoulou, the >nul after Taskkill allows you to "clear" the window (the "Operation successful" message does not appear, but the window, even empty, still opens...).