Jump to content

Administrative user doesn’t write registry settings in HKEY_CURRENT_US


Recommended Posts


You could try this!

@ECHO OFF & SETLOCAL ENABLEEXTENSIONSSET "_UPPS="FOR /F "USEBACKQ TOKENS=2 DELIMS==" %%A IN (`WMIC USERACCOUNT WHERE^ "DISABLED='FALSE' AND LOCALACCOUNT='TRUE' AND STATUS='OK'" GET SID /VALUE`    ) DO (FOR /F "USEBACKQ TOKENS=1* DELIMS==" %%B IN (`        WMIC PATH WIN32_USERPROFILE WHERE^         "SID='%%A' AND SPECIAL='FALSE'" GET LOCALPATH /VALUE 2^>NUL`) DO (        IF %%~dC' NEQ ' (CALL SET _UPPS=%%_UPPS%% "%%~C")))IF NOT DEFINED _UPPS GOTO :EOFSET _CRK=Software\OmicronLab\Avro KeyboardFOR %%A IN (%_UPPS%) DO (REG LOAD "HKU\_" "%%~A\NTUSER.DAT"    REG ADD "HKU\_\%_CRK%" /V ChangeInputLocale /D YES /F>NUL    REG UNLOAD "HKU\_"    PING -n 4 127.0.0.1 1>NUL)

You may not need the ping command at the last line or you may need to adjust it depending upon any delay between unloading one dat file and loading the next dat file.

 

Also be very careful, corruption of this file could prevent your users from logging in.

 

I tried to add some registry line in your command and result is Error, screenshot with. Any fault in my codes?

 

@ECHO OFF & SETLOCAL ENABLEEXTENSIONS
echo.
echo.
echo.
SET "_UPPS="
FOR /F "USEBACKQ TOKENS=2 DELIMS==" %%A IN (`WMIC USERACCOUNT WHERE^
 "DISABLED='FALSE' AND LOCALACCOUNT='TRUE' AND STATUS='OK'" GET SID /VALUE`
    ) DO (FOR /F "USEBACKQ TOKENS=1* DELIMS==" %%B IN (`
        WMIC PATH WIN32_USERPROFILE WHERE^
         "SID='%%A' AND SPECIAL='FALSE'" GET LOCALPATH /VALUE 2^>NUL`) DO (
        IF %%~dC' NEQ ' (CALL SET _UPPS=%%_UPPS%% "%%~C")))
IF NOT DEFINED _UPPS GOTO :EOF
SET _CRK=Software\OmicronLab\Avro Keyboard
FOR %%A IN (%_UPPS%) DO (REG LOAD "HKU\_" "%%~A\NTUSER.DAT"
    REG ADD "HKU\_\%_CRK%" /V ShowSplash /D NO /F>NUL
    REG ADD "HKU\_\%_CRK%" /V DefaultUIMode /D ICON /F>NUL
    REG ADD "HKU\_\%_CRK%" /V ModeSwitchKey /D F11 /F>NUL
    REG ADD "HKU\_\%_CRK%" /V DefaultLayout /D Bijoy2003 /F>NUL
    REG UNLOAD "HKU\_"
    PING -n 4 127.0.0.1 1>NUL)
echo.
echo.
echo.
echo. Now press any key to exit &pause >nul
exit /b

post-322156-0-70059700-1416327446_thumb.

Link to comment
Share on other sites

What happens if you adjust the ping to say 10 seconds?

PING -n 11 127.0.0.1 1>NUL

It suggests that perhaps the handle is still open on the unloaded file and cannot therefore reload it in the loop

 

Screenshot above is my result. I just tried to add more reg settings. That's all. 

Link to comment
Share on other sites

if you were in powershell, you could call the garbage collector to release those handles after unload the hive.

[System.GC]::Collect()

http://jrich523.wordpress.com/2012/03/06/powershell-loading-and-unloading-registry-hives/

I tried many ways. Same result. I think it's not possible. Better let the topic close. Thanks a lot for wise advice.

Link to comment
Share on other sites

 

I visited these links and read very attentively. But it’s very advanced topics to me. So I couldn’t apply the method discussed there. If you try my settings bellow you’ll be thanked and highly appreciated really.

 

 

Windows Registry Editor Version 5.00
 
[HKEY_CURRENT_USER\Software\OmicronLab\Avro Keyboard]
"ChangeInputLocale"="YES"
"PrefferedLocale"="BANGLADESH"
"AvroUpdateCheck"="NO"
"DontShowComplexLNotification"="NO"
"DontShowStartupWizard"="NO"
"StartWithWindows"="YES"
"ShowSplash"="NO"
"DefaultUIMode"="ICON"
"LastUIMode"="ICON"
"ModeSwitchKey"="F11"
"EnableJoNukta"="NO"
"OldStyleReph"="YES"
"VowelFormating"="YES"
"NumPadBangla"="YES"
"AutomaticallyFixChandra"="YES"
"FullOldStyleTyping"="YES"
"DefaultLayout"="Bijoy2003"
"OutputIsBijoy"="NO"
Link to comment
Share on other sites

