User Tools

Site Tools


Active Setup (Example)

The following script registers a new Active Setup script that runs “reg.exe import user.reg” for each user.

Tested with opsi 4.0.4
Tested with opsi-winst
By holgerv 2014-08-06

Active Setup is a mechanism in Microsoft Windows to enforce a script (or multiple scripts) to be executed for each single user who logs on into Windows exactly once. It works for local profiles and for roaming profiles as well.

It is convenient for changing user profiles.

Active Setup entrys have a version number, so you can enforce that the actual version of your Active Setup script is executed for each user.

Limitation: Active Setup doesn't work for Citrix published applications automatically, because Active Setup is run by explorer.exe.



  ├ delsub.ins
  ├ setup.ins
  ├ uninstall.ins
  └ user.reg


SetLogLevel = 6
DefVar $ProductId$
DefVar $ProgramPath$
DefVar $RegFileName$
DefVar $ScriptName$
Set $ProductId$ = "ActiveSetupExample"
Set $ProgramPath$ = "%ProgramFilesSysnativeDir%" + "\" + $ProductId$
Set $RegFileName$ = "user.reg"
Set $ScriptName$ = "ActiveSetupScript.cmd"
Message "Uninstall this software before reinstallation (just in case it's installed already) ..."
Sub "%ScriptPath%\delsub.ins"
Message "Copy .reg file to program directory ..."
Files_Copy_Reg_File /SysNative
Message "Create script that shall be executed once by/for each single user ..."
DosInAnIcon_Create_Script /SysNative
Message "Create ActiveSetup entry for the new script ..."
Registry_Enable_ActiveSetup_Script /SysNative
copy "%ScriptPath%\$RegFileName$" "$ProgramPath$"
echo reg.exe import "$ProgramPath$\$RegFileName$" > "$ProgramPath$\$ScriptName$"
openkey [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\$ProductId$]
set "" = "$ProductId$"
set "StubPath" = '"$ProgramPath$\$ScriptName$"'
set "Version" = "1,0,0,0"


SetLogLevel = 6
DefVar $ProductId$
DefVar $ProgramPath$
DefVar $RegFileName$
DefVar $ScriptName$
Set $ProductId$ = "ActiveSetupExample"
Set $ProgramPath$ = "%ProgramFilesSysnativeDir%" + "\" + $ProductId$
Set $RegFileName$ = "user.reg"
Set $ScriptName$ = "ActiveSetupScript.cmd"
Message "Uninstall " + $ProductId$
Sub "%ScriptPath%\delsub.ins"


Message "Disable ActiveSetup entry ..."
; There's no "If (RegKeyExists(...))" in opsi, so just delete the registry key and get a log file warning if it doesn't exist
Registry_Disable_ActiveSetup_Script /SysNative
Message "Delete ActiveSetup script ..."
If (FileExistsSysNative($ProgramPath$ + "\" + $ScriptName$))
        Files_Delete_ActiveSetup_Script /SysNative
Message "Delete reg file ..."
If (FileExistsSysNative($ProgramPath$ + "\" + $RegFileName$))
        Files_Delete_Reg_File /SysNative
DeleteKey [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\$ProductId$]
Delete "$ProgramPath$\$ScriptName$"
Delete "$ProgramPath$\$RegFileName$"

You will also need a user.reg which contains the changes in HKCU that you want to import for each user.

userspace/active_setup_example.txt · Last modified: 2021/08/23 08:37 (external edit)