I am new to C# programming, and I am attempting to obfuscate some credentials by using them inside an exe instead of running them directly from the command line. This is regarding Sysinternal’s Autologon.exe.
Command line:
C:\Autologon.exe Admin . Pa$$word
C#:
System.Diagnostics.Process.Start(@”C:\Autologon.exe”, @”Admin . Pa$$word”);
The above command line version executes without ever raising an issue by UAC in Windows 7, but the C# version prompts me to Run or Cancel whenever I execute it. This is a very small part of a very large and complex automated utility I have written, so prompts are bad. Once again, I don’t receive any prompts when I execute the command line version, but I do receive a prompt when executing it via my C# exe. Help is greatly appreciated.
Thanks in advance!
Change it to the following:
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.FileName = @”C:\Autologon.exe”;
startInfo.Arguments = “Admin . Pa$$word”;
startInfo.UseShellExecute = false;
System.Diagnostics.Process.Start(startInfo);
The key is UseShellExecute = false