whoam
asked on
Batch File to Edit Registry
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.
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
Contents of HCP.reg are as follows...
Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\HCP]
My guess is that it's a permisions issue.. when you run it from a network are you doing it under your account? Also when dealing with things like scripts you should always put the entire path in every reference to avoid things going where you don't want them to.. if you don't the default path will be used...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.