How to Create Registry key using a batfile

25,814

Solution 1

You can use the Windows built-in command line tools, either regedit.exe or reg.exe, see:

Solution 2

Yes u can create Registry Key using Batch file

here is an example:

for disabling task manager using .bat file:

reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /f /v DisableTaskMgr /t REG_DWORD /d 1

for enabling task manager:

reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableTaskMgr /f

You can take Help by entering reg/? in command prompt for various options.

Enjoy.........

Share:
25,814
Simsons
Author by

Simsons

Love to write programs . Still learning and trying to explain the code to my self and others.

Updated on July 09, 2022

Comments

  • Simsons
    Simsons almost 2 years

    Need to Create a Registry Key using bat file.Can I create Reg Key using Command prompt or a bat file.

    The main purpose behind this , I want to create envoirment variable using bat file.

    • steinar
      steinar over 13 years
      Wouldn't this rather belong on serverfault.com? Anyway, I would check out Powershell (or run a vbs script).
    • Rich
      Rich over 13 years
      Because registry manipulation from a batch file can be painful. However, many people do not realize that blindly suggesting PowerShell/VBS/Cygwin/Gnuwin32/whatever is not always an answer. Still, in your case I wouldn't even touch the registry directly.
  • Chris Smith
    Chris Smith over 13 years
    Environment variables (what you're setting in your example) are different from registry keys.
  • Simsons
    Simsons over 13 years
    It seems SETX is specific to Windows 7
  • Rich
    Rich over 13 years
    It's been in core Windows since at least Vista. Having never used XP I have no idea as how that is on legacy systems. It was part of a Resource kit previously. Furthermore, you never said anything about an OS restriction, so I assumed something recent.
  • Will03uk
    Will03uk over 13 years
    But his main purpose is to set environment variables