Reputation: 4251
I've a executable compiled with gcc-g++, say launcher.exe
. And I want to run it as launcher.exe --param
. So I make a UWP folder with all assets, binary etc. I can successfully pack the folders in a APPX package with makeappx.exe
and sing it with signtool.exe
. It installs and launches successfully. But I can't add the --param
in that appxmanifest.xml file. The manifest file is as below:
<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>
So, How can I add that command parameter in shortcut in start menu or in desktop shortcut?
Upvotes: 2
Views: 644
Reputation: 10993
The desktop bridge support from Advanced Installer, professional edition, can manage the shortcut parameters automatically for your AppX packages. (the application automatically includes a stub EXE that takes your parameters and passes them to your main app EXE).
It can also import your AppX package, so you don't have to create the project from scratch. Once the import is done you end up with a project in Advanced Installer from which can create both an AppX and an MSI (for serving Win7 users for example).
It also has a VS extension to make build and debugging much easier, you can see it in action in the video from the page linked above.
Disclaimer: I work on the team building Advanced Installer.
Upvotes: 0
Reputation: 13850
Since the parameter would be hardcoded in the manifest, you might was well change the code of launcher.exe to assume the "--param" whenever it's launched as a packaged app.
If you can't change the code for that binary, you could just add a second EXE, say helper.exe, in your package, make that the entry point and then launch launcher.exe with the desired parameters from there.
Here is a code snippet for 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");
}
Full sample project uploaded here: https://1drv.ms/u/s!AovTwKUMywTNnY4ofULXFV778Dtdxw
You might also find this somewhat related blogpost helpful: https://blogs.msdn.microsoft.com/appconsult/2017/06/23/accessing-to-the-files-in-the-installation-folder-in-a-desktop-bridge-application/
Upvotes: 2