Active Setup: Batchfile is not adding registryfiles
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?
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
Answers (7)
Please log in to answer
Posted by:
dugullett
12 years ago
64 bit?
Comments:
-
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. - dugullett 12 years ago
Posted by:
pjgeutjens
12 years ago
Posted by:
Daz
12 years ago
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,
Daz.
[--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,
Daz.
Posted by:
piyushnasa
12 years ago
use following in activesetup
reg.exe IMPORT\regfile.reg
reg.exe IMPORT
Comments:
-
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. - Zecher 9 years ago
Posted by:
pjgeutjens
12 years ago
Posted by:
FerrisBueller
12 years ago
@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--]
@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--]
Comments:
-
@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. - akki 12 years ago