2011-07-18 139 views

回答

1

使用Process类与ProcessStartInfo并在启动它之前设置UserNamePassword

ProcessStartInfo startInfo = new ProcessStartInfo("Path to exe"); 
startInfo.UserName = "the user to impersonate"; 
startInfo.Password = "the password in a SecureString"; 

Process.Start(startInfo); 
+0

假设我的密码是密码startInfo.Password ='PASSWORD'不起作用我怎样注释它 – Tuscan

+1

@Ulhas - 看看['SecureString'](http://msdn.microsoft.com/en-us/library/ system.security.securestring.aspx)。 – Oded

+0

执行Process.Start(startInfo)时出现错误“存根收到错误的数据”; – Tuscan