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
Related
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?
I have a NSIS script with RequestExecutionLevel admin set and within this I invoke a .bat script which adds a reg key.
When the batch-file is executed through command-prompt the reg key gets added. But when running the installer, it executes the .bat file but fails to add the reg key.
nsExec::ExecToStack '"$pluginsdir${SETUP_PATH}\UpdateNtpConfiguration.bat" $Ip1'
UpdateNtpConfiguration.bat content
set adds=%1
REM Get the list of ntp servers showing up in System Date & Time->Internet Time dropdown
set "num=0"
for /F %%G in ('reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers ^| findstr "^[^a-z] ^("') do if %%G GTR !num! set "num=%%G"
set /A num=num + 1
REM Add address at the end
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers /v "%num%" /t REG_SZ /d "%adds%" /f
goto:eof
Just like #Anders said, there are built in functions for that.
https://nsis.sourceforge.io/Docs/Chapter4.html#registry
If an an error happens with this command, it will be a lot easier to debug as it is built-in.
If you're not doing anything else in the batch file, it is better to find out if NSIS has a command already integrated with it....
EDIT:
It also might be that the admin installer is run the bat file without admin privs.
After some debugging found out that NSIS was writing the registry values in 32 bit reg space(HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft). I had to append /reg:64 to make it add to the 64 bit reg space.
Also the reason I had the bat script was to have some logic to look for duplicates before adding the key.
One of my troubleshooting steps is to clear the PendingFileRenameOperations registry value to avoid rebooting a server.
What I would like to do is clear this through a batch file, I don't want to delete it, just clear it.
It's the following registry value
HKEY_LOCAL_MACHINE/SOFTWARE/Session Manager/PendingFileRenameOperations
The command
%SystemRoot%\System32\reg.exe add "HKLM\System\CurrentControlSet\Control\Session Manager" /v PendingFileRenameOperations /t REG_MULTI_SZ /d "" /f
replaces current value of multi-string value PendingFileRenameOperations with an empty string.
The path you wrote in the question does not exist on my Windows 7 x64 machine.
For details on command reg open a command prompt window and run there first reg /? and second reg add /?
But why clearing this registry value used to delete or replace (usually update) files after reboot before Windows loads drivers and starts processes and applications should avoid rebooting a Windows server is beyond my understanding.
Some software just checks for the key existence and doesn't care if its blank,So For deleting Key,Use My Way :
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager" /v PendingFileRenameOperations /f
I got a problem with manipulating my registry settings. I use a Panel PC with windows embedded compact version 7 (Win Ce). I want change the display-brightness, which is set on "HKEY_CURRENT_USER\ControlPanel\BackLight", by a BAT file. I use following syntax:
reg add "HKCU\ControlPanel\BackLight" /T REG_DWORD /F /D 150 /V ACBacklightLevel
But when I run the file, the error message : "Cannot execute reg.exe"
I tried the Bat File on my PC with windows 7. It works correctly.
Is there a problem with the command "reg add" on Win CE systems? Did i make another mistake?
Thanks in advance
Frank
edit:
I´m not sure if this is important, but I use in the header of my BAT file the line "REGEDIT4". I read in other forum that it is for WIN98, NT and 4.0. But there isn´t any command fpr windows CE. Do you know what it does?
edit 23.04.2015:
I created a .reg file, which increases the brightness of my HMI. It worked when I import it manually. Is it possible to import it automatically via Batch file or something like that? someone know the syntax of this command or got another idea how to do this?
the correct command line is (you must use the cmd):
REG ADD "HKCU\Control Panel\BackLight" /v "ACBacklightLevel" /t REG_DWORD /d 150 /f
for the next time:
REG ADD "Register key name" /v "key name" /t "type" /d "type value" /f
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