4

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?

Ňɏssa Pøngjǣrdenlarp
  • 38,411
  • 12
  • 59
  • 178
Stevie187
  • 63
  • 3
  • `myShell.StartInfo.Verb = "runas"` doesn't work when `myShell.StartInfo.UseShellExecute = False`, and since you start the new process as an other user it won't inherit your application's admin privileges. Hmm... Tough problem... – Visual Vincent Aug 30 '17 at 19:18
  • ahh thanks for that I was wondering why it wasn't inheriting the admin privileges. I had a feeling it can't be done if it can't I will just have to go back to the old way of the scheduled task running under the enterprise admin account. – Stevie187 Aug 31 '17 at 08:13
  • Why do you think you need to run using an enterprise admin account? Elevation runs as local administrator. – Bill_Stewart Sep 12 '17 at 19:01

0 Answers0