2011-07-18 86 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