Hello can someone help me how i can make from my .net winform to execute the powershell script as admin
here is what i try, but also when open the window of powershell to display results what the code does.
Code:Dim FileNamePath As String = My.Application.Info.DirectoryPath & "\Script.ps1" Dim processStartInfo As New ProcessStartInfo("powershell.exe") With { .Arguments = "-NoProfile -noexit -ExecutionPolicy Bypass -File " & FileNamePath, .UseShellExecute = False, .CreateNoWindow = False, .RedirectStandardError = True, .RedirectStandardOutput = True, .Verb = "runas", .WindowStyle = ProcessWindowStyle.Normal } Using p As New Process() p.StartInfo = processStartInfo p.Start() p.WaitForExit() End Using




Reply With Quote
