How can I execute a process with run as admin rights and run as another user and capture output?

789 views Asked by At

I have seen a few similar questions but not one that requires all 3 so run as privileges, run as different user and capture the STDOUT:

Here is a snippet of my code it is to run the ADMT tool it needs local admin rights and domain admin rights:

Dim myShell = New Process
myShell.StartInfo.FileName = "C:\ADMT\admt.exe"
myShell.StartInfo.Arguments = strArgs
myShell.StartInfo.UseShellExecute = False
myShell.StartInfo.RedirectStandardOutput = True
myShell.StartInfo.RedirectStandardError = True
myShell.StartInfo.CreateNoWindow = True
myShell.StartInfo.Verb = "runas"
myShell.StartInfo.UserName = secureUser
myShell.StartInfo.Password = securePassword
myShell.StartInfo.Domain = myDomain
myShell.StartInfo.WorkingDirectory = "C:\ADMT"
myShell.Start()

So I have edited my app.manifest to run as either highestAvailable or requireAdministrator I get the little shield on the app and it runs ok but complains that the user doesn't have local admin rights even when I run the command prompt with admin privileges. The account quoted in the script has "Enterprise Admin" rights.

Anyone any ideas?

0

There are 0 answers