Vitaliy Nesterenko
Vitaliy Nesterenko

Reputation: 358

UWP AppX Install parameters

I develop client-server UWP app, and I want it to be deployed by sideloading (probably using WinAppDeployCmd or MDM) to the large set of devices by administrator. But to launch, my application needs to know server IP address, which varies for each customer. I need to pass this setting somehow during deployment by administrator to every device.

Is there a way to set remote application settings? Or pass an XML config file along with appx? Or any other way to add some parameters during installation process?

Upvotes: 2

Views: 800

Answers (1)

Howard Kapustein
Howard Kapustein

Reputation: 527

Unlike e.g. MSI, there's no option to pass along "initial data" with a package for installation. One option is to install the package and then add your 'data' e.g.

  1. Add-AppxPackage foo.appx
  2. appdata = ApplicationDataManager.CreateForPackageFamily(foo_pkg_family)
  3. appdata.LocalSettings.CreateContainer("x").values["y"] = z

Step 1 installs the package, most notably it will register the package for the user. That creates the package's appdata storage resources for the user. You can then use ApplicationDataManager (from a Win32/non-UWP process) to access appdata.

You may find AppData.exe handy. A simple exe using ApplicationDataManager to provide a cmdline interface to AppData. Given this or equivalent you could write a batch file

@ECHO Off
powershell -c Add-AppxPackage foo.appx
appdata.exe SET foopkgfamilyname local\configuration --value=x --type=string --data=y

Upvotes: 2

Related Questions