Well, you want to do something "advanced" and it is rather obvious that in order to do that you will need to get "advanced" knowledge, but the procedure is simple enough.

 

From the description in the given link:

http://www.itninja.com/blog/view/appdeploy-articles-activesetup?

 

When an user logs on, a "common to all" key:

HKLM\Software\Microsoft\Active Setup\Installed Components\<UID>

is compared to a corresponding "per user" key:

HKCU\Software\Microsoft\Active Setup\Installed Components\<UID>

 

If the HKCU key is not found the contents of the string value StubPath is executed. The HKLM key is then copied to HKCU. 

 

 

 

See if this makes it simple enough (it includes an example that you can easily replicate for testing purpose):

https://helgeklein.com/blog/2010/04/active-setup-explained/

 

In your case you would add something like:

 

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\KaliOmicronLab]
@="Kali's OmicronLab Avro Keyboard"
"StubPath"="avro.cmd" 

 

When each user logs in for the first time (and for the first time only) the file avro.cmd will be executed, of course under the current user credentials, so all you need is to make a .cmd that adds those Registry entries to HKCU and make sure it is in the PATH or provide a path to it in the above key.

 

The avro.cmd could be something *like*:

@ECHO OFFSETLOCAL ENABLEEXTENSIONSSET My_Reg_hive=HKCU\Software\OmicronLab\Avro KeyboardFOR %%A IN ("ChangeInputLocale=YES""PrefferedLocale=BANGLADESH""AvroUpdateCheck=NO""DontShowComplexLNotification=NO""DontShowStartupWizard=NO""StartWithWindows=YES""ShowSplash=NO""DefaultUIMode=ICON""LastUIMode=ICON""ModeSwitchKey=F11""EnableJoNukta=NO""OldStyleReph=YES""VowelFormating=YES""NumPadBangla=YES""AutomaticallyFixChandra=YES""FullOldStyleTyping=YES""DefaultLayout=Bijoy2003""OutputIsBijoy=NO") DO FOR /F "tokens=1,2 delims==" %%B IN (%%A) DO (ECHO REG ADD "%My_Reg_hive%" /V %%B /D %%C /F)

jaclaz

Link to comment
Share on other sites

When an user logs on, a "common to all" key:

HKLM\Software\Microsoft\Active Setup\Installed Components\<UID>

is compared to a corresponding "per user" key:

HKCU\Software\Microsoft\Active Setup\Installed Components\<UID>

 

If the HKCU key is not found the contents of the string value StubPath is executed. The HKLM key is then copied to HKCU. 

 

 

In your case you would add something like:

 

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\KaliOmicronLab]

@="Kali's OmicronLab Avro Keyboard"

"StubPath"="avro.cmd" 

 

When each user logs in for the first time (and for the first time only) the file avro.cmd will be executed, of course under the current user credentials, so all you need is to make a .cmd that adds those Registry entries to HKCU and make sure it is in the PATH or provide a path to it in the above key.

I’ve understood Active Setup. Your link and description helped me very much to understand. I tried Active Setup in two ways (screenshot attached). None of them is working. May be my fault.

 

The avro.cmd could be something *like*:

@ECHO OFFSETLOCAL ENABLEEXTENSIONSSET My_Reg_hive=HKCU\Software\OmicronLab\Avro KeyboardFOR %%A IN ("ChangeInputLocale=YES""PrefferedLocale=BANGLADESH""AvroUpdateCheck=NO""DontShowComplexLNotification=NO""DontShowStartupWizard=NO""StartWithWindows=YES""ShowSplash=NO""DefaultUIMode=ICON""LastUIMode=ICON""ModeSwitchKey=F11""EnableJoNukta=NO""OldStyleReph=YES""VowelFormating=YES""NumPadBangla=YES""AutomaticallyFixChandra=YES""FullOldStyleTyping=YES""DefaultLayout=Bijoy2003""OutputIsBijoy=NO") DO FOR /F "tokens=1,2 delims==" %%B IN (%%A) DO (ECHO REG ADD "%My_Reg_hive%" /V %%B /D %%C /F)

It’s not working. I attached my final bat file for your kind concentration. I added a run once command here to work for all users. I think it’s not working. What’s your advice about this?

post-322156-0-52526400-1416589278_thumb.

post-322156-0-56403900-1416589287_thumb.

Avro_Silent_Final.txt

Link to comment
Share on other sites

The first (image on the left) attempt makes no sense.

 

The one on the right seems like fine at first sight.

 

