c# 指定用户启动 exe

来源:互联网 发布:阿里云子域名 编辑:程序博客网 时间:2024/06/05 22:33
Process process = new Process();process.StartInfo.UserName = 指定用户名;string strPWD = 密码;SecureString password = new SecureString();foreach (char c in strPWD.ToCharArray()){    password.AppendChar(c);}process.StartInfo.Password = password;process.StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;process.StartInfo.FileName = "xxx.exe";process.StartInfo.Arguments = "/run /wu";process.StartInfo.UseShellExecute = false;process.Start();