I am trying to run an exe file from another user account name, it shows following error
System.ComponentModel.Win32Exception: The requested operation requires an elevation
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
Here is my code
ProcessStartInfo pro = new ProcessStartInfo(application);
pro.UseShellExecute = false;
pro.Verb = "runas";
pro.WorkingDirectory = workingdirectory;
pro.RedirectStandardInput = true;
pro.RedirectStandardOutput = true;
pro.CreateNoWindow = true;
Process process = Process.Start(pro);
How to resolve this?
What Does 'The Requested Operation Requires Elevation' Mean in Windows 10? As the error message indicates, you can only gain access to or take ownership of the file/folder by getting the elevated permission of a local administrator. So, to resolve the problem, you need to change the ownership of the drive.
In the Search box, type cmd.exe but do NOT press Enter. In the search results window, under Programs, right-click on the program cmd.exe. In the pop-up menu, select Run As Administrator.
For Windows 7 and Windows 2008 R2, click User Account Control Settings link. This opens the User Account Control Settings dialog showing the control level. Drag and choose the control level to Never Notify and click OK.
The term “elevation” simply means that you need a “higher” level of access to the system than you currently have. The privileges associated with your current login need to be temporarily raised or “elevated” to a more privileged or powerful level.
Unfortunately, you cannot do
simultaneously.
Reason:
Verb
is only recognized when UseShellExecute = true
, butUseShellExecute = false
.More information:
I guess in your situation you will have to skip using runas
, but rather ensure that your application is already started with the correct user account/permissions. This should work, since processes started by elevated processes "inherit" elevation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With