MSIX Command Line Argument

Brass Contributor

Hey guys,

 

I'm trying to convert an App-V package to an MSIX package. I've tried using the packager to make a new package from scratch, and I've tried converting the package.

 

Normally, my program's shortcut launches an executable with a command line argument. MSIX doesn't seem to support this in the manifest XML file, unlike App-V.

 

I've listed a comparison of both below. 

 

App-V manifest item (has arguments, is working):

        <appv:Extension Category="AppV.Shortcut">
            <appv:Shortcut>
                <appv:File>[{Programs}]\Microsoft Dynamics\GP 2015\GP.lnk</appv:File>
                <appv:Target>[{ProgramFilesX86}]\Microsoft Dynamics\GP2015\Dynamics.exe</appv:Target>
                <appv:Icon>[{ProgramFilesX86}]\Microsoft Dynamics\GP2015\Dynamics.exe.0.ico</appv:Icon>
                <appv:Arguments>Dynamics.set</appv:Arguments>
                <appv:WorkingDirectory>[{ProgramFilesX86}]\Microsoft Dynamics\GP2015\</appv:WorkingDirectory>
                <appv:ShowCommand>1</appv:ShowCommand>
                <appv:ApplicationId>[{ProgramFilesX86}]\Microsoft Dynamics\GP2015\Dynamics.exe</appv:ApplicationId>
            </appv:Shortcut>
        </appv:Extension>

 

MSIX manifest item (doesn't have arguments, isn't working):

<Application Id="DYNAMICS" Executable="VFS\ProgramFilesX86\Microsoft Dynamics\GP2015\Dynamics.exe" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements BackgroundColor="transparent" DisplayName="GP" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="GP">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square310x310Logo="Assets\Square310x310Logo.png" Square71x71Logo="Assets\Square71x71Logo.png" />
</uap:VisualElements>
</Application>
  
How can I edit my MSIX package so that the start menu items launch with the appropriate command line arguments?
25 Replies

Hi Taylor,

 

This is a well known limitation.

 

The solution is to have a stub/launcher used as entry point instead of your main app and that launcher can in the end launch your application with the desired command line parameters.

 

When MSIX was announced in March, Kevin Gallo introduced the free Express edition from Advanced Installer. This is a setup authoring tool that can convert old setups to MSIX, or import an existing MSIX package and package it, providing additional functionality, like a GUI based method for you to specify command line arguments and many others (Advanced Installer takes care of the details in the background, i.e. includes a launcher that saves your command line args and passes them to your main application).

 

So all you need to do is to import your current MSIX package into a new project in Advanced Installer, go to Application Details page and set your args in the "Arguments" field. Then build the MSIX package again.

 

msix args.png

 

 Disclaimer: I work on the team building Advanced Installer.

 

 

Support for shortcut parameters is not yet supported in 1809, it should be in an upcoming Insider preview.

 

John.

Thanks for the update, John. Any idea when this will be supported? Is there a GitHub repo I can consult to open an issue?

You can add something to the ideas section of the community and we can update you on the progress.

 

John.

@John Vintzel

Is there any update on allowing parameters to be specified to the MSIX package that get passed on to the installed application? My application needs environment specific data on the command line that can be different for each installation environment without creating a whole new package for each environment.

Thank you, Brett

@BrettBurgeson 

 

