Close Command Window Automatically After Unrar

This guide explains how to automatically close the Windows Command Prompt window once the unrar extraction process finishes. By default, how the command line behaves depends on how the utility was launched. You can ensure the window exits immediately upon completion by using native Windows command flags, structuring batch files properly, or removing blocking commands.

Method 1: Execute with the cmd /c Parameter

If you are running unrar from a shortcut, a script, or the Windows Run dialog (Win + R), use the /c switch with cmd.exe. The /c flag instructs the Command Prompt to carry out the specified command and then terminate immediately.

Run the following command:

cmd /c unrar x "archive.rar" "C:\DestinationFolder\"
  • cmd /c launches a temporary terminal session and terminates it when execution finishes.
  • x extracts files with full paths.

Method 2: Update Batch Files with the exit Command

If you run unrar inside a batch file (.bat or .cmd), the window often stays open because of an interactive command or because it was launched from an existing shell.

  1. Open your .bat file in a text editor like Notepad.
  2. Check the end of the script for the pause command. If it is present, delete it.
  3. Add the exit command to the very end of your script:
@echo off
unrar x "archive.rar" "C:\DestinationFolder\"
exit

Once the extraction finishes, the script executes exit, which terminates the Command Prompt window automatically.

Method 3: Use the Windows start Command

If you trigger the extraction from an existing script or terminal and want it to run in a self-closing external window, you can use the start command paired with /wait and cmd /c:

start /wait cmd /c unrar x "archive.rar" "C:\DestinationFolder\"

The new window opens, extracts the archive, and closes instantly upon completion without interrupting the caller environment.