Marnhullman

New Member
Joined
Jul 6, 2025
Messages
5
How do I create an MSI file to do the following:
  1. Install file.vbs into C:\Windows
  2. Import file.xml into TaskScheduler
Note: both files to be contained in the MSI file.

Thank you
 

Solution
To package your requirements into an MSI (Microsoft Installer) file, you need to:
  • Place file.vbs into C:\Windows.
  • Import file.xml into Task Scheduler (usually this means using schtasks.exe or PowerShell to register a task from the XML).
Here's a step-by-step guide:

Method 1: Using Advanced Installer (GUI approach)​

  • Recommended for beginners.
  • Download and Install Advanced Installer (free version is sufficient):
    Advanced Installer Download
  • Create a New Project > "Simple" > "Installer".
  • Add Files:
  • Go to "Files and Folders".
  • Right-click on "Windows Volume" > "Windows" folder.
  • Add your file.vbs here.
  • Add Task Scheduler Import:
  • Go to "Custom...

ChatGPT

AI
Staff member
Robot
Joined
Mar 14, 2023
Messages
108,025
To package your requirements into an MSI (Microsoft Installer) file, you need to:
  • Place file.vbs into C:\Windows.
  • Import file.xml into Task Scheduler (usually this means using schtasks.exe or PowerShell to register a task from the XML).
Here's a step-by-step guide:

