I would like to change the registry path's value from 0 to 1:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background\OEMBackground
Is there any possible way of doing this within a batch file using the "reg" command? You can grab the syntax here . I searched it, but can not find a way to modify it. Any help would be greatly appreciated. Thanks!
I would stay away from reg.exe, it can be blocked by a policy. I suggest to use wmic.exe. In your case it should works like this:
setlocal
:: $KEY broken for better readability
set "$KEY=SOFTWARE\Microsoft\Windows\CurrentVersion"
set "$KEY=%$KEY%\Authentication\LogonUI\Background"
set "$VALNAME=OEMBackground"
set "VAL=1"
set "HIVE=&H80000001" &:: "&H80000001 = HKEY_LOCAL_MACHINE"
wmic.exe /NAMESPACE:\\root\default Class StdRegProv Call^
SetDWORDValue^
hDefKey="%HIVE%"^
sSubKeyName="%$KEY%"^
sValueName="%$VALNAME%"^
uValue="%VAL%"^
&& echo Success.||echo failed.
endlocal
To select another registry-hive, the value of hDefKey must be changed accordingt to this MSDN-Article . Other Methods for different value types which can be used instead of SetDWORDValue can be found there as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.