如何使用C#打开系统还原('rstrui.exe') [英] How to open system restore ('rstrui.exe') using C#

查看:165
本文介绍了如何使用C#打开系统还原('rstrui.exe')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。

有人可以告诉我一个在Windows中打开系统还原的代码。

提前谢谢。



我尝试了什么:



我已经尝试过Process.Start(C:\ Windows \ System32 \\\trutrui.exe)但它没有用。这是文件的确切位置。我也试过

 System.Diagnostics.Process.Start(Environment.SystemDirectory +   \rstrui.exe)和System.Diagnostics.Process.Start(Environment.SystemDirectory +   \restore \rstrui.exe).. 



它们也不起作用。



注意:我已经检查了system32目录并且其中存在rstrui.exe。当我手动打开它然后它成功打开

解决方案

这里有一些问题:Windows和Windows \ System32是系统文件夹,因此无法保证对它们的访问 - 如果您无法访问该文件夹,则无法访问应用程序。首先检查您的应用将运行的用户必须访问文件夹的权限。



其次,您想要做的是相当奇怪的:恢复您的系统在一个应用程序中是一种奇怪的行为方式。



虽然如果我尝试它:

  string  path = Path.Combine(Environment.SystemDirectory,  rstrui。 EXE); 
Process.Start(路径);



它对我有用 - 我立即按取消! :笑:


所以,你必须确保这里的一些事情如下:



1.你构建配置是AnyCPU。

2.您正在以管理员身份运行VS.

3.您正在使用该文件的路径为 c:\windows \ 64位计算机上的sysnative\rstrui.exe 。 (文件系统重定向器(Windows) [< a href =https://msdn.microsoft.com/en-us/library/windows/desktop/aa384187(v=vs.85).aspx\"target =_ blanktitle =New Window> ^ ])

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

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

解决方案

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:

string path = Path.Combine(Environment.SystemDirectory, "rstrui.exe");
Process.Start(path);


It works for me - and I press Cancel immediately! :laugh:


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)[^])


这篇关于如何使用C#打开系统还原('rstrui.exe')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