Reputation: 2673
As I want to run the cmd
with administrative privilege in the process, but the pop up open up even set the WindowStyle
to hidden.
ProcessInfo = new ProcessStartInfo("cmd.exe", "/c " + @"cscript.exe DTCSECURITY.vbs");
ProcessInfo.CreateNoWindow = true;.
ProcessInfo.WindowStyle = ProcessWindowStyle.Hidden;
// Here with i pass the privillage
ProcessInfo.UserName = @"administrator";
ProcessInfo.Password = StringToSecureString("password12$");
process = Process.Start(ProcessInfo);
process.WaitForExit();
But if I comment the privillage code no pop up blinks.
Upvotes: 2
Views: 583
Reputation: 9526
Try to set ProcessStartInfo.UseShellExecute
to false
(it is true
by default).
ProcessStartInfo.CreateNoWindow Property says:
If the UseShellExecute property is true or the UserName and Password properties are not null, the CreateNoWindow property value is ignored and a new window is created.
Upvotes: 1
Reputation: 98750
I think you should set WorkingDirectory
property. From MSDN;
The WorkingDirectory property must be set if UserName and Password are provided. If the property is not set, the default working directory is %SYSTEMROOT%\system32.
If the UserName property is not null or an empty string, the UseShellExecute property must be false, or an InvalidOperationException will be thrown when the Process.Start(ProcessStartInfo) method is called.
Upvotes: 1