如何自定义Windows Installer卸载程序文件名?WIX友好命名实现方法
Hey there! Let’s tackle your two questions one by one—they’re super common for anyone building MSIs with WiX, so great call asking about this.
1. Can we define the filename of the Windows Installer uninstall program?
Short answer: Yes, but with a small clarification.
Windows Installer relies on cached copies of your MSI package to handle uninstall, repair, and modify operations. By default, this cached file (stored in C:\WINDOWS\Installer) gets a GUID-based filename that looks like a random string—exactly the annoying thing you’re talking about.
You can’t directly rename the "uninstall program" (since uninstall is triggered via msiexec.exe calling the cached MSI), but you can control the filename of that cached MSI package. That’s the key here—making the cached file friendly means any tools or users looking at the installer cache will see a recognizable name instead of a random GUID.
2. How to create a user-friendly uninstall filename with WiX?
The fix is straightforward in WiX—you just need to set the Name attribute on your <Package> element. Here’s a concrete example:
<Product Id="*" Name="My Cool App" Language="1033" Version="1.0.0.0" Manufacturer="My Tech Corp" UpgradeCode="YOUR-UPGRADE-GUID-HERE"> <!-- Set the friendly filename for the cached MSI here --> <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Name="MyCoolApp.msi" /> <!-- Rest of your WiX configuration --> <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" /> <!-- Add your Features, Components, and other elements here --> </Product>
What this does:
- When your MSI runs, Windows Installer will cache the package to
C:\WINDOWS\Installerusing the name you specified (MyCoolApp.msi) instead of the default GUID-based filename. - This doesn’t break any uninstall/repair functionality—Windows Installer still tracks the package via its product code, so everything works as expected.
Bonus: Make the uninstall shortcut friendly too
While we’re at it, you probably want the actual uninstall shortcut in the Start Menu to be user-friendly too. Here’s how to set that up in WiX:
<DirectoryRef Id="ProgramMenuFolder"> <Component Id="UninstallShortcutComponent" Guid="YOUR-COMPONENT-GUID-HERE"> <Shortcut Id="UninstallMyCoolApp" Name="Uninstall My Cool App" Target="[SystemFolder]msiexec.exe" Arguments="/x [ProductCode]" Description="Remove My Cool App from your system" Icon="MyAppIcon.ico" IconIndex="0" /> <RegistryValue Root="HKCU" Key="Software\MyTechCorp\MyCoolApp" Name="UninstallShortcut" Type="string" Value="1" KeyPath="yes" /> </Component> </DirectoryRef>
Quick notes to keep in mind:
- Avoid special characters in your cached MSI filename—stick to letters, numbers, and underscores/hyphens to stay compliant with Windows file naming rules.
- If you’re using multiple media cabinets (for large installs), you’ll need to ensure each media’s filename is also friendly, but the main package name is the one that matters for uninstall.
- The
Cache="yes"attribute on<Package>is enabled by default, so you don’t need to add it explicitly unless you’ve changed it before.
That’s all! With these tweaks, your users (and you) won’t have to deal with those confusing random GUID filenames anymore.
内容的提问来源于stack exchange,提问作者Włodzimierz O. Kubera

