We help IT Professionals succeed at work.
Get Started

Batch File to Edit Registry

585 Views
Last Modified: 2012-05-09
Okay, I have a really simple script.  It runs from local storage just fine, but from a network locaiton, it fails with no error.

The batch file backup up a reg key, then calls a .reg to remove the offending key.

Having the script pause at each step reveals no errors.

Like I said, run it locally, it works, run it from a network location it silently fails.  One note, when run locally it creates a new .reg for the undo in the folder with the existing .reg below and teh existing .bat below.  From a network location it creates no new .reg.  I'm not sure if it needs a place to stick the new .reg, but I don't know how to give it a target in the script.
rem first, back up the registry key so it can later be restore.
Regedit.exe /e HCP_Protocol_Backup.reg HKEY_CLASSES_ROOT\HCP
rem pause

rem next, remove the vulnerable registry key.
Regedit.exe /s HCP.reg
rem pause

rem finally, restore the vulnerable key one the vendor patch is avaiable
rem Regedit.exe /s HCP_Protocol_Backup.reg

Open in new window

Contents of HCP.reg are as follows...

Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\HCP]

Open in new window

Comment
Watch Question
Sr. Systems Engineer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE