可能重复:
How to force C# App to run as administrator on Windows 7
我创建了一个.NET应用程序,它可以处理一些文件。我在Windows Vista和Windows 7中遇到的问题是,如果用户没有右键单击以管理员身份运行应用程序,他/她将获得一个无法处理的异常窗口。
有没有办法绕过这个?
以下是堆栈跟踪: -
************** Exception Text **************
System.UnauthorizedAccessException: Please run the application as an administrator
at .(Object , EventArgs )
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
请告诉我是否可以采取措施避免此事。
谢谢, 罗恩