Creating Silent/Unattended or Portable Software Packages

crypticus

Well-Known Member
This guide will show you a way to create silent/unattended setups or portable softwares. Guide simply uses 7-Zip SFX as package creation method with support of bat/cmd/reg commands to enchance the ability to customize silent/unattended setups or portable packages. This method creates packages as we call open sourced so anything inside can be inspected via 7-Zip.

There are 3 SFX package creators. We are going to learn and use the first one.
  • 7-Zip SFX Builder – Download From Official Source
  • 7-Zip SFX Maker (Obsolute)
  • Winrar’s Built-In SFX Creator (Alternative but has less features)
  • EDIT: Started Using "7-Zip SFX Constructor" it is way better. Same settings in one windows easier to use. Official Source



Lets look into GUI and my personal preferences first, then I will share one simple and one complicated package as example.

1) Main Tab
1.png
Overwrite Mode: I always select Overwrite all files option to always use newest files in my package for future updates.
GUI Mode: For silent/unattended and portable apps I use Hide all GUI Window option.
Extraction Path: I always extract my packages to %temp% folder so it is hidden away from eye.
GUI/Misc Flags: There are different flags in order to hide the installation windows. GUIMode=2 is the one for silent installations.
Also I skip system locked files in order to prevent possible conflicts created by currently used files.

2) Title/Text Tab
In scope of this GUIDE we are creating silent/unattended or porable packages. So we will not have any user promt on our package. This part is unnecessary for us. So we are leaving it blank untouched.

3) Dialogs Tab
In scope of this GUIDE we are creating silent/unattended or porable packages. So we will not have any user promt on our package. This part is unnecessary for us. So we are leaving it blank untouched.

4) Run Tab

2.jpg


Press green + icon to add a command.
File: We enter software or script's full path here. On main window we set %temp% as a extraction path. For example you will install a simple software with silent parameter. You created a folder named InstallMe and inside there you placed NTLite.exe setup. Then the path you should write here is; %temp%\InstallMe\Ntlite.exe
Commands: Here we will write /s /qn /Silent /Quiet /NoRestart etc whatever the parameter of the exe file is.
Edit Prefixes: There are some important options here. Mostly I use 2 of them, nowait option lets you to remove or move or rename the package file while its running since its already extracted. When its not selected, our exe file can't be renamed or removed or moved. I find it silly since its already extracted and running so my package should be un-tied from running process. hidcon is important if you are running bat/cmd scripts, since the package we are creating is silent and unattended this option will hide that cmd window.

3) Detele Tab
This windows lets you to remove files/folders, normally I don't use it, because I can easily remove files via script I run if needed. But for nonscripted software packages or portable softwares this option can be usefull to do cleanups.

3) Shortcuts Tab
If your software doesn't create shortcuts on its own, or you deleted original one and want to create custom one without bat/cmd script, this tab will help you.

4) SetEnvironment Tab
This part lets you to create variables to use as paths etc. Normally you won't need it.

5) Output Tab
Here you can see commands that created during your configuration.

6) SFX Tab

3.jpg
This is the packaging part of the SFX.
7z Archive: Where you select your *.7z package. (We compress all files into one *.7z archive.)
SFX Module: I leave it empty.
SFX Path: Set your packages name and saving location.
SFX Icon: Select your *.ico file for your package. (Use softwares like "IconsExtract" to extract the Icons from exe files instead of searching and converting images.)
SFX Options: Can be set as shown for maximum compression.
Edit Version Info: These informations shown when file's properties are checked. Don't forget to select "Change version info" for changes to appy. Or default 7-Zip information will be shown.
Press Make SFX to create your own package.





I will share a package I made that uses CCleaner Free as an example for educational purposes. Archive can be opened via 7-Zip to inspect the commands. (Open Sourced) DM Me For It

