Log inRegister

Convert win32 programs into Windows UWP apps

UWP = Universal Windows Platform

In the "Go crazy" series, I tried to convert Windows desktop application into a Windows 10 app… And guess what, I succeeded!

Sources

Necessary programs

  1. Convert .exe into .msi: !Exe2Msi: https://mega.nz/#!vdNCCK4Q!x0ohz2DDusOP73jaHX7woIRSsKDZf9blnPU7N6BzSuY
  2. Desktop App Converter 2.1 from Windows Store for local app converting
  3. Windows 10 Software Development Kit to create a locally signed certificate: https://developer.microsoft.com/nl-nl/windows/downloads/windows-10-sdk

Process

Convert .exe into .msi

If there is no setup .msi file available, you will have to convert the setup .exe file into an .msi file using the downloaded Exe2Msi program.

The program itself should install automatically by double-clicking the Exe2Msi.appx file, but it doesn't.

So open the .appx file in 7-Zip or another compression tool and simply uncompress the exe2msi.exe file that's inside!

Convert .msi into .appx

Once you have a setup .msi file, you can convert this into an UWP file (Universal Windows Platform).
  • Run the Desktop App Converter as Administrator
  • enter the following command:
    DesktopAppConverter.exe -Installer C:\<path>\<to>\<your>\setup.msi -Destination C:\<destination>\<folder> -PackageName "YourApp" -Publisher "CN=<you>" -Version 1.0.0.0 -MakeAppx
    • Microsoft Windows 10 SDK must be installed
    • Windows Feature 'Containers' must be enabled
    • destination path must exist
    • the -Publisher options must begin with CN=
      afterwards, you will have to create a certificate to sign the app with the same publisher name

Make a certificate - or use an existing one...

  • Run Command Prompt as Administrator
  • navigate to the Windows SDK directory and then further down to the location which contains the MakeCert executable, e.g.:
    cd C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x86>
  • create a private key by entering the following command:
    MakeCert -n CN=<you> -sv YourApp.pvk -r YourApp.cer
    • make sure that the value for CN= is the same as the one you used when converting the .msi into .appx
  • then, in the same directory, issue the following command:
    Pvk2Pfx /pvk YourApp.pvk /pi <password> /spc YourApp.cer /pfx YourApp.pfx
    • where the .pvk and .cer files are the ones created just now
    • and where <password> is the password you used when creating the private key

Sign the .appx file

  • copy the .pfx file you just created, from the SDK folder to the folder where your .appx file can be found
  • navigate back to the Windows SDK directory, and then further down to the location which contains the SignTool executable, e.g.:
    C:\Program Files (x86)\Windows Kits\10\App Certification Kit>
  • sign your app package using SignTool:
    .\SignTool sign /fd SHA256 /a /f C:\<destination>\<folder>\YourApp.pfx /p <password> C:\<destination>\<folder>\YourApp.appx
    • where SHA256 is the default hash algorithm
    • YourApp.pfx is the .pfx file you created
    • <password> is the password you used when creating the private key
    • YourApp.appx is the .appx you created

Install the Windows UWP app

In PowerShell (as Administrator), issue the following command:

add-appxpackage C:\<destination>\<folder>\YourApp.appx

Installation on other machines

ASUS VivoTab Smart: fails

Probably because it's a Windows 10 v1607

Dell XPS 1647:succeeds

I have to use the bridge10demo.com certificate from windowsblogitalia.com, but apart from that, it works:
  1. Eseguite un doppio click sul file auto-generated.pfx.
  2. Si avvierà Importazione guidata certificati.
  3. Selezionate Computer locale e cliccate Avanti.
  4. Alla richiesta di Controllo dell’account utente cliccate .
  5. Vi verrà chiesto di specificare il file da importare. Cliccate Sfoglia… e selezionate il file auto-generated.cer presente nella cartella Exe2Msi.
  6. Cliccate sul pulsante Avanti.
  7. Assicuratevi che la scelta sia impostata su Seleziona automaticamente l’archivio certificati secondo il tipo di certificato e cliccate Avanti.
  8. Cliccate sul pulsante Fine per terminare l’operazione.
Installation is even possible by double-clicking the .appx file (so not issuing the add-appxpackage cmdlet).

Issues

Now I give the impression that it's relatively simple. However, I met a lot of obstacles during this process. I'll mention here the ones I remember:
  • for the Desktop App Converter to work correctly, the right Windows Desktop App Converter Base Image is required: https://www.microsoft.com/en-us/software-download/dac
    Download the .wim file for your Windows build, then setup the converter environment using that base image:
    C:\> [[DesktopAppConverter][DesktopAppConverter]].exe -Setup -BaseImage C:\BaseImage\BaseImage-<version>.wim
  • for the Desktop App Converter to work correctly, the container feature is required:
    Control Panel > All Control Panel Items > Programs and Features: Turn Windows features on or off: Containers
    I don't know if Docker for Windows is necessary if you do the above, but if you require it, you can find it here: https://docs.docker.com/docker-for-windows/install/: click the large Get Docker for Windows [Stable] button and follow the on-screen instructions - a restart is required
  • trying to use a self created certificate failed (error 0x800B0109: The root certificate of the signature in the app package or bundle must be trusted.), but I used an existing .cer / .pfx from which I knew the Issuer (CN=): double-click an existing .cer file, and you see to who it has been issued
    the "Publisher" you use in the DesktopAppConverter command can be seen in the .appx file, which can be opend with a .zip tool: in the AppxManifest.xml, you see the PublisherDisplayName
    You could try to check the mmc -console > Certificates > Trusted Root Certification Authorities > Certificates and then try to create your own certificate…
  • Developer mode must be enabled?
    Settings > Update & Security: For developers
    - Use developer features: Developer mode ingeschakeld
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback
This page was cached on 19 Apr 2024 - 23:57.