異なるユーザーでプロセスを実行しようとしています。私は通常の "notepad.exe"を実行すると正常に動作します。しかし、ファイルをフルパス(C:\\ Program Files \\ Microsoft Office \\ Office15 \\ Excel.exe)または(C:\\ Program Files(x86)\\ Adobe \\ Acrobat Reader DC \\ Reader \\ AcroRd32.exe)は動作しません。代わりに写真に添付されたようなエラーを出します。C#プロセスの開始偽装エラー
提案がありますか?
static void Main(string[] args)
{
SecureString securePwd = new SecureString();
string password = "[email protected]";
SecureString sec_pass = new SecureString();
Array.ForEach(password.ToArray(), sec_pass.AppendChar);
sec_pass.MakeReadOnly();
Process p = new Process();
ProcessStartInfo ps = new ProcessStartInfo();
p.StartInfo.FileName = "notepad.exe";
p.StartInfo.Arguments = "C:\\Program Files (x86)\\Adobe\\Acrobat Reader DC\\Reader\\welcome.pdf";
p.StartInfo.WorkingDirectory = "C:\\Program Files (x86)\\Adobe\\Acrobat Reader DC\\Reader\\";
p.StartInfo.ErrorDialog = true;
p.StartInfo.EnvironmentVariables.Add("TempPath", "C:\\Temp");
p.StartInfo.Domain = "testdom";
p.StartInfo.UserName = "testuser";
p.StartInfo.Password = sec_pass;
p.StartInfo.RedirectStandardError = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.Start();
StreamReader myStreamReader = p.StandardOutput;
// Read the standard error of net.exe and write it on to console.
Console.WriteLine(myStreamReader.ReadLine());
p.Close();
}
助手席.... .... –