【发布时间】:2022-01-20 17:07:46
【问题描述】:
我有一个 UWP C++/WinRT 应用和一个 C++/WinRT 控制台应用程序。
UWP 应用程序使用FullTrustProcessLauncher 启动控制台应用程序,并且控制台应用程序应该在系统上启动任意.exe 文件,例如cmd.exe.
控制台应用程序的完整代码在这里:
#include "pch.h"
#include <iostream>
int main()
{
winrt::init_apartment();
try
{
winrt::Windows::System::ProcessLauncher::RunToCompletionAsync(L"cmd.exe", L"").get();
}
catch (const winrt::hresult_error& err)
{
std::cout << winrt::to_string(err.message()) << std::endl;
}
std::cin.get();
}
而pch.h 包括winrt/Windows.Foundation 以及winrt/Windows.System.h。
UWP 应用可以成功启动控制台应用,但控制台应用似乎无法启动.exe 文件,带有E_ACCESSDENIED。
我认为控制台应用程序应该能够启动任意 .exe 文件是一个完全信任的进程,我错了吗?
如果没有,我该如何修复Access is denied 错误?
【问题讨论】: