在一个应用程序,我需要与另一用户的凭证来执行其它程序。目前我使用的 System.Diagnostics.Process.Start 以执行该程序

public static Process Start(
   string fileName,
   string arguments,
   string userName,
   SecureString password,
   string domain
)

然而,该函数不会从网加载漫游配置 - 其中需要

我可以使用“运行方式/配置文件...”加载配置文件并执行命令,但会要求输入密码。必须有一个更优雅的方式......

但是,在哪里呢?

其他提示

我的解决方案(基于leppie的提示):

        Process p = new Process();

        p.StartInfo.FileName = textFilename.Text;
        p.StartInfo.Arguments = textArgument.Text;
        p.StartInfo.UserName = textUsername.Text;
        p.StartInfo.Domain = textDomain.Text;
        p.StartInfo.Password = securePassword.SecureText;

        p.StartInfo.LoadUserProfile = true;
        p.StartInfo.UseShellExecute = false;

        try {
            p.Start();
        } catch (Win32Exception ex) {
            MessageBox.Show("Error:\r\n" + ex.Message);
        }
scroll top