【问题标题】:React native windows - UWP application - trying to shutdown the computerReact native windows - UWP 应用程序 - 试图关闭计算机
【发布时间】:2023-02-14 14:12:29
【问题描述】:

我正在尝试从反应本机 Windows - 关闭计算机的 UWP 应用程序运行 cmd 命令。有什么办法吗???

我创建了一个 c# 本机模块,它创建了一个运行 cmd 命令的进程。总是得到“访问被拒绝”

【问题讨论】:

    标签: uwp shutdown access-denied react-native-windows


    【解决方案1】:

    不能直接从 UWP 应用运行 cmd 命令。 UWP 应用在沙盒中运行。您可以做的是创建一个运行命令的 .exe 文件。然后将 .exe 文件放入 UWP 包中,并通过调用 FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync() 从 UWP 应用程序启动 .exe 文件。 以下是步骤:

    1. 创建一个可以运行您的命令的 .exe 文件。
    2. 将 .exe 文件添加到您在 Visual Studio 中的项目,如资产文件夹。
    3. 修改UWP应用的manifest文件添加运行完全信任能力。
    4. 调用FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync API 启动 .exe 文件。

      你可以在这里参考 Arya 的回答:Run an exe/batch file from UWP app。 其他一些文件相关:FullTrustProcessLauncher Class

    【讨论】:

      猜你喜欢
      • 2015-09-09
      • 1970-01-01
      • 2020-07-20
      • 2013-09-10
      • 1970-01-01
      • 2013-04-10
      • 1970-01-01
      • 2016-04-20
      相关资源
      最近更新 更多