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
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)
Please log in to answer
Posted by:
KPrinz
19 years ago
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)
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
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
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.