首先,我安装了winget-cli并在设备上打开命令提示符,我可以获得winget版本。
请参阅https://user-images.githubusercontent.com/22248019/127574830-3f01c414-09c2-4a29-bbe6-60a62ea49b18.png上的image1
该设备还安装了我们的应用程序,该功能可以通过编程方式从命令提示符获取输出。就像你在我们的应用中输入"ipconfig“一样,你可以获得设备的ip地址信息。但当我输入"winget -v“时,只返回"'winget‘不被识别为内部或外部命令”。下图显示了我们应用程序中的输出。您可以看到,除了winget命令之外,命令输入将获得正确的输出
请参阅https://user-images.githubusercontent.com/22248019/127573134-9b78ad99-9c0b-4671-b146-62c60ef74866.png上的图2
这段代码如下所示:
char sBuffer[256];
while (fgets(sBuffer, sizeof(sBuffer) - 1, pipe) != NULL) {
cout << "winget version result:" + sBuffer;
}
Does anyone know why this not working
[1]: https://user-images.githubusercontent.com/22248019/127574830-3f01c414-09c2-4a29-bbe6-60a62ea49b18.png
[2]: https://user-images.githubusercontent.com/22248019/127573134-9b78ad99-9c0b-4671-b146-62c60ef74866.png发布于 2021-10-07 14:34:36
该错误似乎与应用程序在其中运行的上下文有关。Windows包管理器通过Microsoft应用商店中的App Installer提供。MSIX包是为用户注册的,而不是系统。如果应用程序代码在已注册的用户上下文中运行,并且错误仍然存在,请查看troubleshooting guide。
https://stackoverflow.com/questions/68583763
复制相似问题