/build/static/layout/Breadcrumb_cap_w.png

Delete reg key with random path

I need to delete a registry key from HKCU for the ActiveSync deployment I am working on. Easy enough with say Kix and DELKEY, but the Activesync software which creates the keys, randomly assigns one of the keys. Can a script be written to work out the full path to the key I want to delete, when a part of is different for every install.

e.g
One example is
HKCU\Software\Microsoft\Windows CE Services\Partners\497c4832\Services\Synchronization\Objects\Merlin Mail

The 497c4832 is the part that is random and Merlin Mail is the section I need to delete. If it helps there are no other keys created under Partners, though there are plenty of keys created with the lower sections.

The script could be kix or vbscript

Thanks in advance

0 Comments   [ + ] Show comments

Answers (3)

Posted by: KPrinz 19 years ago
Fourth Degree Green Belt
0
As I'm not familiar with neither kix nor vbscript, let me just point out my DOS way, maybe this will help anyway:

If there are no other Keys in Partners, we can list the content of partners and set a variable with that name. In DOS you can use:

FOR /F "delims=\ tokens=6" %%A in ('REG QUERY HKCU\Software\Microsoft\Windows CE Services\Partners') DO SET YOURVARIABLE=%%A

FOR /F goes through contents of the output of the command in brackets. The backslash is our delimiter and we want to evaluate the contents behind the sixth backslash. This will be set as YOURVARIABLE. This only works out right, when there is just one key below Partners, otherwise YOURVARIABLE will always be the last...

Then you can REG DELETE HKCU\Software\Microsoft\Windows CE Services\Partners\%YOURVARIABLE%\Services\Synchronization\Objects\Merlin Mail.

(sorry, no syntax checks when I typed this up, add quotes where needed)
Posted by: TomB 19 years ago
Orange Belt
0
Same concept in vbscript here:



Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002

Dim strComputer, sKey, sKeyPath
strComputer = "."

Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Windows CE Services\Partners"
oReg.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubKeys

sKey=arrSubKeys(0)
sKeyPath = "Software\Microsoft\Windows CE Services\Partners\"&sKey&"\Services\Synchronization\Objects\Merlin Mail"

oReg.DeleteKey HKEY_CURRENT_USER, strKeyPath
Posted by: glwday 19 years ago
Orange Belt
0
Thanks guys, thats helped a lot
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