3

I have made a .reg file where I set certain registry values. but I need to have a printout of situation before and after.

So how can I easily read out all reg values (within this regfile)? And is it possible to fill in a registry value with %computer name% so that this registry will use the current computer name for example:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\WinLogon
"AutoAdminLogon"="REG_SZ:1"
"AutoLogonDomain"="REG_SZ:%ComputerName%"
"AutoLogonUser"="REG_SZ:User1"
"DefaultDomain"="REG_SZ:%ComputerName%"
"DefaultDomainName"="REG_SZ:%ComputerName%"
"DefaultUsername"="REG_SZ:User1"
clhy
  • 6,514
Joep
  • 55

2 Answers2

1

this worked for me: REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon >nul if %errorlevel% equ 0 echo key AutoAdminLogon exists || key AutoAdminLogon does not exist but still need the add function when it not exists to create the registrykey...

Joep
  • 55
0

I'm by no means an expert but I hope I can help you out :)
I've thrown together a batch file with the help of various sites and answers from here.
This script reads the current registry values and prints them out to the console.
Then it adds the registry values with your desired values and prints them again so you can see the changes.
I am pretty sure that you can optimize it a lot but it should be enough for giving you a start.

@echo OFF
echo "Current values..."
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoLogonDomain
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoLogonUser
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomain
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUsername

echo "Now performing the changes..."
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /f /v AutoAdminLogon /t REG_SZ /d 1

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /f /v AutoLogonDomain /t REG_SZ /d %ComputerName%

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /f /v AutoLogonUser /t REG_SZ /d User1

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /f /v DefaultDomain /t REG_SZ /d %ComputerName%

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /f /v DefaultDomainName /t REG_SZ /d %ComputerName%

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /f /v DefaultUsername /t REG_SZ /d User1

echo "Printing out new values..."
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoLogonDomain
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoLogonUser
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomain
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUsername
pause

Copy it to a text file and change the file ending to .cmd
The following sites helped me to create it - you might want to have a look at it:
How to find the PCs name in a batch script?
Adding key to registry
Reading NT's Registry with REG Query Is it possible to modify a registry entry via a .bat/.cmd script?

benjamin
  • 483