Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello.
Can somebody please tell me a code to open up System Restore in Windows.
Thank you in advance.

What I have tried:

I have tried Process.Start("C:\Windows\System32\rstrui.exe") and it didn't work. That is the exact location of the file. I also tried
C#
System.Diagnostics.Process.Start(Environment.SystemDirectory + "\rstrui.exe") and System.Diagnostics.Process.Start(Environment.SystemDirectory + "\restore\rstrui.exe")..  

They did not work either.

Note: i have checked in system32 directory and rstrui.exe exist in it.when i open it manually then it is open successfully
Posted
Updated 5-Dec-16 0:00am
v2
Comments
dan!sh 5-Dec-16 5:04am    
What is the error you are getting?
mKhemraj 5-Dec-16 5:11am    
the system cannot find the file specified
Richard MacCutchan 5-Dec-16 5:07am    
What does "did not work" mean?
mKhemraj 5-Dec-16 5:11am    
getting error - the system cannot find the file specified
Richard MacCutchan 5-Dec-16 5:14am    
Then your path is wrong, or you have a permissions problem.
Your string contains an unescaped backslash, which makes the two characters \r act as a carriage return. Use the @ prefix or double backslash in the string.

There are a couple of problems here: Windows and Windows\System32 are system folders, so access to them is not guaranteed - and if you can't access the folder, you can't access the application. Start by checking the permissions that the user your app will run as has to access the folders.

Secondly, what you want to do is rather strange: restoring your system from within a application is an odd way to behave.

Though if I try it:
C#
string path = Path.Combine(Environment.SystemDirectory, "rstrui.exe");
Process.Start(path);

It works for me - and I press Cancel immediately! :laugh:
 
Share this answer
 
Comments
mKhemraj 5-Dec-16 5:32am    
thanks OriginalGriff, but i have checked same.. its not working..
So, you have to make sure few things are as follows here:

1. You build configuration is AnyCPU.
2. You are running VS as administrator.
3. You are using path to the file as c:\windows\sysnative\rstrui.exe on 64-bit machines. (File System Redirector (Windows)[^])
 
Share this answer
 
Comments
mKhemraj 5-Dec-16 6:02am    
thank you very much.. its working fine..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900