Windows Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 5.00

Running WinRAR in a Command Line Window

This section provides a tutorial example on how to run WinRAR in a command line window.

WinRAR also support command line operations. This is important to allow users to incorporate WinRAR commands into automated scripts. Here is a simple script I used to backup a directory, backup.bat:

@rem backup.bat
@rem Usage: backup directory zipfile password

\local\winrar\winrar a -afzip -r -p%3 %2.zip %1\*.*

My restore script is also very simple, restore.bat:

@rem restore.bat
@rem Usage: restore zipfile password

\local\winrar\winrar x -p%2 %1.zip .\

Note that:

  • Command "a" is to create archive files.
  • Option "-afzip" is to create archive files in ZIP format.
  • Option "-r" is to take input files recursively to include sub-directories.
  • Option "-p*" is to add password protection to archive files.
  • Command "x" is to extract files out of archive files.

For complete description of the command line interface of WinRAR, see the WinRAR help document.

Sections in This Chapter

What Is WinRAR?

Downloading and Installing WinRAR 3.42

Adding Files to a New RAR File

Extracting All Files from a RAR File

Setting Passwords in RAR Files

Creating Multi-Volume RAR Files

Setting Windows Explorer Context Menu

Compressing Files with ZIP Format

Running WinRAR in a Command Line Window

Dr. Herong Yang, updated in 2008
Running WinRAR in a Command Line Window