Todd B
Todd B

Reputation: 9

C# Passing arguments to Sysinternals Autologon.exe

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

Upvotes: 1

Views: 1428

Answers (1)

The Scrum Meister
The Scrum Meister

Reputation: 30111

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);

Upvotes: 5

Related Questions