1
votes

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?

2

2 Answers

3
votes

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.

1
votes

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();