Windows store apps 如何在windows应用商店应用程序中运行命令?

Windows store apps 如何在windows应用商店应用程序中运行命令?,windows-store-apps,windows-8.1,Windows Store Apps,Windows 8.1,我需要从windows应用商店应用程序运行命令 命令如下:java-jarabc.jar 我该怎么做 编辑: 我试过了,但没有成功。上面说找不到文件 string exeFile = @"C:\DATA\start.bat"; var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(exeFile); if (file !=

我需要从windows应用商店应用程序运行命令

命令如下:java-jarabc.jar

我该怎么做

编辑:

我试过了,但没有成功。上面说找不到文件

       string exeFile = @"C:\DATA\start.bat";

        var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(exeFile);

        if (file != null)
        {
            // Set the option to show the picker
            var options = new Windows.System.LauncherOptions();
            options.DisplayApplicationPicker = true;

            // Launch the retrieved file
            bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
            if (success)
            {
                // File launched
            }
            else
            {
                // File launch failed
            }
        }

应用程序容器阻止商店应用程序的此行为

首先,您试图通过package InstalledLocation文件夹获取一个StorageFile,但这不起作用。InstalledLocation是一个StorageFolder,其GetFileAsync只查找该立即文件夹中的文件。这就是它返回未找到文件的原因

       string exeFile = @"C:\DATA\start.bat";

        var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(exeFile);

        if (file != null)
        {
            // Set the option to show the picker
            var options = new Windows.System.LauncherOptions();
            options.DisplayApplicationPicker = true;

            // Launch the retrieved file
            bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
            if (success)
            {
                // File launched
            }
            else
            {
                // File launch failed
            }
        }
采用任意路径的API是Windows.Storage.StorageFolder.GetFileFromPathAsync。但是,您访问文件的能力受到应用程序容器的限制。默认情况下,您可以访问软件包文件夹或应用程序数据位置中的文件,或者如果您在清单中声明了访问权限,则可以访问各种媒体库中的文件,但否则您必须通过文件选择器,以便用户知道您在做什么,并可以授予许可。简单地说,这是访问位于c:\data这样位置的文件的唯一方法。您可以使用的场景1和“拾取并启动”按钮来处理此问题

如果您可以获得访问权限,那么在中,如果文件不是被阻止的文件类型,您将能够启动该文件。与另一个应用程序关联的数据文件(如.docx)工作正常,但由于明显的安全原因,可执行文件被完全阻止。您可以使用我上面链接的示例进行尝试——pick.bat、.cmd、.exe、.msi等,您将看到LaunchFileAsync失败


另请注意,另一个启动程序函数launchurisync也会出于同样的原因阻止文件://。

Windows应用商店应用程序在沙箱中运行。我认为您将无法运行java命令。我是否可以不执行包含此命令的批处理文件?