Change Registry key via batch file - batch-file

How can I change this registry key in my batch file?
HKEY_LOCAL_MACHINE\SOFTWARE\CONFIGURATION
Name Type Data
Default REG_SZ ServerA
That is an example regkey, but the result I am looking for is the same. I would like to change the "ServerA" to "ServerB"
Would this be the correct syntax?
reg add "hkey_local_machine\software\configurations" /t REG_SZ /v Default /d ServerB
And is there also a way to run this with command priveleges?

Related

Why does this bat file not execute properly?

I need to add a subkey in the registry of Windows 10 with a .bat script, but the results are not what is expected. Code does produce a result, but creates an incorrect entry. I need a subkey named EnableLinkedConnections that is of the type: REG_DWORD with a data value of 1
I have already written a .bat to add entries which are correct, but trying to add another in a different registry folder creates an incorrect entry.
#echo off
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\" /f /v "EnableLinkedConnections" /t REG_DWORD d/ 0x1
pause
This creates a folder outside of the System folder, but still in the Policies folder named:
System" /f /v EnableLinkedConnections /t REG_DWORD d/ 0x1
which is not correct. I expected a subkey entry of type REG_DWORD.
Seems that its having an issue with backslashes maybe, but the other .bat I wrote does not do this, so a bit stumped. Any pointers welcome.

Add registry from bat file

I am trying to add registry entry from bat file. I have a reg file that contains
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel]
"HomePage"=dword:00000001
It works if you double click the reg file. However, I need to make the same registry edit from bat file. I have tried this
reg add HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel /v HomePage /t REG_DWORD /d 0 /f
But doesnt work. What is the correct way to do that ? (except running .reg file from bat file)
Put quotes around the key name.
reg add "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel" /v HomePage /t REG_DWORD /d 0 /f
Because "Internet Explorer" and "Control Panel" contain spaces, you need quotes so it is all treated as one parameter.

Batch File to Adjust Registry with Contents of Text File

Here's what I'm trying to accomplish:
I'd like an end-user to be able to type their updated AD password into a Text file, then run a Batch which adjusts the registry with the user's updated AD Password to configure Auto-Login to Windows. After the Registry is updated, I'd like the contents of the Text file cleared.
The purpose of this is so users can re-configure their Auto-Logon themselves after they change their passwords (which expire every 90-days in my environment).
How can I pull the text out of the Text file and apply it to a Reg key? Alternatively, is there a way that the Batch file can simply prompt for their new password, so I can avoid using the Text file all together?
Thanks in advance,
Cameron
I would use something like the following. It prompts for the password, rather than using the text file. It also uses the current logged in user name. Please note that this stores the users domain password in clear-text in the registry where anyone with access to the machine can read it. This is VERY insecure, though there can be reasons to use it. I would offer my opinion that if you're doing this with domain passwords, this is probably the wrong thing to do.
#Echo off
setlocal
set /p PWD= Enter your password:
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /f /v DefaultUserName /t REG_SZ /d %USERNAME%
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /f /v DefaultPassword /t REG_SZ /d %PWD%
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /f /v AutoAdminLogon /t REG_SZ /d 1
endlocal

Change regional and language options in BATCH

How can I change the regional and language options in Windows XP and 7 using batch code?
I want to change the "Standards and formats" to Mexican Spanish with a .bat file.
Those settings are in the registry under HKCU\Control Panel\International
You can use reg.exe to make the changes manually. The easiest way to do that is to manually change your region and language to spanish (mexico) open a cmd window and type reg query "HKCU\Control Panel\International" which will show you the values as you want them. Then to modify them, use REG ADD "HKCU\Control Panel\International" /t REG_SZ /v LocaleName /d es-Mx /f for each value replacing what is after /v with the appropriate name and what is after /d with the appropriate value.
The other option is to just export the HKCU\Control Panel\International hive to a .reg file and just import it into the registry using regedit /s ImportFile.reg
You may need to refresh the registry after the import to see the changes. This usually involves a reboot but try adding the following as the last line in your batch file instead. RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True

Registry Duplicate Key

So I am writing one of my first large batch scripts and part of the script needs to create several keys in the registry. The problem I am having is that a redundant subordinate key is being created in the path and I am not sure how to solve it. Also of note is that this only occurs on certain systems and is not always the case.
Here is the command I am using:
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Riedel\ARTIST SNMP Agent" /v "MasterSnmpAgentIpAddr" /t REG_SZ /d "127.0.0.1:705"
When I look in the registry to see the result, here is the path that it is placed in:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Wow6432Node\Riedel\ARTIST SNMP Agent
I've tried a few methods of creating registry keys, but they yield the same results. Any thoughts or help would be appreciated. Thanks!
Wow6432Node is for the 32bit programs in 64bit OS. So you should better use the reg add switch /reg:
try this for 32bit entries
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Riedel\ARTIST SNMP Agent" /v "MasterSnmpAgentIpAddr" /t REG_SZ /d "127.0.0.1:705" /reg:32
and for 64bit
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Riedel\ARTIST SNMP Agent" /v "MasterSnmpAgentIpAddr" /t REG_SZ /d "127.0.0.1:705" /reg:64

Resources