Skip to content

Instantly share code, notes, and snippets.

Last active Dec 30, 2021
What would you like to do?
A batch file that automates self elevation (to UAC), enables side loading, uninstalls the previous version and then installs a new version of your Windows 10 UWP/UAP app.
@echo off
REM Version 1.3
REM Put this batch file in the same directory as your published Windows app directory and change the variable value below [YOUR_APP_PACKAGE_ID]
REM Once you are ready to publish this publically, zip up the *.cer, *.msixappbudle or *.appxbundle and this batch file and
REM put it on your server or upload it to your account.
REM Tell your users/customers to unzip and launch the install.bat file and follow the prompts.
REM NOTE: Some users/customers may not have the appropriate rights to enable Developer Mode and Side Loading.
REM Usually people trying to install something on their work machines, which are locked down.
REM This batch file is provided as is and I cannot be held responsible for any damage it may cause. It works for my scenario, apps and game and worked during testing.
REM By downloading and using this file, you accept the above disclaimer.
REM Is this batch file the perfect side-loading installer. NO! Don't @ me :)
REM If you find this batch file useful, let me know and give credit where credit it due.
REM If you have suggestions to improve it for the betterment of the whole community, then @ me as CartBlanche on github, or SoftSavage on Instagram and Twitter.
REM Any improvement will be added to this gist file and your name will be added to the credits below.
REM Updates
REM -------
REM v1.1 Made Desktop Shortcut creation optional with a prompt.
REM v1.2 Made certificate installation more specific to "this" app.
REM v1.3 Add human readable variable, which is friendlier to the customer. See appName variable.
REM Credits
REM -------
REM Bringing together of several Stack Overflow searches
REM Dominique Louis - Original publisher of this file.
REM [Your_Name_Here] - Contributer
net session >nul 2>&1
if %errorlevel% equ 0 (
goto installApp
) else (
goto restartBatchfile
REM Change this variable's value to YOUR UWP/UAP app's package name, found on the Packaging tab of Package.appxmanifest. No spaces!!
set installedApp=[YOUR_APP_PACKAGE_ID]
REM Change this variable's value to YOUR UWP/UAP Display Name. This can contain spaces as long as everything is on one line.
echo Enabling Developer Mode for Sideloading
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
FOR /F "delims=" %%i IN ('DISM /Online /Get-CapabilityInfo /CapabilityName:Tools.DeveloperMode.Core~~~~') DO (
if "%%i"=="State : Not Present" (
DISM /Online /Add-Capability /CapabilityName:Tools.DeveloperMode.Core~~~~
echo Installing Certificates for "%appName%"
for %%i in (%~sdp0\*%installedApp%*.cer) do certutil.exe -addstore TrustedPeople %%i
echo Uninstalling previous versions of "%appName%"
PowerShell -command "Get-AppxPackage | ?{ $_.Name.Contains('%installedApp%') } | Remove-AppxPackage"
echo Launching "%appName%" Installers
for %%j in (%~sdp0\*%installedApp%*.msixbundle) do (
echo "Installing %%j"
Powershell -command "Add-AppxPackage -Path %%j"
for %%j in (%~sdp0\*%installedApp%*.appxbundle) do (
echo "Installing %%j"
Powershell -command "Add-AppxPackage -Path %%j"
set desktopShortcut=
set /p desktopShortcut=Would you like to create a Desktop Shortcut for "%appName%" now (Y/N)?
if '%desktopShortcut%'=='Y' goto createDesktopShortcut
if '%desktopShortcut%'=='y' goto createDesktopShortcut
if '%desktopShortcut%'=='N' goto launchprompt
if '%desktopShortcut%'=='n' goto launchprompt
echo "%desktopShortcut%" is invalid. Please try again
goto desktopShortcutPrompt
echo Creating a Desktop Shortcut for "%appName%"
Powershell -command "$app = Get-StartApps | ?{ $_.AppID.Contains('%installedApp%') }; $appName = $app.Name.Replace(':', '-'); $linkFile = ($appName + '.lnk'); $linkPath = Join-Path ([Environment]::GetFolderPath('Desktop')) $linkFile; $link = (New-Object -ComObject WScript.Shell).CreateShortcut($linkPath); $link.TargetPath = ('shell:appsFolder\' + $app.AppID); $link.Save();"
set choice=
set /p choice=Would you like to Launch "%appName%" now (Y/N)?
if '%choice%'=='Y' goto launchapp
if '%choice%'=='y' goto launchapp
if '%choice%'=='N' goto installcomplete
if '%choice%'=='n' goto installcomplete
echo "%choice%" is invalid. Please try again
goto launchprompt
echo Launching "%appName%"
Powershell -command "$app = Get-StartApps | ?{ $_.AppID.Contains('%installedApp%') }; $appID = $app.AppID; $shellPath = ('shell:appsFolder\' + $app.AppID); (explorer.exe $shellPath);"
echo Installation of "%appName%" Complete.
REM Relaunch itself with elevated privileges
Powershell Start install.bat -verb runas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment