技术需求:开发可部署三个独立程序的KAM Package安装器
Got it, let's break down how to create an installer that checks all your boxes—installing three independent programs into a root KAM Package folder, each with their own dedicated subfolder, and separate Start Menu entries. I’ll cover two reliable, free tools that work perfectly for Windows installers: Inno Setup (user-friendly, ideal for beginners) and WiX Toolset (for MSI-based deployments, better for enterprise use).
Option 1: Inno Setup (Quick & Intuitive)
Inno Setup is a popular open-source tool that lets you build installers with a simple, readable script. Here’s how to set it up:
Step 1: Prepare Your Local File Structure
First, organize your files so the installer can copy them correctly. Create a source folder like this:
KAM_Package_Source/ ├── ProgramA/ │ ├── ProgramA.exe │ └── (all supporting files for Program A) ├── ProgramB/ │ ├── ProgramB.exe │ └── (all supporting files for Program B) └── ProgramC/ ├── ProgramC.exe └── (all supporting files for Program C)
Step 2: Write the Inno Setup Script
Open Inno Setup and create a new script. Replace the default code with this sample (tweak paths and names to match your programs):
[Setup] AppName=KAM Package AppVersion=1.0 DefaultDirName={pf}\KAM Package DefaultGroupName=KAM Package OutputDir=Installer_Output OutputBaseFilename=KAM_Package_Installer [Dirs] ; Create the root folder and each program's subfolder Name: "{app}\ProgramA" Name: "{app}\ProgramB" Name: "{app}\ProgramC" [Files] ; Copy all files for Program A (including subfolders) Source: "KAM_Package_Source\ProgramA\*"; DestDir: "{app}\ProgramA"; Flags: recursesubdirs createallsubdirs ; Copy all files for Program B Source: "KAM_Package_Source\ProgramB\*"; DestDir: "{app}\ProgramB"; Flags: recursesubdirs createallsubdirs ; Copy all files for Program C Source: "KAM_Package_Source\ProgramC\*"; DestDir: "{app}\ProgramC"; Flags: recursesubdirs createallsubdirs [Icons] ; Create separate Start Menu entries for each program Name: "{group}\Program A"; Filename: "{app}\ProgramA\ProgramA.exe" Name: "{group}\Program B"; Filename: "{app}\ProgramB\ProgramB.exe" Name: "{group}\Program C"; Filename: "{app}\ProgramC\ProgramC.exe" ; Optional: Add an uninstall shortcut Name: "{group}\Uninstall KAM Package"; Filename: "{uninstallexe}"
Step 3: Compile & Test
Click the "Compile" button in Inno Setup to generate your installer. Run it to verify:
- The
KAM Packagefolder is created in Program Files (or your chosen directory) - Each program’s files are neatly stored in their own subfolder
- Three distinct entries appear in the Start Menu under the "KAM Package" group
Option 2: WiX Toolset (MSI-Based Deployment)
If you need an MSI installer (common for enterprise environments or strict deployment policies), WiX is the standard open-source tool. Here’s a simplified setup:
Step 1: Create a WXS Script
Create a new .wxs file with this structure (adjust names and paths as needed):
<?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Product Id="*" Name="KAM Package" Language="1033" Version="1.0.0.0" Manufacturer="Your Brand" UpgradeCode="PUT-UNIQUE-GUID-HERE"> <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFilesFolder"> <Directory Id="KAMROOT" Name="KAM Package"> <Directory Id="PROGA_DIR" Name="ProgramA" /> <Directory Id="PROGB_DIR" Name="ProgramB" /> <Directory Id="PROGC_DIR" Name="ProgramC" /> </Directory> </Directory> <Directory Id="ProgramMenuFolder"> <Directory Id="KAM_STARTMENU" Name="KAM Package" /> </Directory> </Directory> <!-- Components for each program --> <ComponentGroup Id="ProgramA_Files" Directory="PROGA_DIR"> <Component Id="ProgramA_Exe"> <File Id="ProgramA_Exe_File" Source="KAM_Package_Source\ProgramA\ProgramA.exe" KeyPath="yes" /> <!-- Add other files for Program A here with <File> elements --> </Component> </ComponentGroup> <ComponentGroup Id="ProgramB_Files" Directory="PROGB_DIR"> <Component Id="ProgramB_Exe"> <File Id="ProgramB_Exe_File" Source="KAM_Package_Source\ProgramB\ProgramB.exe" KeyPath="yes" /> <!-- Add other files for Program B here --> </Component> </ComponentGroup> <ComponentGroup Id="ProgramC_Files" Directory="PROGC_DIR"> <Component Id="ProgramC_Exe"> <File Id="ProgramC_Exe_File" Source="KAM_Package_Source\ProgramC\ProgramC.exe" KeyPath="yes" /> <!-- Add other files for Program C here --> </Component> </ComponentGroup> <!-- Start Menu shortcuts --> <ComponentGroup Id="StartMenuShortcuts" Directory="KAM_STARTMENU"> <Component Id="Shortcut_ProgramA"> <Shortcut Id="Shortcut_ProgramA" Name="Program A" Target="[PROGA_DIR]ProgramA.exe" WorkingDirectory="PROGA_DIR" /> <RegistryValue Root="HKCU" Key="Software\YourBrand\KAMPackage" Name="ProgramA_Shortcut" Type="string" Value="1" KeyPath="yes" /> </Component> <Component Id="Shortcut_ProgramB"> <Shortcut Id="Shortcut_ProgramB" Name="Program B" Target="[PROGB_DIR]ProgramB.exe" WorkingDirectory="PROGB_DIR" /> <RegistryValue Root="HKCU" Key="Software\YourBrand\KAMPackage" Name="ProgramB_Shortcut" Type="string" Value="1" KeyPath="yes" /> </Component> <Component Id="Shortcut_ProgramC"> <Shortcut Id="Shortcut_ProgramC" Name="Program C" Target="[PROGC_DIR]ProgramC.exe" WorkingDirectory="PROGC_DIR" /> <RegistryValue Root="HKCU" Key="Software\YourBrand\KAMPackage" Name="ProgramC_Shortcut" Type="string" Value="1" KeyPath="yes" /> </Component> </ComponentGroup> <Feature Id="MainFeature" Title="KAM Package" Level="1"> <ComponentGroupRef Id="ProgramA_Files" /> <ComponentGroupRef Id="ProgramB_Files" /> <ComponentGroupRef Id="ProgramC_Files" /> <ComponentGroupRef Id="StartMenuShortcuts" /> </Feature> </Product> </Wix>
Step 2: Compile the Script
Open the WiX command prompt and run these commands (replace YourInstallerScript.wxs with your file name):
candle YourInstallerScript.wxs light YourInstallerScript.wixobj
This will generate an MSI installer. Test it to ensure all your requirements are met.
Key Notes
- Customization: Both tools let you add extras like license agreements, custom installation prompts, or registry entries—just extend the scripts as needed.
- Testing: Always test the installer on a clean machine to catch issues with file paths or shortcut creation.
- Permissions: Both tools handle elevated permissions for writing to Program Files by default for per-machine installs.
Either tool will deliver exactly what you need. Inno Setup is the way to go if you’re new to installer building, while WiX is better for enterprise-grade MSI deployments.
内容的提问来源于stack exchange,提问作者qamarq