It is supported using the package support framework (http://aka.ms/msix-psf).  We are working on a more detailed implementation doc for this on the main docs site (http://aka.ms/msix).  We hope to have that live (with a couple other psf docs) next week.

 

John.

@John Vintzel 

That is awesome! Thank you for the update.

Hi @BrettBurgeson 

 

Can you give us more details about the command line that you need to set? From what I see you said it depends on the target machine. Is it a file/folder path that can be different for each machine?

 

I am asking because in Advanced Installer we try to handle all these MSIX limitations with generic solutions that apply to multiple use cases. For example, now we are working on extending our private PSF fork to support expanding folder IDs or environment variables, like ProgramFilesFolder to "C:\Program Files". This path expansion can occur in a config file that gets installed or in a shortcut command line.

I am curious to better understand the specifics for your scenario.

Thanks,
Bogdan

Hi @Bogdan Mitrache 

Thank you for your response.

We are trying to replace our click once installers with an up to date installer platform.

We have customers that have multiple users that need to be able to install our application from a web server that our customers maintain. Currently the click once link supplies an argument with a path to a config file. The path to the config file is of course unique to the customer but not to each machine.

We need to do the same thing with our new installer. MSIX can do that with the PSF but the package needs to be opened and the config file updated with the argument specific to the customer and repacked. We would like to avoid that step if possible so we can just have our Azure Devops pipeline produce an installer that we don't have to open up to modify the argument.

 

One more thing is that MSIX requires the user of MSIX Core to install on versions earlier than Windows 10 build 1709. At this point I'm having trouble getting MSIX Core to build successfully.

 

Thank you,

Brett

 

Hi @BrettBurgeson

 

For this scenario I am thinking you could do this in a different way.

 

First, when your customers host the MSIX file on their servers, their should make it available for download using an .appinstaller file. It's a simple XML which they can write.

 

Now, at runtime, your app can detect the link used by the appinstaller. You can use a simple PowerShell script to get that link and save it into the registry. Then using the PSF launcher you can read that link from the registry (every time your app launches) and launch your app with a different command line (or whatever the customization was made by your clients), depending on the link it reads.

Is this what you would like? (I can provide a sample script and demo project in Advanced Installer if you want)

@Bogdan Mitrache 

That sounds promising. Yes I would like a sample.

MSIX containers change how programs interact with the registry. This still works in a container?

How can I contact you offline?

Hi @BrettBurgeson 

 

You can reach me at bogdan at advancedinstaller dot com or you can reach my colleagues from the support team at support at advancedinstaller dot com.  Send them a link to this thread so they can catch up.

 

I'll be out of the office next week, but I will get back to you with the sample ASAP.

 

 

For anyone else interested in this scenario, here is a download link for a sample project.

 

Basically, the Advanced Installer launcher runs a script that gets the URL of the MSIX appinstaller (when a user installs it from the website where your customers will host it) and saves it into a registry, before your app launches. 
 
Now your app can read that URL and customize its behavior based on the link it reads from the registry.

@John VintzelI'm trying to find out how to use the package support framework to accept a query string when launched from a web site and pass that query string to the installed application as a command line argument. Is there someplace in the documentation that will help me accomplish this?

 

Thank you,

Brett

@BrettBurgeson Getting the arguments is fairly straightforward using the PSF.  You'll add a copy of the PsfLauncherXXX.exe to the package and configure the config.json for that application to launch your app.  I haven't run this test case in a while, but the launcher should be appending any arguments listed for the app arguments in the json, plus any that were passed into the launcher.  So leave the arguments out of the json file.  Of course, if you don't need the PSF for other purposes, you can skip the Launcher and just target your end application as per below.

 

The trickier part is getting the things you need to run (PsfLauncher or target).  It's bad to hard code the package path, so a powershell script to query for install packages and getting the install folder from there and appending the Psflauncher or target name for the command line and adding your query string there will do it.

@TIMOTHY MANGANThank you for the information. I will try to get that to work.

@TIMOTHY MANGANI'm not having any success getting arguments passed to the installed application.

I added PsfLauncher64.exe and PsfRuntime64.dll to my InstallerPackageProject and I modified the config.json to execute my application being installed and left out the arguments. I also modified Package.appxmanifest to execute PsfLauncher64.exe.

The appx package installs my application and launches it but does not pass any arguments to the installed application when it is launched by the installer. I have run the appx package two ways. First with a shortcut containing command line arguments. The second way is from a web page link that has a query string containing my arguments using the appinstaller. 

 

I'm really only interested in running the install from a web page using the appinstaller. I want to pass arguments as a query string. I am not interested in the install folder location.

 

You probably need more information to understand what I may be doing wrong.

Let me know what else I can tell you.

 

Thank you for your help.

Brett

@John VintzelHi John, I see from the article here:

https://docs.microsoft.com/en-us/windows/msix/psf/psf-launch-apps-with-parameters

we can put arguments into the config.json file inside the package to have the Launcher64.exe pass those arguments to the installed application when it is launched.

What I need to do is pass a query string to the MSIX package from a link on a web page using the appinstaller and have that query string passed as an argument to the installed application when it is launched. Is there a way to do this?

 

Thank you,

Brett Burgeson

@BrettBurgeson 

 

Right now we do not support passing an argument from the installation URI to an installed app.  Its something that we talked about, but not available today.  I recommend adding an Feature Idea to the ideas section of the community.

 

https://aka.ms/msix-ideas

 

John Vintzel (@jvintzel)

PM Lead, MSIX