CCleaner portable package with settings and online download ability in order to get latest version each time exe is run. (Will download itself at background so don't open it multiple times, just wait.)

Scripted version have unlimited potential, limit is literally your imagination and scripting skills.
 
Last edited:
Another way i use is to fake an install.
Start your installer then run RegFromApp, save the reg file(convert to command line if you wish), copy the 7zip folder to $OEM$.
Add the reg file to a mounted image or add it(or the command line) to Post Setup.
It wont suit some programs but some it will.

Code:
Reg.exe add "HKEY_CURRENT_USER\Software\7-Zip" /v "Path64" /t REG_SZ /d "C:\Program Files\7-Zip\\" /f
Reg.exe add "HKEY_CURRENT_USER\Software\7-Zip" /v "Path" /t REG_SZ /d "C:\Program Files\7-Zip\\" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip" /v "Path64" /t REG_SZ /d "C:\Program Files\7-Zip\\" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip" /v "Path" /t REG_SZ /d "C:\Program Files\7-Zip\\" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{23170F69-40C1-278A-1000-000100020000}" /ve /t REG_SZ /d "7-Zip Shell Extension" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{23170F69-40C1-278A-1000-000100020000}\InprocServer32" /ve /t REG_SZ /d "C:\Program Files\7-Zip\7-zip32.dll" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{23170F69-40C1-278A-1000-000100020000}\InprocServer32" /v "ThreadingModel" /t REG_SZ /d "Apartment" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}" /ve /t REG_SZ /d "7-Zip Shell Extension" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}\InprocServer32" /ve /t REG_SZ /d "C:\Program Files\7-Zip\7-zip.dll" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}\InprocServer32" /v "ThreadingModel" /t REG_SZ /d "Apartment" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shellex\ContextMenuHandlers\7-Zip" /ve /t REG_SZ /d "{23170F69-40C1-278A-1000-000100020000}" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shellex\ContextMenuHandlers\7-Zip" /ve /t REG_SZ /d "{23170F69-40C1-278A-1000-000100020000}" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shellex\ContextMenuHandlers\7-Zip" /ve /t REG_SZ /d "{23170F69-40C1-278A-1000-000100020000}" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shellex\DragDropHandlers\7-Zip" /ve /t REG_SZ /d "{23170F69-40C1-278A-1000-000100020000}" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shellex\DragDropHandlers\7-Zip" /ve /t REG_SZ /d "{23170F69-40C1-278A-1000-000100020000}" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved" /v "{23170F69-40C1-278A-1000-000100020000}" /t REG_SZ /d "7-Zip Shell Extension" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved" /v "{23170F69-40C1-278A-1000-000100020000}" /t REG_SZ /d "7-Zip Shell Extension" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\7zFM.exe" /ve /t REG_SZ /d "C:\Program Files\7-Zip\7zFM.exe" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\7zFM.exe" /v "Path" /t REG_SZ /d "C:\Program Files\7-Zip\\" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" /v "DisplayName" /t REG_SZ /d "7-Zip 19.00 (x64)" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" /v "DisplayVersion" /t REG_SZ /d "19.00" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" /v "DisplayIcon" /t REG_SZ /d "C:\Program Files\7-Zip\7zFM.exe" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" /v "InstallLocation" /t REG_SZ /d "C:\Program Files\7-Zip\\" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" /v "UninstallString" /t REG_SZ /d "C:\Program Files\7-Zip\Uninstall.exe" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" /v "NoModify" /t REG_DWORD /d "1" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" /v "NoRepair" /t REG_DWORD /d "1" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" /v "EstimatedSize" /t REG_DWORD /d "5082" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" /v "VersionMajor" /t REG_DWORD /d "19" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" /v "VersionMinor" /t REG_DWORD /d "0" /f
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" /v "Publisher" /t REG_SZ /d "Igor Pavlov" /f
 
That's usefull if you want to preinstall softwares. You can also place files by exploring mounted content and just paste to there.. instead of $OEM$ folder....
 
Last edited:
You can also place files by exploring mounted content and just paste to there.. instead of $OEM$ folder....
You dont have to mount an image using $OEM$, its easier to add newer versions that way :)
Besides, once i have got a working image(captured) i dont like to mess around with it, you are at the mercy of bugs and other unforseen events.
 
The drawback is you need to know if the installer isn't writing to files outside of it's Program Files folder.
For example, updating Default user's NTUSER.dat or AppData\Local.
 
You dont have to mount an image using $OEM$, its easier to add newer versions that way :)
Besides, once i have got a working image(captured) i dont like to mess around with it, you are at the mercy of bugs and other unforseen events.
Thats why I add "software" folder recognized by setupcomplete and install silent softwares at first boot during setup.

