Jump to content
MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. ×

Registry import in setupcomplete.cmd does not work


 Share

Recommended Posts

Hi,

I have some .reg files with settings I'd like all the users to have and I'm trying to apply them in setupcomplete.cmd, so that the default account is modified and new accounts copy the settings from there.

Here's my setupcomplete.cmd

@echo on

echo OK>>C:\setupcomplete.log
:: Apply common HKCU tweaks to the default account
IF EXIST C:\Install\user_regtweaks_common.reg echo Exist user_regtweaks_common.reg>>C:\setupcomplete.log
REGEDIT /S %SystemDrive%\Install\user_regtweaks_common.reg>>%SystemDrive%\setupcomplete.log

:: Console tweaks
IF EXIST C:\Install\console.reg echo Exist console.reg>>C:\setupcomplete.log
REGEDIT /S C:\Install\console.reg>>C:\setupcomplete.log

After setup is completed, setupcomplete.log contains

OK
Exist user_regtweaks_common.reg
Exist console.reg

Does anybody know what's wrong?

Link to comment
Share on other sites


If uac isn't turned off regedit command doesn't run. Perhaps that's why also i would replace "regedit" with "reg import".

UAC is off, I tried with reg import and I got the same results.

If I manually run setupcomplete.cmd, it works.

Link to comment
Share on other sites

Perhaps uac is turned off after the script is run or isn't turned of for the user running the script because "reg import" will always output something.

Try with those tricks to bypass uac.

That didn't work :( Reg import outputs "operation completed successfully" or something alike.

I'm afraid it's related to that, but it does not seem an elegant solution to me.

Thanks for helping me out

Link to comment
Share on other sites

You can try adding registry keys like this example.

Create your customized SetupComplete.cmd and your registry settings (User.reg and Console.reg) inside the folder:

%SystemDrive%\Distribution_Folder\sources\$OEM$\$$\Setup\Scripts\

Example:

SetupComplete.cmd


@echo off
REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx
SET KEY=HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx
echo.
REG ADD %KEY%\005 /V 1 /D "REGEDIT /S %SystemRoot%\Setup\Scripts\User.reg" /f
echo.
REG ADD %KEY%\010 /V 1 /D "REGEDIT /S %SystemRoot%\Setup\Scripts\Console.reg" /f
exit

Link to comment
Share on other sites

I solved it by loading the default user registry:

reg load HKU\LoadedDefaultUser "%SystemDrive%\Users\Default\ntuser.dat"

:: Apply common HKCU tweaks to the default account
REGEDIT /S %SystemDrive%\Install\user_regtweaks_common.reg

:: Unload registry hive
reg unload HKU\LoadedDefaultUser

I thought that HKCU pointed to that hive, but I was wrong.

Link to comment
Share on other sites

Works fine also using "reg.exe import" (example):

SetupComplete.cmd


@echo off
REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx
SET KEY=HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx
REG ADD %KEY%\005 /V 1 /D "reg import "%SystemDrive%\Install\Tweaks.reg""

exit

Edited by myselfidem
Link to comment
Share on other sites

  • 2 years later...

I solved it by loading the default user registry:

reg load HKU\LoadedDefaultUser "%SystemDrive%\Users\Default\ntuser.dat":: Apply common HKCU tweaks to the default accountREGEDIT /S %SystemDrive%\Install\user_regtweaks_common.reg:: Unload registry hivereg unload HKU\LoadedDefaultUser
I thought that HKCU pointed to that hive, but I was wrong.

Hey darks0ul...

look to the thread @ mydigitallife again.... i just was there and now i found this thread xD

But you should have menioned, that the keys in the regfile have to be adapted to the hive

from

HKEY_CURRENT_USER\BLABLA

to

HKU\LoadedDefaultUser\BLABLA

Cheers, Schiiwa

Link to comment
Share on other sites

Works fine also using "reg.exe import" (example):

SetupComplete.cmd

@echo offREG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceExSET KEY=HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceExREG ADD %KEY%\005 /V 1 /D "reg import "%SystemDrive%\Install\Tweaks.reg""exit

This would be more genteel if you want to have a variable anyway :whistle:

@echo offSET KEY=HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceExREG ADD %KEY%REG ADD %KEY%\005 /V 1 /D "reg import "%SystemDrive%\Install\Tweaks.reg""exit
Edited by Schiiwa
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...