I've put code together to be able to open a saved MSC file but this needs to open as another user. This MSC file just opens Active Directory Users and Computers, DHCP, DNS, etc but it's only my admin account that will have permissions to this. I'll also want to do the same for Exchange Management Console which is also an MSC file.
The problem is I get the error "The requested operation requires elevation" I've tested this outside of Visual Studio by running the built exe using my normal account and an elevated admin account and it still gives the same error
Here's the code:
Dim passwordString As String
passwordString = "blahblahblah"
Dim password As SecureString = ConvertToSecureString(passwordString)
Dim p As New ProcessStartInfo
p.FileName = "mmc.exe"
p.WorkingDirectory = "C:\Windows\System32"
' Use these arguments for the process
p.Arguments = "mymmc.msc"
p.Domain = "my.domain"
p.UserName = "a_myadminaccount"
p.Password = password
p.UseShellExecute = False
' Start the process
Process.Start(p)