我试图运行,并从我的WinForm应用程序调整OSK但我收到此错误后:请求的操作需要提升,即使在运行Visual Studio作为管理员
The requested operation requires elevation.
我在运行Visual Studio为管理员。
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.FileName = "c:\\windows\\system32\\osk.exe";
process.StartInfo.Arguments = "";
process.StartInfo.WorkingDirectory = "c:\\";
process.Start(); // **ERROR HERE**
process.WaitForInputIdle();
SetWindowPos(process.MainWindowHandle,
this.Handle, // Parent Window
this.Left, // Keypad Position X
this.Top + 20, // Keypad Position Y
panelButtons.Width, // Keypad Width
panelButtons.Height, // Keypad Height
SWP_SHOWWINDOW | SWP_NOZORDER); // Show Window and Place on Top
SetForegroundWindow(process.MainWindowHandle);
然而,
System.Diagnostics.Process.Start("osk.exe");
工作得很好,但它不会让我调整键盘
您是否试过在“释放”模式下运行?即运行你的程序exe文件?为了以管理员身份运行你的exe,你可以使用'startInfo.Verb =“runas”;' – Sunil