Clear the PendingFileRenameOperations registry value - batch-file

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

Related

NSIS with admin access fails to create reg key via batch script

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.

How to add string value to Windows registry?

I want to add this new registry entry via cmd/batch file to run CMD always as administrator. I know I can add it by navigating to the mentioned path in the command. But I want to add it in one of my batch files. And I think to add string value I need to modify my cmd. I am missing something here :-
reg.exe ADD \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers /t REG_SZ "C:\\WINDOWS\\system32\\cmd.exe"="RUNASADMIN" /f
Can anyone help me with this please?
The command line to use in a batch file executed by 64-bit cmd.exe on Windows x64 or 32-bit cmd.exe executed on Windows x86 running under elevated environment of a local administrator is:
%SystemRoot%\System32\reg.exe ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /f /t REG_SZ /v "C:\WINDOWS\system32\cmd.exe" /d "RUNASADMIN"
Open a command prompt window and run reg /? and next reg add /? for help on used command REG for adding a string value to Windows registry.

Manipulate registry settings on a Win CE 7 System with a Batch file

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

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