Windows: Custom multi-user multi-registry key script

Source: Internet
Author: User

This is the key.MultipleWord.

Let's take a look at the customization process of a single registry key:

reg load HKU\TempHive C:\Users\Default\NTUSER.datreg import Sample.regreg unload HKU\TempHive

The following script can process multiple Reg files for the default user.

REG load HKU\TempHive "C:\Users\Default\NTUSER.DAT" > nulfor /F "delims=*" %%i in ('dir /A /B *.reg') do REG import "%%i" >nulREG unload HKU\TempHive >nul

 

The following are multiple Reg files that process multiple users.

for /F "delims=*" %%i in ('dir /A /B %SystemDrive%\Users') do CALL :ModUserRegs "%%i" TempRegs > nulgoto End:ModUserRegs   IF "%USERNAME%" == "%~1" (      Echo  %1 is Current user.   ) ELSE (      IF EXIST "%SystemDrive%\Users\%~1\NTUSER.DAT" (         REG load HKU\TempHive "%SystemDrive%\Users\%~1\NTUSER.DAT" > nul         for /F "delims=*" %%i in ('dir /A /B ^"%~d0%~p0TempRegs\*.reg^"') do REG import "%~2\%%i" >nul         REG unload HKU\TempHive >nul         Echo  %1 is done.      ) ELSE (         Echo  %1 isn't a user.      )   )goto :eof

 

Finally, the following is a complete batch script with the logging function:

ECHO OFF:: ---------------------------------------------------------------------------------------:: Modify All and Default User Registry:: Version: 1.1:: Copyright Tony Liu, 2012:::: History:::    Initial: May 22, 2012 Tony Liu:::: Description: It imports all defined registry into all system users NTUSER.DAT registry hive including Default User.:::: How TO:::    Put exported registry files, .reg files, in TempRegs folder and change all the [HKEY_CURRENT_USER] root to [HKEY_USERS\TempHive] in .reg files.:: ---------------------------------------------------------------------------------------Echo ---------------------------------------------------------------------------- >> History.logEcho : Modify All and Default User Registry : >> History.logEcho : Start: %time%, %date% >> History.logEcho : Windows Version:  >> History.logsysteminfo | find "OS Name" | find "Windows 7" >> History.logif %ERRORLEVEL% NEQ 0 goto EndIF Not Exist TempRegs (   Echo Error: .\TempRegs folder not exist. >> History.log   goto End):: for /F "delims=," %%i IN (UserList.txt) do echo "%%i"for /F "delims=*" %%i in ('dir /A /B %SystemDrive%\Users') do CALL :ModUserRegs "%%i" TempRegs > nulgoto End:ModUserRegs   IF "%USERNAME%" == "%~1" (      Echo  %1 is Current user. >> History.log   ) ELSE (      IF EXIST "%SystemDrive%\Users\%~1\NTUSER.DAT" (         REG load HKU\TempHive "%SystemDrive%\Users\%~1\NTUSER.DAT" > nul::         for /F "delims=*" %%i in ('dir /A /B ^"%~d0%~p0TempRegs\*.reg^"') do REG import "%~2\%%i" >nul         REG unload HKU\TempHive >nul         Echo  %1 is done. >> History.log      ) ELSE (         Echo  %1 isn't a user. >> History.log      )   )goto :eof:EndEcho : End: %time%, %date% >> History.logEcho ---------------------------------------------------------------------------- >> History.loggoto :eof

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.