Re: Change registry for all users of a machine

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi

Personally, I think the best way of doing it would depend on his setup, but he never clarified it.

Mats wrote:

you can do it in two other ways too

the easiest solution to this is to create a simple batch that runs a
regfile. The regfile should contain the values to be changed for current
user.

The batchfile should be something like regedit /S regfile.

Place the batch i n all user startup and it will apply the regchange every
time a user logs on.

The more complex version  would use a more advanced batch or vbscript to
read a key first  to check if the update has been applied. if the check
fails it applies the uppdate and sets the check key to indicate that the
update is complete for this user


"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@xxxxxxxxx> wrote in message news:u340lE3lFHA.3256@xxxxxxxxxxxxxxxxxxxxxxx

Hal Berenson wrote:


We need to apply a change to the registry for all user accounts on a PC,

and

we'd like to automate the process. We don't have access to their

machines

directly, so they need something they run from a privileged account that
adds this key for all user accounts.  The key itself (.reg listed below)

is

defined as being in HKCU. So the question is, is there a place one can

make

this change in the registry and have it propagated to all users under

HKU?

Or would I need to write a script to loop through HKU and apply it to

all

the existing users?


Hi,

You will need to enumerate all the user profile folders, and load each
user's NTUSER.DAT in a temporary hive and adding the registry value
(using reg.exe that comes builtin with WinXP).

Here is a batch file that will set the registry value FilterQueueType
to hex ffffffff (REG_DWORD) on all user accounts on the computer. You
will of course need to run the batch file under an user account that
have local admin privileges.

--------------------8<----------------------
@echo off
setlocal

set regcmd=%SystemRoot%\system32\reg.exe
set keypath=Software\Microsoft\Terminal Server Client\Default\AddIns\RDPDR
set valuename=FilterQueueType

:: update current user
set hive=HKCU
set key=%hive%\%keypath%
%regcmd% add "%key%" /v %valuename% /d 0xffffffff /t REG_DWORD /f >nul

:: update all other users on the computer, using a temporary hive
set hive=HKLM\TempHive
set key=%hive%\%keypath%

:: set current directory to "Documents and Settings"
cd /d %USERPROFILE%\..
:: enumerate all folders
for /f "tokens=*" %%i in ('dir /b /ad') do (
  if exist ".\%%i\NTUSER.DAT" call :AddRegValue "%%i" ".\%%i\NTUSER.DAT"
)

endlocal
echo.
echo Finished...
echo.
pause

goto :EOF

:AddRegValue
set upd=Y
if /I %1 equ "All Users" set upd=N
if /I %1 equ "LocalService" set upd=N
if /I %1 equ "NetworkService" set upd=N

if %upd% equ Y (
  %regcmd% load %hive% %2 >nul 2>&1
  %regcmd% add "%key%" /v %valuename% /d 0xffffffff /t REG_DWORD /f >nul

2>&1

  %regcmd% unload %hive% >nul 2>&1
)


--------------------8<----------------------



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx





--
Gerry Hickman (London UK)
.



Relevant Pages

  • Re: Change registry for all users of a machine
    ... The regfile should contain the values to be changed for current ... Place the batch i n all user startup and it will apply the regchange every ... >> We need to apply a change to the registry for all user accounts on a PC, ... > @echo off ...
    (microsoft.public.windowsxp.setup_deployment)
  • Re: Change registry for all users of a machine
    ... >> We need to apply a change to the registry for all user accounts on a PC, ... > @echo off ... > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ...
    (microsoft.public.windowsxp.setup_deployment)
  • Re: Persisting env vars in cmd windows
    ... But the piece de resistance was the "start" command, ... - Have all code for the one project in one single batch file. ... @echo off ... echo:: ERROR ERROR ERROR ERROR ...
    (microsoft.public.win2000.general)
  • Re: Batch File to manipulate path and file name
    ... It should process any "poison" characters ... # echo Full name=%%a ... If you object to requiring two files to achieve your aim (one batch, ... How do I get from Input File Name to Output File Name Desired? ...
    (microsoft.public.windowsxp.general)
  • Re: File Size Check
    ... the batch ended and was done. ... del para2.txt ... echo open ... SLEEP is part of the WinNT/2K/XP/2003 Resource Kit and not a ...
    (microsoft.public.scripting.vbscript)