WinRAR Self-Extracting (SFX) Installer
Package an application into a single .exe using WinRAR SFX, including a post-install script to create shortcuts and optionally launch the app.
1) Requirements
- WinRAR (latest version recommended)
- Application folder (contains the main executable, e.g.,
AppLauncher.exe or autopatch.exe) - Optional:
icon.icofor SFX window & shortcuts
2) Prepare the Source Folder
Package\
AppLauncher.exe
icon.ico (optional)
postinstall.vbs (script below)
Rename files as needed. The guide uses neutral names.
3) postinstall.vbs — Create Shortcuts & Launch
Save this file in the source folder.
' Post-install: create shortcuts and launch application
Option Explicit
Dim WshShell, fso, instDir, scDesk, smDir, lnk
Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
' Use the extracted folder (where this VBS is located)
instDir = fso.GetParentFolderName(WScript.ScriptFullName)
' Desktop shortcut
scDesk = WshShell.SpecialFolders("Desktop") & "\Your App.lnk"
Set lnk = WshShell.CreateShortcut(scDesk)
lnk.TargetPath = instDir & "\AppLauncher.exe"
lnk.WorkingDirectory = instDir
If fso.FileExists(instDir & "\icon.ico") Then lnk.IconLocation = instDir & "\icon.ico"
lnk.Save
' Start Menu shortcut
smDir = WshShell.SpecialFolders("Programs") & "\Your App"
If Not fso.FolderExists(smDir) Then fso.CreateFolder(smDir)
Set lnk = WshShell.CreateShortcut(smDir & "\Your App.lnk")
lnk.TargetPath = instDir & "\AppLauncher.exe"
lnk.WorkingDirectory = instDir
If fso.FileExists(instDir & "\icon.ico") Then lnk.IconLocation = instDir & "\icon.ico"
lnk.Save
' Auto launch application (optional)
WshShell.Run """" & instDir & "\AppLauncher.exe" & """", 1, False
Replace Your App and AppLauncher.exe with your own names if needed.
4) Build the SFX in WinRAR
- Open WinRAR and browse into the Package folder.
- Select all files → click Add.
- In the dialog, set:
- Archive format: RAR
- Create SFX archive: checked
- Advanced SFX options… → Text and icon → Load SFX icon from file → choose
icon.ico(optional)
- Open the Comment tab and paste one of the following blocks.
A) Interactive Mode
;The comment below contains SFX script commands
Title=Application Installer
Path=%ProgramFiles%\Your App
Overwrite=1
Setup=wscript.exe postinstall.vbs
B) Silent Mode
;The comment below contains SFX script commands
Title=Application Installer
Path=%ProgramFiles%\Your App
Silent=1
Overwrite=1
Setup=wscript.exe postinstall.vbs
To avoid UAC, install per-user instead: Path=%UserProfile%\Apps\Your App.
5) Test
- Run the generated .exe — files extract to the specified folder.
- Shortcuts appear on Desktop and in Start Menu.
- The application auto-launches (remove the last VBS line if not desired).
6) Troubleshooting
- Window title shows quotes — Use the WinRAR SFX comment format (no quotes). First line must be
;The comment below contains SFX script commands. - Default folder isn’t Program Files — Use
Path=...(WinRAR syntax).InstallPath=is 7-Zip SFX only. - VBS doesn’t run — Ensure Windows Script Host isn’t disabled by policy/AV.
- No uninstaller — WinRAR SFX does not create one; remove by deleting the folder and shortcuts.
7) Notes & Options
- RAR is recommended for larger payloads.
- Overwrite=1 ensures updates replace previous files.
- Icon: set SFX icon via Advanced SFX options → Text and icon. Shortcuts use
icon.icofrom the install folder. - Split volumes: configure Split to volumes in Add to Archive… for multi-part uploads.
8) Quick Checklist
- Place
AppLauncher.exe,icon.ico, andpostinstall.vbsin the source folder. - WinRAR → Add → check Create SFX archive → choose RAR5.
- Comment tab → paste the
Title/Path/Setupblock (no quotes). - Build the .exe → test → shortcuts + launch ready.