Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

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. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


darks0ul

Registry import in setupcomplete.cmd does not work

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?

Share this post


Link to post
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".

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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 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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...