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?
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/