But maybe you are trying to do too many things at once, try to ONLY follow the given example, EXACTLY:

https://helgeklein.com/blog/2010/04/active-setup-explained/

 

I.e., see if you can succeed to run notepad as in the example.

 

Just for the record, batch files on NT systems should really have .cmd extension (and not .bat).

 

About the example batch I posted, what do you mean by "it is not working"?

 

jaclaz

Link to comment
Share on other sites

The first (image on the left) attempt makes no sense.

 

The one on the right seems like fine at first sight.

 

But maybe you are trying to do too many things at once, try to ONLY follow the given example, EXACTLY:

https://helgeklein.com/blog/2010/04/active-setup-explained/

 

I.e., see if you can succeed to run notepad as in the example.

 

Just for the record, batch files on NT systems should really have .cmd extension (and not .bat).

  

jaclaz

I’m really sorry to disturb you too much. I got the solution. I added my reg settings 1st and then I added admin user command. So my Avro.exe is running with administrative mode but reg is running with active user/logon user/running user. I added command to run reg with admin at last also. I attached my batch.

 

About the example batch I posted, what do you mean by "it is not working"?

I tested it but the settings is not being applied. I think your command will work when it'll be run normally. But my problem was running the the batch file with administrator from standard user

Avro_Silent_Working.txt

Link to comment
Share on other sites

 

About the example batch I posted, what do you mean by "it is not working"?

I tested it but the settings is not being applied.

Sure they are not:

...

ECHO REG ADD "%My_Reg_hive%" /V %%B /D %%C /F

...

 

the batch as I posted it only prints on screen the commands.

 

jaclaz

Link to comment
Share on other sites

@ECHO OFFSETLOCAL ENABLEEXTENSIONSSET My_Reg_hive=HKCU\Software\OmicronLab\Avro KeyboardFOR %%A IN ("ChangeInputLocale=YES""PrefferedLocale=BANGLADESH""AvroUpdateCheck=NO""DontShowComplexLNotification=NO""DontShowStartupWizard=NO""StartWithWindows=YES""ShowSplash=NO""DefaultUIMode=ICON""LastUIMode=ICON""ModeSwitchKey=F11""EnableJoNukta=NO""OldStyleReph=YES""VowelFormating=YES""NumPadBangla=YES""AutomaticallyFixChandra=YES""FullOldStyleTyping=YES""DefaultLayout=Bijoy2003""OutputIsBijoy=NO") DO FOR /F "tokens=1,2 delims==" %%B IN (%%A) DO (ECHO REG ADD "%My_Reg_hive%" /V %%B /D %%C /F)

jaclaz

 

I can understand all normal batch command but complex. For example your command bellow. I like batch command to use. Would you please give me some important links about how to learn pipeline and complex command you used I've given bellow?

 

) DO FOR /F "tokens=1,2 delims==" %%B IN (%%A) DO (

ECHO REG ADD "%My_Reg_hive%" /V %%B /D %%C /F

)

Edited by kali
Link to comment
Share on other sites

Actually there is nothing particularly complex in the above batch.

 

It is a rather basic use of FOR .

 

See these pages:

http://www.robvanderwoude.com/ntfor.php

http://www.robvanderwoude.com/ntfortokens.php

 

The first FOR loop simply runs through all the items of the list, which I created by simply replacing "=" with = in the list you posted on #23:

http://www.msfn.org/board/topic/173033-administrative-user-doesn’t-write-registry-settings-in-hkey-current-user/#entry1089363

giving to the %%A variable the value of items in the list.

The second FOR loop uses the /F switch and tokens and delims to separate the first part (name) from the second part (value), assigning them to the variable %%B and %%C.

 

This is a slightly more complex (or simplified :unsure:) version of the same batch, this time using a single FOR /F loop and some piping:

 

 

@ECHO OFFSETLOCAL ENABLEEXTENSIONSSET My_Reg_hive=HKCU\Software\OmicronLab\Avro KeyboardFOR /F "tokens=1,2 delims=:=" %%A IN ('TYPE %~dpnx0 ^|FIND "::" ^|FIND /v "FIND"') DO ECHO REG ADD %My_Reg_hive% /V %%A /D %%B /F::ChangeInputLocale=YES::PrefferedLocale=BANGLADESH::AvroUpdateCheck=NO::DontShowComplexLNotification=NO::DontShowStartupWizard=NO::StartWithWindows=YES::ShowSplash=NO::DefaultUIMode=ICON::LastUIMode=ICON::ModeSwitchKey=F11::EnableJoNukta=NO::OldStyleReph=YES::VowelFormating=YES::NumPadBangla=YES::AutomaticallyFixChandra=YES::FullOldStyleTyping=YES::DefaultLayout=Bijoy2003::OutputIsBijoy=NO
 

 

jaclaz

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...