C# Passing arguments to Sysinternals Autologon.exe

1.3k Views Asked by At

I am trying to pass arguments to the SysInteranls Autologon.exe file, and am unable to do so. This is the C# Code that I am using:

string usr = usrTextBox.Text.ToString();
                string auto = autologon;
                string domain = STORES;
                string pass = password;
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.CreateNoWindow = false;
                startInfo.UseShellExecute = false;
                startInfo.FileName = "Autologon.exe";
                startInfo.WindowStyle = ProcessWindowStyle.Hidden;
                startInfo.Arguments = usr + domain + pass;
                Process.Start(startInfo);

It works if I set the startInfo.Arguments = "USER DOMAIN PASSWORD"; Any help would be greatly appreciated.

Todd

1

There are 1 best solutions below

1
The Scrum Meister On

As per your last statement, You need a space in between them.

startInfo.Arguments = usr + " " + domain + " " + pass;

To keep the code cleaner, use the string.Format method.

startInfo.Arguments = string.Format("{0} {1} {2}", usr, domain, pass);