문제

응용 프로그램에서는 다른 사용자의 자격 증명으로 다른 프로그램을 실행해야합니다. 현재 사용합니다 System.diagnostics.process.start 프로그램을 실행하려면 :

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

그러나이 함수는 그물에서 로밍 프로파일을로드하지 않습니다.

"runas /profile ..."을 사용하여 프로필을로드하고 명령을 실행할 수 있지만 비밀번호를 요구할 수 있습니다. 더 우아한 방법이 있어야합니다 ...

하지만 어디?

도움이 되었습니까?

다른 팁

내 솔루션 (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);
        }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top