2011-07-18 2 views

Répondre

1

Utilisez la classe Process avec ProcessStartInfo et définissez UserName et Password avant de le démarrer.

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

Process.Start(startInfo); 
+0

supposons que mon mot de passe est PASSWORD startInfo.Password = 'MOT DE PASSE' ne fonctionne pas comment je l'ai classé – Tuscan

+1

@Ulhas - Jetez un oeil à ['SecureString'] (http://msdn.microsoft.com/fr-fr/library/ system.security.securestring.aspx). – Oded

+0

Je reçois une erreur "Le stub a reçu des données incorrectes" lors de l'exécution de Process.Start (startInfo); – Tuscan

Questions connexes