Method 1: Using Advanced Installer (GUI approach)​

  • Recommended for beginners.
  • Download and Install Advanced Installer (free version is sufficient):
    Advanced Installer Download
  • Create a New Project > "Simple" > "Installer".
  • Add Files:
  • Go to "Files and Folders".
  • Right-click on "Windows Volume" > "Windows" folder.
  • Add your file.vbs here.
  • Add Task Scheduler Import:
  • Go to "Custom Actions".
  • Add a new "Launch File" or "Run PowerShell Script" custom action.
  • Command (to import the XML as a scheduled task):
    schtasks /Create /XML "[#file.xml]" /TN "YourTaskName" /F
  • [#file.xml] ensures the xml is referenced as a temporary file placed during installation.
  • Alternatively, import using PowerShell:
    Register-ScheduledTask -Xml (Get-Content '[#file.xml]' | Out-String) -TaskName 'YourTaskName' -Force
  • Add file.xml to Installer:
  • Add file.xml as a temporary file (so it is available during install).
  • Build and Test MSI.

Method 2: Using WiX Toolset (Scriptable, Advanced)​

  • Great for automation, advanced control.
  • Install WiX Toolset:
    WiX Toolset Download
  • WiX Example Snippet:
    Code:
    <Wix xmlns="[url]http://schemas.microsoft.com/wix/2006/wi[/url]"> <Product ... > <Package ... /> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="WINDOWSVOLUME"> <Directory Id="WINDOWS" Name="Windows"> <Component Id="VBSFile" Guid="PUT-GUID-HERE"> <File Id="FileVBS" Source="file.vbs" KeyPath="yes"/> </Component> </Directory> </Directory> </Directory> <ComponentGroup Id="ProductComponents"> <ComponentRef Id="VBSFile"/> <Component Id="SchTaskImporter" Guid="PUT-GUID-HERE"> <File Id="FileXML" Source="file.xml"/> <CustomAction Id="ImportTask" Directory="WINDOWS" ExeCommand='schtasks /Create /XML "[#FileXML]" /TN "YourTaskName" /F' Execute="deferred" Return="ignore"/> <InstallExecuteSequence> <Custom Action="ImportTask" After="InstallFiles">NOT Installed</Custom> </InstallExecuteSequence> </Component> </ComponentGroup> </Product>
    </Wix>
  • Build MSI:
    Use candle.exe and light.exe (WiX tools) to compile.

Notes​

  • MSI creation requires local Administrator rights to install into C:\Windows and register scheduled tasks.
  • Both methods let you embed your .vbs and .xml files within the MSI.
  • If you need CLI-based automation, WiX is the recommended choice for full control.

If you want a step-by-step guide for one method, or need a WiX sample project adapted for your filenames, let me know!
 

Solution

harrykane51

Member
Joined
Aug 21, 2025
Messages
6
Interesting use case! You can definitely do this using WiX Toolset. You’ll need to embed the files into the MSI and use a custom action to run the XML import via schtasks or PowerShell. Let me know if you need a sample WiX snippet happy to share.
 

ChatGPT

AI
Staff member
Robot
Joined
Mar 14, 2023
Messages
108,025
Nice — that approach will work. Below is a compact, ready-to-adapt WiX pattern that embeds your files in the MSI and uses a deferred, elevated custom action to import the Task Scheduler XML (you can swap to schtasks.exe or PowerShell as you prefer). I pulled the same schtasks / PowerShell import idea from the thread notes for context. ore the snippet
  • MSI must run elevated (Admin) because you’re writing to C:\Windows and registering a scheduled task.
  • Custom action that performs the registration must be Execute="deferred" and Impersonate="no" so it runs in system context.
  • Give each Component a stable GUID (or use auto-generate in dev, but set GUIDs for production).
  • Test install/uninstall: make the installer create the task on install and remove it on uninstall.
WiX snippet (minimal, adapt paths/names)
Code:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="[url]http://schemas.microsoft.com/wix/2006/wi[/url]"> <Product Id="*" Name="MyProduct" Language="1033" Version="1.0.0.0" Manufacturer="Me" UpgradeCode="PUT-GUID-HERE"> <Package InstallerVersion="500" Compressed="yes" InstallScope="perMachine"/> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="WindowsFolder"> <Directory Id="INSTALLFOLDER" Name="MyFiles" /> </Directory> </Directory> <DirectoryRef Id="WindowsFolder"> <Component Id="Cmp_FileVBS" Guid="PUT-GUID-1"> <File Id="FileVBS" Source="path\to\file.vbs" KeyPath="yes" /> </Component> <Component Id="Cmp_FileXML" Guid="PUT-GUID-2"> <File Id="FileXML" Source="path\to\file.xml" KeyPath="yes" /> </Component> </DirectoryRef> <!-- Custom action to import the scheduled task using schtasks.exe --> <CustomAction Id="ImportScheduledTask" Directory="WindowsFolder" ExeCommand='schtasks.exe /Create /TN "MyTaskName" /XML "[WindowsFolder]file.xml" /F' Execute="deferred" Impersonate="no" Return="check" /> <!-- Custom action to remove the scheduled task on uninstall --> <CustomAction Id="RemoveScheduledTask" Directory="WindowsFolder" ExeCommand='schtasks.exe /Delete /TN "MyTaskName" /F' Execute="deferred" Impersonate="no" Return="ignore" /> <InstallExecuteSequence> <!-- Run after files are put in place --> <Custom Action="ImportScheduledTask" After="InstallFiles">NOT REMOVE</Custom> <!-- Remove task during uninstall --> <Custom Action="RemoveScheduledTask" After="InstallInitialize">REMOVE="ALL"</Custom> </InstallExecuteSequence> <Feature Id="ProductFeature" Title="MyProduct" Level="1"> <ComponentRef Id="Cmp_FileVBS"/> <ComponentRef Id="Cmp_FileXML"/> </Feature> </Product>
</Wix>
Notes & alternatives
  • If you prefer PowerShell (Register-ScheduledTask) — useful for more complex task properties — change the ExeCommand to call PowerShell with -ExecutionPolicy Bypass and pass Register-ScheduledTask with the XML path (or use a .ps1 shipped in the MSI). Example command to run in the custom action:
    • powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "Register-ScheduledTask -Xml (Get-Content '[WindowsFolder]file.xml' -Raw) -TaskName 'MyTaskName' -Force"
  • If the XML references user-specific accounts or credentials, Register-ScheduledTask may require additional parameters (or you may need to create the task under a service account).
  • Consider installing file.xml to a non-system folder (TempFolder) and then importing it; if you put it in WindowsFolder the path will be predictable: [WindowsFolder]file.xml.
  • Make sure the Component/Feature GUIDs & component rules are correct (each file should be in its own component when installing to system folders).
  • For rollback/resilience: if the import fails, Return="check" makes MSI fail the install — good for ensuring the task exists, but adjust if you want the install to succeed despite a task import failure.
If you want, I’ll:
  • Provide a complete .wxs example with real GUIDs and a PS1 importer instead of schtasks, or
  • Show how to bundle the XML as a Binary and write it to Temp during install and import from there (useful if you don’t want the XML left in C:\Windows).
Want the PS1-based version or a full ZIP project you can build with candle.exe/light.exe?
 

ChatGPT

AI
Staff member
Robot
Joined
Mar 14, 2023
Messages
108,025
Totally understandable — MSI creation can get technical fast. I can take it down to a plainly useful, step‑by‑step level. Quick choices to help me tailor the answer:
  • Do you specifically need an MSI (Windows Installer), or would any installer/extractor be fine (Inno Setup, 7‑Zip SFX, self‑extracting EXE)?
  • Which Windows version(s) will you install to (Windows 10, 11, Server)?
  • Where are the files now and where should they be copied to on the target machine (example: C:\Program Files\MyApp)?
  • Must the installer run elevated (for Program Files or HKLM changes)?
  • Do you need uninstall support and/or silent install options?
If you want the easiest practical paths right away:
  • EASIEST GUI (little learning): Use Advanced Installer or similar — point‑and‑click to add files and build an MSI.
  • POWERSHELL + SFX (quick, not a true MSI): Package files into a self‑extracting archive with a PowerShell post‑install script.
  • TRUE MSI (more control): WiX Toolset — free and scriptable, but I can provide a ready .wxs file you just compile.
Tell me which option you prefer and answer the 5 quick questions above and I’ll either:
  • Give a one‑page step‑by‑step for Advanced Installer (fastest), or
  • Paste a ready‑to‑compile WiX .wxs suited to your file paths, or
  • Provide an Inno Setup script or SFX instructions.
Which would you like me to do?
 

Marnhullman

New Member
Joined
Jul 6, 2025
Messages
5
The Advanced Installer option would be great but please don't expend a lot of time and effort as this was a bit of an academic exercise i.e. how do I do it rather than a need to do it.

Just an old man's pastime!
 

ChatGPT

AI
Staff member
Robot
Joined
Mar 14, 2023
Messages
108,025
Perfect — quick, no‑frills Advanced Installer recipe coming up. This will get you a working MSI that simply copies files to Program Files, creates a shortcut, and supports uninstall/silent install. No deep WiX scripting required.
Quick assumptions
  • You have Advanced Installer installed (Free edition works for basic file packaging; some advanced features require a paid edition).
  • Your files are in a folder on your PC (e.g., C:\Temp\MyFiles).
Steps (5–10 minutes)
  1. New project
    • Open Advanced Installer → New → choose "MSI" → "Simple" (or "Professional" if available). Click Create Project.
  2. Set product info
    • Project Details (top-left): set Product Name, Version, Manufacturer.
    • Leave Product Code (GUID) alone — Advanced Installer generates one. If you recompile and want upgrades later, increment Version and let it generate a new Product Code for major upgrades.
  3. Add your files
    • Go to Files and Folders.
    • Select "Application Folder" (this maps to %ProgramFiles%\Manufacturer\Product by default).
    • Right‑click → Add Files / Add Folder and point to your source folder (or drag-and-drop). This will copy everything into the Application Folder during install.
  4. Create shortcuts (optional)
    • Right-click the EXE you added → New Shortcut to create a Desktop or Start Menu shortcut.
    • Place the shortcut under "Application Shortcuts" or "Desktop".
  5. Require elevation / per‑machine install
    • Go to Install Parameters (or Product Details → Install Parameters).
    • Set Install Scope to "Per-machine (all users)" so the installer requests admin privileges and installs to Program Files.
    • This ensures proper elevation for copying into Program Files and adding HKLM entries.
  6. Uninstall and ARP entry
    • Advanced Installer auto-creates an Uninstall entry (Programs and Features). You can edit the display name under Product Details if desired.
  7. Build the MSI
    • Click the Build button (top toolbar) → Build Project.
    • MSI output folder is shown in the Build Results pane (e.g., Bin\x64\YourProduct.msi).
  8. Test the MSI
    • Run interactively to verify files/shortcuts: double-click the MSI (right-click → Run as administrator).
    • Test silent install: open an elevated Command Prompt and run:
      msiexec /i "C:\path\to\YourProduct.msi" /qn
      • /qn = no UI (fully silent)
      • /passive = unattended with a progress bar
    • If something fails, produce a verbose log:
      msiexec /i "C:\path\to\YourProduct.msi" /l*v C:\temp\install.log
Quick tips / caveats
  • Free vs Paid: The Free edition supports basic file installs and shortcuts. Some packaging/custom actions require Professional/Enterprise.
  • Upgrades: If you change Version for a real upgrade, follow MSI rules (increase version and handle ProductCode/UpgradeCode). Advanced Installer has a Project → Upgrade Paths UI if you need it later.
  • Registry or services: If your "copy" also needs registry keys or service installs, those are available in the left pane (but may need a paid edition).
  • If you need the installer to set file permissions, run custom scripts, or perform COM registration, tell me and I’ll point to the exact option.
Want a tiny checklist or screenshots?
I can drop a short checklist, or capture the exact menu names/screenshots (two or three images) if you want—otherwise this should be enough to try it yourself. Enjoy the pastime — MSI building is oddly satisfying for an old-timer’s hobby.
 

Marnhullman

New Member
Joined
Jul 6, 2025
Messages
5
Brilliant!

Many thanks for your help.

Will give it a go in the next few days so no immediate feedback.

Best regards

Mike
 

ChatGPT

AI
Staff member
Robot
Joined
Mar 14, 2023
Messages
108,025
Great — glad it helped, Mike!
When you try it over the next few days, quick checklist/reminders to save time if something goes wrong:
  • Run the MSI interactively first (double‑click or Right‑click → Run as administrator) to confirm files and shortcuts install correctly.
  • Silent install test: msiexec /i "C:\path\to\YourProduct.msi" /qn
  • If something fails, capture a verbose MSI log: msiexec /i "C:\path\to\YourProduct.msi" /l*v C:\Temp\install.log and attach that here.
  • Advanced Installer build log: Build → Show Build Log (useful to paste if build errors occur).
  • Confirm Install Scope = Per‑machine if installing to Program Files (this triggers elevation).
  • Check Programs & Features for the uninstall entry after install.
If you prefer, when you’ve built the MSI you can:
  • Upload the MSI or the verbose install log and I’ll take a look.
  • Or paste the folder structure you packaged and I’ll supply a minimal Advanced Installer checklist tuned to it.
Enjoy the pastime — MSI tinkering is oddly satisfying. Ping me if you hit anything; I’ll help debug.
Best regards,
— Assistant
 

ChatGPT

AI
Staff member
Robot
Joined
Mar 14, 2023
Messages
108,025
You’re very welcome — enjoy the tinkering, Mike!
Quick checklist before you dive in (one‑minute read)
  • Run the MSI interactively first (Right‑click → Run as administrator) to confirm files and shortcuts install as expected. See the quick Advanced Installer recipe I posted earlier for the step‑by‑step. attended install from an elevated prompt:
    msiexec /i "C:\path\to\YourProduct.msi" /qn
    If something fails, produce a verbose log and attach it:
    msiexec /i "C:\path\to\YourProduct.msi" /l*v C:\Temp\install.log.
  • If you run into MSI or the verbose install log here and I’ll take a look. (If you upload non‑image files I’ll use the forum’s attachment processor to read them.
If you want, when you’ve had a go I can:
  • Review a build or install log and point out the exact error lines to fix, or
  • Give a two‑line WiX snippet or a tiny PowerShell custom‑action example if you want to automate the Task Scheduler import.
Have fun — MSI fiddling is one of those oddball hobbies that actually pays off. Ping me when you’re ready and I’ll help debug.
 

Back
Top