# Solved: WinRar Command Line Question



## Reconsniper1 (Apr 17, 2008)

Hello Everyone!
I'm a first time poster! My current project is making a batch file that will compress a folder / drive, password protect it. I then I will include my Nero batch info and burn it to DVD so that it is password protected. I'm having issues with the Winrar batch part. I have it listed below 


"C:\Program Files\WinRAR\rar.exe" a -m5 -e -pTest c:\test\ c:\

However it doesn't copy anything. Can someone please help me out if my flags are incorrect or syntax is incorrect. 

Thanks in advanced,
T


----------



## TheOutcaste (Aug 8, 2007)

Welcome to TSG!


Reconsniper1 said:


> Hello Everyone!
> I'm a first time poster! My current project is making a batch file that will compress a folder / drive, password protect it. I then I will include my Nero batch info and burn it to DVD so that it is password protected. I'm having issues with the Winrar batch part. I have it listed below
> 
> "C:\Program Files\WinRAR\rar.exe" a -m5 -e -pTest c:\test\ c:\
> ...


"*C:\Program Files\WinRAR\rar.exe*" a -m5 *-e* -pTest *c:\test\* *c:\*

*-e* Invalid switch. I'm guessing you want *-ed* to not archive empty folders
*c:\test\* This tells WinRar to create an archive named *c:\test\.rar*, which is an invalid name. This should be just *C:\test* or better yet *c:\test.rar*
*c:\* Do you really want to put the entire C: drive into the archive? This will include the page file and hibernation file if it exists, and could take several hours. If your drive is more than 50% full, it could crash before it finishes, as it may run out of disk space.

The following will create an archive named test.rar in the root of the C drive which will contain the contents of the folder C:\test and all subfolders except empty ones.

*"C:\Program Files\WinRAR\rar.exe" a -m5 -ed -pTest c:\test.rar c:\test*

If you need to specify a particular type of file AND include subfolders, you have to use the -r switch:
*"C:\Program Files\WinRAR\rar.exe" a -m5 -ed -pTest c:\test.rar c:\test\*.doc*
will back up *.doc files in the Test folder only
*"C:\Program Files\WinRAR\rar.exe" a -m5 -ed -pTest -r c:\test.rar c:\test\*.doc*
will back up *.doc files in the Test folder *and* subfolders.

HTH

Jerry


----------



## TheOutcaste (Aug 8, 2007)

An additional thought, It would be a good idea to add a recovery record. This will allow you to repair the archive in case there is an error during the burn, or later on trying to read the file. A 1% recovery record will allow you to recover the archive even if a section up to 0.6% of the archive size is damaged.
See the -rr switch in the help file.

Jerry


----------



## Reconsniper1 (Apr 17, 2008)

Hello all and thanks for your replies. I wasn't trying to imply that I was backing up the complete C: drive. That would be insane. I actually had the syntax incorrect. I have corrected it and used the following batch file. It works so i'm happy with that. 

"C:\Program Files\WinRAR\rar.exe" a -m5 -ed -r -rr -x*.jpg -pTest "c:\Backup 

%date:~10,4%_%date:~4,2%_%date:~7,2%.rar" Z:\
Pause

I have this section of my batch file complete. Now I need to get a few other piece fixed and it will be complete. 

I will find the correct place for DOS batch questions.  Thanks again.


----------



## TheOutcaste (Aug 8, 2007)

You're Welcome!
Dos forum is here: http://forums.techguy.org/23-dos-pda-other/

If your issue has been resolved you (and ONLY you) can use the Thread Tools at the Upper Right (above the first post) to mark this thread Solved.


----------

