jasonsandys

Setting a Registry Value in Every User’s Profile

Jul 24th, 2018
5,695
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.97 KB | None | 0 0
  1. ECHO OFF
  2. SETLOCAL EnableDelayedExpansion
  3.  
  4. SET DEST="%~1"
  5. ECHO %DEST%
  6.  
  7. FOR /f "tokens=*" %%G in ('dir /b /a:d-s-l "%SystemDrive%\Users"') DO (
  8.     IF /I NOT "%%G"=="Public" (
  9.  
  10.         reg.exe load HKU\XYZ "%SystemDrive%\Users\%%G\NTUser.dat"
  11.  
  12.         IF NOT ERRORLEVEL 1 (
  13.  
  14.             call :regchanges XYZ
  15.  
  16.             reg.exe unload HKU\XYZ
  17.         )
  18.     )
  19. )
  20.  
  21. FOR /f "tokens=1,2 skip=1" %%G IN ('wmic.exe PATH Win32_UserProfile get loaded^,sid') DO (
  22.     IF /I "%%G"=="True" (
  23.         set sid=%%H
  24.  
  25.         IF /I "!sid:~0,8!"=="S-1-5-21" (
  26.            
  27.             call :regchanges !sid!            
  28.         )
  29.     )
  30. )
  31.  
  32. exit /b
  33.  
  34. :regchanges
  35.  
  36. REM reg.exe add "HKU\%1\..." /v ... /t ... /d ... /f
  37.  
  38. reg.exe add "HKU\%1\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v Win10UpgradeMessage /t REG_SZ /d "cmd.exe /c start /D %DEST% UI++64.exe /config:UpgradeInProgress.xml" /f
  39.  
  40. REM reg.exe add "HKU\%1\Software\Temp3" /v TempValue /t REG_SZ /d "A sub Test" /f
Advertisement
Add Comment
Please, Sign In to add comment