Code:
setlocal EnableDelayedExpansion
set /a KEYNUM=0
SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx
REG ADD %KEY% /V TITLE /D "Installing Softwares..." /f
FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST "%%i:\Software" (for /f "delims=" %%z in ('dir /b %%i:\Software\*.exe') do (
set /a KEYNUM=!KEYNUM!+1
REG ADD %KEY%\!KEYNUM! /VE /D "%%~nz" /f
REG ADD %KEY%\!KEYNUM! /V 1 /D "%%i:\Software\%%z" /f
))

Edit: Updated code check other comments by me

The drawback is you need to know if the installer isn't writing to files outside of it's Program Files folder.
For example, updating Default user's NTUSER.dat or AppData\Local.
You can use hibit uninstallers "installation monitoring" for things like that. but I think they can never be %100 accurate
 
Last edited:
The drawback is you need to know if the installer isn't writing to files outside of it's Program Files folder.
For example, updating Default user's NTUSER.dat or AppData\Local.
True, but if you run Everything and sort by Date Created you will see what files have been added.
You might be right about ntuser.dat though. For users "app data" you can create a custom $OEM$ folder but without $$ and $1 then just copy them over. Whatever way its good to know users have multiple choices :)
 
Thats why I add "software" folder recognized by setupcomplete and install silent softwares at first boot during setup.

Code:
setlocal EnableDelayedExpansion
set /a KEYNUM=0
SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx
REG ADD %KEY% /V TITLE /D "Installing Softwares..." /f
FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST "%%i:\Software" (for /f "delims=" %%z in ('dir /b %%i:\Software\*.exe') do (
set /a KEYNUM=!KEYNUM!+1
REG ADD %KEY%\!KEYNUM! /VE /D "%%~nz" /f
REG ADD %KEY%\!KEYNUM! /V 1 /D "%%i:\Software\%%z" /f
))


You can use hibit uninstallers "installation monitoring" for things like that. but I think they can never be %100 accurate

here is updated version to handle more file types...

Code:
setlocal EnableDelayedExpansion

set /a KEYNUM=0
SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx
REG ADD %KEY% /V TITLE /D "Installing Softwares..." /f

FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST "%%i:\Software" (
    for %%x in (exe bat cmd vbs vbe reg) do (
        for /f "delims=" %%z in ('dir /b "%%i:\Software\*.%%x" 2^>nul') do (
            set /a KEYNUM+=1
            if "%%x"=="reg" (
                REG ADD "%KEY%\!KEYNUM!" /VE /D "Importing %%~nz.reg" /f
                REG ADD "%KEY%\!KEYNUM!" /V 1 /D "regedit /s \"%%i:\Software\%%z\"" /f
            ) else if "%%x"=="vbs" (
                REG ADD "%KEY%\!KEYNUM!" /VE /D "Running %%~nz.vbs" /f
                REG ADD "%KEY%\!KEYNUM!" /V 1 /D "cscript /nologo \"%%i:\Software\%%z\"" /f
            ) else if "%%x"=="vbe" (
                REG ADD "%KEY%\!KEYNUM!" /VE /D "Running %%~nz.vbe" /f
                REG ADD "%KEY%\!KEYNUM!" /V 1 /D "cscript /nologo \"%%i:\Software\%%z\"" /f
            ) else (
                REG ADD "%KEY%\!KEYNUM!" /VE /D "Running %%~nz.%%x" /f
                REG ADD "%KEY%\!KEYNUM!" /V 1 /D "cmd /c \"%%i:\Software\%%z\"" /f
            )
        )
    )
)
 
A shorter way of determining the USB drive (since it has a default label):
Code:
for /f "tokens=1" %%i in ('wmic logicaldisk where volumename^="NTLite" get deviceid ^| findstr :') do if exist "%%i\Software" (
)
 
Volume name can be different? also the point is also to use normal drives if you have them plugged since you may not have lots of GBs on flashdrive
 
The idea is if you have drives with an unique volume label, then you don't have to search every device. Like if you had two drives both with \Software but only wanted to recognize one of them.
 
Back
Top