Software Deployment Question

Active Setup: Batchfile is not adding registryfiles

03/28/2012 10985 views
I run a batchfile via active setup. This batch file is adding .reg-files to the HKCU of the user (folder view-settings, etc).
The batchfile does it's job when I run manually as an user. When it's been started by active setup, the registry keys are not applied. For debugging I added "echo 1 > %temp%\1.log", which showed that the batchfile was started and each command line (eg "regedit /s HKCU_Remove_recent_from_startmenu.reg) was started as well.
Anybody any ideas?
0 Comments   [ + ] Show comments


All Answers

64 bit?
Answered 03/28/2012 by: dugullett
Red Belt

  • I had some trouble with this on one of our installs. I ended up creating an exe using Autoit that ran the reg keys. For whatever reason I had better luck running an exe rather the a reg file. Not sure if it was just my enviroment or not.
did you set your scripts working directory by starting it with

pushd "%~dp0"

If not, give it a try
Answered 03/28/2012 by: pjgeutjens
Red Belt

If we assume that you batch file and the reg files are in the same folder, try the following batch file:

[--Snip Start--]
@echo off

Set CURRDIR=%~dp0
Set LOG_FILE=%Temp%\Log.log

REG.exe IMPORT "%CURRDIR%HKCU_Alle_Folders_visible.reg" >> "%LOG_FILE%" 2>&1
Echo return: %ERRORLEVEL% >> "%LOG_FILE%"

REG.exe IMPORT "%CURRDIR%HKCU_set_screensave_reactivation_password.reg" >> "%LOG_FILE%" 2>&1
Echo return: %ERRORLEVEL% >> "%LOG_FILE%"

REG.exe IMPORT "%CURRDIR%HKCU_explorer_statusleiste visible.reg" >> "%LOG_FILE%" 2>&1
Echo return: %ERRORLEVEL% >> "%LOG_FILE%"

REG.exe IMPORT "%CURRDIR%HKCU_systemscontrol_small_icons.reg" >> "%LOG_FILE%" 2>&1
Echo return: %ERRORLEVEL% >> "%LOG_FILE%"

REG.exe IMPORT "%CURRDIR%HKCU_windows_explorer_folder_options.reg" >> "%LOG_FILE%" 2>&1
Echo return: %ERRORLEVEL% >> "%LOG_FILE%"

REG.exe IMPORT "%CURRDIR%HKCU_Remove_recent_from_startmenu.reg" >> "%LOG_FILE%" 2>&1
Echo return: %ERRORLEVEL% >> "%LOG_FILE%"
[--Snip End--]

Reg.exe gives a return code of 1 if it fails but regedit just returns zero in either case.

Hope this helps,
Answered 03/28/2012 by: Daz
Orange Belt

use following in activesetup
reg.exe IMPORT \regfile.reg
Answered 03/29/2012 by: piyushnasa
Red Belt

  • Thanks piyushnasa, this is what I needed. My Active Setup was hanging because a UAC prompt is triggering when using REGEDIT ADD but REG IMPORT gets around it.
regedit /s HKCU_Remove_recent_from_startmenu.reg

start by taking out the /s and see if you get any error messages.
Answered 03/28/2012 by: pjgeutjens
Red Belt

Can you post code snippet of your batch file??
Answered 03/28/2012 by: akki
4th Degree Black Belt

@dugullett: Yes, 64Bit
@pjgeutjens: You'll see nothing of that at all, cause the batch runs before the desktop is ready. When you redirect the output to a file (eg
regedit /s HKCU_Remove_recent_from_startmenu.reg > %temp%\logfile.log), it'll be empty
@akki: this is my batch:

[--Snip Start--]
@echo off
regedit /s HKCU_Alle_Folders_visible.reg
regedit /s HKCU_set_screensave_reactivation_password.reg
regedit /s HKCU_explorer_statusleiste visible.reg
regedit /s HKCU_systemscontrol_small_icons.reg
regedit /s HKCU_windows_explorer_folder_options.reg
regedit /s HKCU_Remove_recent_from_startmenu.reg
[--Snip END--]
Answered 03/28/2012 by: FerrisBueller
Senior Yellow Belt

  • @FerrisBueller:
    1. Have you given the proper path as in
    "%alluserspath%\HKCU_Remove_recent_from_startmenu" in your batch file, i dont
    see this in you batch file.
    2. If possible give it a try through VBScript.
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