在开始菜单快捷方式中添加可执行参

时间:2018-02-14 16:33:32

标签: uwp desktop-bridge project-centennial

我用gcc-g ++编译了一个可执行文件,比如launcher.exe。我希望将其作为launcher.exe --param运行。所以我创建了一个包含所有资源,二进制文件等的UWP文件夹。我可以使用makeappx.exe成功地将文件夹打包到APPX包中,然后用signtool.exe唱出来。它成功安装和启动。但我无法在该appxmanifest.xml文件中添加--param。清单文件如下:

 <Applications>
    <Application Executable="launcher.exe" EntryPoint="Windows.FullTrustApplication" Id="test">
      <uap:VisualElements DisplayName="launcher" Square44x44Logo="Assets\test44x44.png" Description="" BackgroundColor="transparent" Square150x150Logo="Assets\test150x150.png">
        <uap:InitialRotationPreference>
          <uap:Rotation Preference="portrait"/>
          <uap:Rotation Preference="landscape"/>
        </uap:InitialRotationPreference>
      </uap:VisualElements>
      <Extensions>
        <rescap3:Extension Category="windows.desktopAppMigration">
          <rescap3:DesktopAppMigration>
            <rescap3:DesktopApp ShortcutPath="%APPDATA%\Microsoft\Windows\Start Menu\Programs\test\launcher.lnk"/>
          </rescap3:DesktopAppMigration>
        </rescap3:Extension>
      </Extensions>
    </Application>
  </Applications>

那么,如何在开始菜单或桌面快捷方式的快捷方式中添加该命令参数?

2 个答案:

答案 0 :(得分:1)

由于参数将在清单中进行硬编码,因此只要将launcher.exe的代码作为打包的应用程序启动,您就可以将其更改为“ - param”。

如果您无法更改该二进制文件的代码,您可以在包中添加第二个EXE,例如helper.exe,将其作为入口点,然后从那里启动带有所需参数的launcher.exe。

以下是helper.exe的代码段:

static void Main(string[] args)
{
    string result = System.Reflection.Assembly.GetExecutingAssembly().Location;
    int index = result.LastIndexOf("\\");
    string processPath = $"{result.Substring(0, index)}\\..\\Launcher\\Launcher.exe";
    Process.Start(processPath, "--param");
}

上传完整示例项目:https://1drv.ms/u/s!AovTwKUMywTNnY4ofULXFV778Dtdxw

您可能还会发现这个有点相关的博文有用: https://blogs.msdn.microsoft.com/appconsult/2017/06/23/accessing-to-the-files-in-the-installation-folder-in-a-desktop-bridge-application/

答案 1 :(得分:0)

desktop bridge support from Advanced Installer专业版可以自动管理AppX包的快捷方式参数。 (应用程序自动包含一个存根EXE,它接收您的参数并将它们传递给您的主应用程序EXE )。

它还可以导入您的AppX包,因此您无需从头开始创建项目。导入完成后,您最终会在Advanced Installer中创建一个项目,可以创建AppX和MSI(用于服务Win7用户,例如)。

它还有一个VS扩展,使构建和调试变得更加容易,您可以在上面链接的页面视频中看到它。

免责声明:我致力于构建高级安装程序的团队。

相关问题