我试图在运行 Vista 并启用了 UAC 的 2 台不同计算机中以具有管理员权限的不同用户身份运行进程,但在其中一台计算机中,我得到一个 Win32Exception,显示“目录名称无效”
谁能告诉我我的代码有什么问题?
var myFile = "D:\\SomeFolder\\MyExecutable.exe";
var workingFolder = "D:\\SomeFolder";
var pInfo = new System.Diagnostics.ProcessStartInfo();
pInfo.FileName = myFile;
pInfo.WorkingDirectory = workingFolder;
pInfo.Arguments = myArgs;
pInfo.LoadUserProfile = true;
pInfo.UseShellExecute = false;
pInfo.UserName = {UserAccount};
pInfo.Password = {SecureStringPassword};
pInfo.Domain = ".";
System.Diagnostics.Process.Start(pInfo);
更新
执行上述代码的应用程序具有 requireAdministrator 执行级别。我什至将工作文件夹设置为“Path.GetDirectoryName(myFile)”和“New System.IO.FileInfo(myFile).DirectoryName”