.bat/.cmd 스크립트를 통해 레지스트리 항목을 수정할 수 있습니까?
-
02-07-2019 - |
문제
.bat/.cmd 스크립트를 통해 레지스트리 값(문자열 또는 DWORD)을 수정할 수 있습니까?
해결책
reg 명령을 사용할 수 있습니다. 에서 http://www.ss64.com/nt/reg.html:
Syntax:
REG QUERY [ROOT\]RegKey /v ValueName [/s]
REG QUERY [ROOT\]RegKey /ve --This returns the (default) value
REG ADD [ROOT\]RegKey /v ValueName [/t DataType] [/S Separator] [/d Data] [/f]
REG ADD [ROOT\]RegKey /ve [/d Data] [/f] -- Set the (default) value
REG DELETE [ROOT\]RegKey /v ValueName [/f]
REG DELETE [ROOT\]RegKey /ve [/f] -- Remove the (default) value
REG DELETE [ROOT\]RegKey /va [/f] -- Delete all values under this key
REG COPY [\\SourceMachine\][ROOT\]RegKey [\\DestMachine\][ROOT\]RegKey
REG EXPORT [ROOT\]RegKey FileName.reg
REG IMPORT FileName.reg
REG SAVE [ROOT\]RegKey FileName.hiv
REG RESTORE \\MachineName\[ROOT]\KeyName FileName.hiv
REG LOAD FileName KeyName
REG UNLOAD KeyName
REG COMPARE [ROOT\]RegKey [ROOT\]RegKey [/v ValueName] [Output] [/s]
REG COMPARE [ROOT\]RegKey [ROOT\]RegKey [/ve] [Output] [/s]
Key:
ROOT :
HKLM = HKey_Local_machine (default)
HKCU = HKey_current_user
HKU = HKey_users
HKCR = HKey_classes_root
ValueName : The value, under the selected RegKey, to edit.
(default is all keys and values)
/d Data : The actual data to store as a "String", integer etc
/f : Force an update without prompting "Value exists, overwrite Y/N"
\\Machine : Name of remote machine - omitting defaults to current machine.
Only HKLM and HKU are available on remote machines.
FileName : The filename to save or restore a registry hive.
KeyName : A key name to load a hive file into. (Creating a new key)
/S : Query all subkeys and values.
/S Separator : Character to use as the separator in REG_MULTI_SZ values
the default is "\0"
/t DataType : REG_SZ (default) | REG_DWORD | REG_EXPAND_SZ | REG_MULTI_SZ
Output : /od (only differences) /os (only matches) /oa (all) /on (no output)
다른 팁
@Franci Penov- 수정 ~이다 의미에서 가능합니다 덮어 쓰기 ~와 함께 /f
, 예를 들어
reg add "HKCU\Software\etc\etc" /f /v "value" /t REG_SZ /d "Yes"
예, 당신은 그것을 사용하여 스크립트 할 수 있습니다 reg
명령. 예시:
reg add HKCU\Software\SomeProduct
reg add HKCU\Software\SomeProduct /v Version /t REG_SZ /d v2.4.6
이것은 키를 만들 것입니다 HKEY_CURRENT_USER\Software\SomeProduct
, 문자열 값 "v2.4.6"명명 된 "버전"을 해당 키에 추가하십시오.
reg /?
세부 사항이 있습니다.
예 또는 아니오 프롬프트없이 레지스트리를 수정할 수있는 방법입니다. 관리자로 실행하는 것을 잊지 마십시오.
reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\etc\etc /v Valuename /t REG_SZ /d valuedata /f
아래는 Internet Explorer를 기본 브라우저로 설정하는 실제 예입니다.
reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice /v ProgId /t REG_SZ /d IE.HTTPS /f
/f force : "값이 존재하고, y/n을 덮어 쓰고"프롬프트하지 않고 업데이트를 강제로합니다.
/d 데이터 : "문자열", 정수 등으로 저장할 실제 데이터
/v 값 : 값 이름 예, 예 : 프로 게드
/t 데이터 유형 : reg_sz (기본값) | reg_dword | reg_expand_sz | reg_multi_sz
레지스트리 키 및 값을 읽고 설정 또는 삭제하고 .reg 파일에서 저장 및 복원에 대해 자세히 알아보십시오. ~에서 여기
.reg 파일을 만들고 시작을 시작할 수 있습니다. 레지스트리의 모든 부분을 .reg 파일로 내보내서 형식이 무엇인지 확인할 수 있습니다.
여기에 형식 :
http://support.microsoft.com/kb/310516
다른 소프트웨어를 설치하지 않고 모든 Windows 시스템에서 실행할 수 있습니다.
예.OS와 함께 제공되는 reg.exe를 사용하여 레지스트리 값을 추가, 삭제 또는 쿼리할 수 있습니다.Reg.exe에는 명시적인 수정 명령이 없지만 삭제한 다음 추가하면 됩니다.
Reg.exe 외에도 PowerShell을 확인하는 것이 좋습니다.