This question already has an answer here:
I have a Visual Studio Windows app project. I've added code to download an installer update file. The installer after it has finished downloading would need administrator privileges to run. I have added a manifest file.
When user clicks on the DownloadUpdate.exe, UAC prompts the user for Admin permissions. So I assumed that all processes created and called within DownloadUpdate.exe will run in admin capacity. So I made the setup call my downloaded file with the following code:
Process p = new Process();
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.FileName = strFile;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
This is a clear answer to your question: How do I force my .NET application to run as administrator?
Summary:
Right Click on project -> Add new item -> Application Manifest File
Then in that file change a line like this:
Compile and run!
Try this:
Alternatively, go the manifest route for your application.
Use this method:
Hope it helps.
You probably need to set your application as an x64 app.
The IIS Snap In only works in 64 bit and doesn't work in 32 bit, and a process spawned from a 32 bit app seems to work to be a 32 bit process and the same goes for 64 bit apps.
Look at: Start process as 64 bit
First of all you need to include in your project
After that you could write a general method that you could use for different .exe files that you want to use. It would be like below:
If you want to for example execute notepad.exe then all you do is you call this method: