Joey Joey - 18 days ago 8
Vb.net Question

Open an external program as Administrator?

I know I can make my program start with admin rights, but how do I open a different program with admin rights programmatically using vb.net?

example:

Process.start.RunAsAdmin?("C:\Test.exe")


How do I open Test.exe as an admin from vb.net?
I know in the property settings of Test.exe I can choose to "Run as Admin" but I would like to do it from vb.net, as Test.exe was just an example and will not be included from my vb.net project.

Answer

Like @Hans already wrote in his comment, you can start a process with elevated rights by creating a ProcessInfo object and set its relevant properties:

Dim startInfo as new ProcessStartInfo();
startInfo.UseShellExecute = true;
startInfo.WorkingDirectory = "C:\";
startInfo.FileName = "Test.exe";
startInfo.Verb = "runas";

Process.Start(startInfo);