hi,
Disable Regedit
REG add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableRegistryTools /t REG_DWORD /d 1 /f
Enable Regedit
REG add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableRegistryTools /t REG_DWORD /d 0 /f
I want to create batch file as below:
[1] Run Regedit
My pc was restrict to run regedit unless i enable it back at registry via REG command. I want to do like this:
once user choose [1], batch will check the value of existing registry of user pc. if the existing value is 1, then batch will change value to 0..then it will call the regedit program. after user finished with regedit and close it, the batch will automatically change the value to 1
but when user choose [1], batch check the existing registry of user pc if the existing value is 0, the value will still remain then batch will call the regedit program. after user finished with regedit and close it, batch will close the regedit itself.
simple wors:
if user pc is registry disable, the option [1] will temporary make it enable until user finished used it and it when change ti disable mode again.
if user pc is registry enable, nothing will be change
help me how to code this...
batch for if else to check regedit
Moderator: DosItHelp
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Well, you use a reg query command to get the current value, then you set the value, then you launch regedit, then you set the value to the original value.
Completely untested something like this:
Completely untested something like this:
Code: Select all
set "key=HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System"
for /f "tokens=2 delims=x" %%a in ('reg query "%key%" /v DisableRegistryTools') do set
value=%%a
reg add "%key%" /v DisableRegistryTools /t REG_DWORD /d 0 /f
start regedit
if defined value (
reg add "%key%" /v DisableRegistryTools /t REG_DWORD /d %value% /f
) else (
reg delete "%key%" /v DisableRegistryTools /f
)