1

I have WinRAR SFX file. I know that I can extract archive using following code:

Process process = new Process();
process.StartInfo.FileName = "unrar.exe";
process.StartInfo.Arguments = "x file.rar d:\myFolder";
process.Start();
process.WaitForExit();   

But how can I extract SFX file when it have known password?

Phoenix
  • 1,045
  • 1
  • 14
  • 22
Robin.S
  • 21
  • 4

2 Answers2

3

Assuming your password is mypassword, you need to change your arguments line to this:

process.StartInfo.Arguments = @"x -pmypassword file.rar d:\myFolder";

Note that you shouldn't put a space after the -p before your password - or it'll prompt you.

I also added a @ to mark the string as a literal, otherwise it'll try to treat the \m in the file name as an escape character.

Baldrick
  • 11,712
  • 2
  • 31
  • 35
1

you can use -p as parameter
Assuming your password is 123456

Process process = new Process();
process.StartInfo.FileName = "unrar.exe";
process.StartInfo.Arguments = "x -p123456 file.rar d:\myFolder";
process.Start();
process.WaitForExit(); 
AminM
  • 1,658
  • 4
  • 32
  • 48