我编写简单程序,从用户启动另一个Client.exe:
Console.Write("Enter your domain: ");
string domain = Console.ReadLine();
Console.Write("Enter you user name: ");
string uname = Console.ReadLine();
Console.Write("Enter your password: ");
SecureString password = new SecureString();
ConsoleKeyInfo key;
do
{
key = Console.ReadKey(true);
// Ignore any key out of range.
if (((int)key.Key) >= 33 && ((int)key.Key <= 90) && key.Key != ConsoleKey.Enter)
{
// Append the character to the password.
password.AppendChar(key.KeyChar);
Console.Write("*");
}
// Exit if Enter key is pressed.
} while (key.Key != ConsoleKey.Enter);
Console.WriteLine();
try
{
Console.WriteLine("\nTrying to launch ProcessClient using your login information...");
Process.Start("ProcessClient.exe", uname, password, domain);
}
catch (Win32Exception ex)
{
Console.WriteLine(ex.Message);
}
它有效!但Client.exe如何知道用户执行此程序的内容?