Is there any way to delete a key with subkeys under it with a vbscript?
From what I have tried you have to delete all the subkeys first before you
can delete the key.
exp:
To delete the key ddeexec I have to delete the Topic and the Application
keys first before I can delete the ddeexec key. Any way around this?

WshShell.RegDelete
"HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\ddeexec\Application\"
WshShell.RegDelete "HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\ddeexec\Topic\"
WshShell.RegDelete "HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\ddeexec\"

Re: key and subkey by hb21l6

hb21l6
Sun Jul 20 04:49:16 CDT 2008


"PaulM" <paul@paulsxp.com> wrote in message
news:%23rFWBwf6IHA.4988@TK2MSFTNGP04.phx.gbl...
> Is there any way to delete a key with subkeys under it with a vbscript?
> From what I have tried you have to delete all the subkeys first before you
> can delete the key.
> exp:
> To delete the key ddeexec I have to delete the Topic and the Application
> keys first before I can delete the ddeexec key. Any way around this?
>
> WshShell.RegDelete
> "HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\ddeexec\Application\"
> WshShell.RegDelete
> "HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\ddeexec\Topic\"
> WshShell.RegDelete "HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\ddeexec\"

I think you have to loop though all the keys deleteing them before you can
delete the topic.
Using this array, you can delete multiple topics at once.

Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000005

strComputer = "."
arrKeys = array(HKEY_CURRENT_USER & "key path",_
HKEY_CURRENT_USER & "key path",_
HKEY_CURRENT_USER & "key path",_
HKEY_LOCAL_MACHINE & "key path")

Set objRegistry = GetObject("winmgmts:\\" & strComputer &
"\root\default:StdRegProv")

For i=0 to ubound(arrKeys) 'this loops through the arrKeys array"

For Each strKey In arrKeys sCmd = "reg delete /f """ & strKey & """"
nRC = WshShell.Run ( sCmd, 4, True )Next
Next
or something similar..Dave


Re: key and subkey by Pegasus

Pegasus
Sun Jul 20 06:16:37 CDT 2008


"PaulM" <paul@paulsxp.com> wrote in message
news:%23rFWBwf6IHA.4988@TK2MSFTNGP04.phx.gbl...
> Is there any way to delete a key with subkeys under it with a vbscript?
> From what I have tried you have to delete all the subkeys first before you
> can delete the key.
> exp:
> To delete the key ddeexec I have to delete the Topic and the Application
> keys first before I can delete the ddeexec key. Any way around this?
>
> WshShell.RegDelete
> "HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\ddeexec\Application\"
> WshShell.RegDelete
> "HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\ddeexec\Topic\"
> WshShell.RegDelete "HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\ddeexec\"

It ain't nice but regedit.exe will do it.



Re: key and subkey by PaulM

PaulM
Sun Jul 20 13:00:36 CDT 2008

I will give it a try. Thanks

--
-------------------------------------------------------------------------------------
www.paulsxp.com
www.paulsxp.com/forum
www.supportspace.com/home/affiliates.s2?aiu=paulm
------------------------------------------------------------------------------------

"hb21l6" <hb21l6@hotmail.com> wrote in message
news:CA52E446-F3FE-4F87-AAEB-17E9671E153A@microsoft.com...
>
> "PaulM" <paul@paulsxp.com> wrote in message
> news:%23rFWBwf6IHA.4988@TK2MSFTNGP04.phx.gbl...
>> Is there any way to delete a key with subkeys under it with a vbscript?
>> From what I have tried you have to delete all the subkeys first before
>> you can delete the key.
>> exp:
>> To delete the key ddeexec I have to delete the Topic and the Application
>> keys first before I can delete the ddeexec key. Any way around this?
>>
>> WshShell.RegDelete
>> "HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\ddeexec\Application\"
>> WshShell.RegDelete
>> "HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\ddeexec\Topic\"
>> WshShell.RegDelete "HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\ddeexec\"
>
> I think you have to loop though all the keys deleteing them before you can
> delete the topic.
> Using this array, you can delete multiple topics at once.
>
> Const HKEY_CLASSES_ROOT = &H80000000
> Const HKEY_CURRENT_USER = &H80000001
> Const HKEY_LOCAL_MACHINE = &H80000002
> Const HKEY_USERS = &H80000003
> Const HKEY_CURRENT_CONFIG = &H80000005
>
> strComputer = "."
> arrKeys = array(HKEY_CURRENT_USER & "key path",_
> HKEY_CURRENT_USER & "key path",_
> HKEY_CURRENT_USER & "key path",_
> HKEY_LOCAL_MACHINE & "key path")
>
> Set objRegistry = GetObject("winmgmts:\\" & strComputer &
> "\root\default:StdRegProv")
>
> For i=0 to ubound(arrKeys) 'this loops through the arrKeys array"
>
> For Each strKey In arrKeys sCmd = "reg delete /f """ & strKey & """"
> nRC = WshShell.Run ( sCmd, 4, True )Next
> Next
> or something similar..Dave


Re: key and subkey by PaulM

PaulM
Sun Jul 20 13:03:53 CDT 2008

You can do it with a .reg file, but it does not tell the user what it is
about to do. With a vbs file I have a menu come up and let the user know
what it is about do do and why and whatever.


"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
news:#bAaUol6IHA.1420@TK2MSFTNGP06.phx.gbl...
>
> "PaulM" <paul@paulsxp.com> wrote in message
> news:%23rFWBwf6IHA.4988@TK2MSFTNGP04.phx.gbl...
>> Is there any way to delete a key with subkeys under it with a vbscript?
>> From what I have tried you have to delete all the subkeys first before
>> you can delete the key.
>> exp:
>> To delete the key ddeexec I have to delete the Topic and the Application
>> keys first before I can delete the ddeexec key. Any way around this?
>>
>> WshShell.RegDelete
>> "HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\ddeexec\Application\"
>> WshShell.RegDelete
>> "HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\ddeexec\Topic\"
>> WshShell.RegDelete "HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\ddeexec\"
>
> It ain't nice but regedit.exe will do it.
>

Re: key and subkey by Pegasus

Pegasus
Sun Jul 20 13:52:14 CDT 2008


"PaulM" <paul@paulsxp.com> wrote in message
news:OFn14Lp6IHA.4468@TK2MSFTNGP02.phx.gbl...
> You can do it with a .reg file, but it does not tell the user what it is
> about to do. With a vbs file I have a menu come up and let the user know
> what it is about do do and why and whatever.

There is no reason why you cannot have a mixed environment
(other than it being clumsy): Do the menu with the VB Script,
then invoke regedit.exe with the Run method.



Re: key and subkey by PaulM

PaulM
Sun Jul 20 14:52:35 CDT 2008

example please.


"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
news:OmoX8mp6IHA.2056@TK2MSFTNGP04.phx.gbl...
>
> "PaulM" <paul@paulsxp.com> wrote in message
> news:OFn14Lp6IHA.4468@TK2MSFTNGP02.phx.gbl...
>> You can do it with a .reg file, but it does not tell the user what it is
>> about to do. With a vbs file I have a menu come up and let the user know
>> what it is about do do and why and whatever.
>
> There is no reason why you cannot have a mixed environment
> (other than it being clumsy): Do the menu with the VB Script,
> then invoke regedit.exe with the Run method.
>

Re: key and subkey by Pegasus

Pegasus
Sun Jul 20 15:43:43 CDT 2008

Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("notepad c:\test.txt", 1, true)

(taken almost verbatim from script56.chm, which I urge you to
download if you don't have it already).


"PaulM" <paul@paulsxp.com> wrote in message
news:ekyvoIq6IHA.1592@TK2MSFTNGP04.phx.gbl...
> example please.
>
>
> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
> news:OmoX8mp6IHA.2056@TK2MSFTNGP04.phx.gbl...
>>
>> "PaulM" <paul@paulsxp.com> wrote in message
>> news:OFn14Lp6IHA.4468@TK2MSFTNGP02.phx.gbl...
>>> You can do it with a .reg file, but it does not tell the user what it is
>>> about to do. With a vbs file I have a menu come up and let the user know
>>> what it is about do do and why and whatever.
>>
>> There is no reason why you cannot have a mixed environment
>> (other than it being clumsy): Do the menu with the VB Script,
>> then invoke regedit.exe with the Run method.
>>



Re: key and subkey by PaulM

PaulM
Sun Jul 20 17:05:47 CDT 2008

Ok thanks


"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
news:uuvsNlq6IHA.1196@TK2MSFTNGP05.phx.gbl...
> Set WshShell = WScript.CreateObject("WScript.Shell")
> Return = WshShell.Run("notepad c:\test.txt", 1, true)
>
> (taken almost verbatim from script56.chm, which I urge you to
> download if you don't have it already).
>
>
> "PaulM" <paul@paulsxp.com> wrote in message
> news:ekyvoIq6IHA.1592@TK2MSFTNGP04.phx.gbl...
>> example please.
>>
>>
>> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
>> news:OmoX8mp6IHA.2056@TK2MSFTNGP04.phx.gbl...
>>>
>>> "PaulM" <paul@paulsxp.com> wrote in message
>>> news:OFn14Lp6IHA.4468@TK2MSFTNGP02.phx.gbl...
>>>> You can do it with a .reg file, but it does not tell the user what it
>>>> is about to do. With a vbs file I have a menu come up and let the user
>>>> know what it is about do do and why and whatever.
>>>
>>> There is no reason why you cannot have a mixed environment
>>> (other than it being clumsy): Do the menu with the VB Script,
>>> then invoke regedit.exe with the Run method.
>>>
>
>

Re: key and subkey by PaulM

PaulM
Sun Jul 20 17:26:39 CDT 2008

This works in a vbscript:

Return=wshshell.Run ("reg delete HKCR\FirefoxHTML\shell\open\ddeexec"
,1,true)
But a cmd window comes up with yes/no prompt. I can not find a way to run it
without the prompt.


"PaulM" <paul@paulsxp.com> wrote in message
news:OWlpETr6IHA.4112@TK2MSFTNGP05.phx.gbl...
> Ok thanks
>
>
> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
> news:uuvsNlq6IHA.1196@TK2MSFTNGP05.phx.gbl...
>> Set WshShell = WScript.CreateObject("WScript.Shell")
>> Return = WshShell.Run("notepad c:\test.txt", 1, true)
>>
>> (taken almost verbatim from script56.chm, which I urge you to
>> download if you don't have it already).
>>
>>
>> "PaulM" <paul@paulsxp.com> wrote in message
>> news:ekyvoIq6IHA.1592@TK2MSFTNGP04.phx.gbl...
>>> example please.
>>>
>>>
>>> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
>>> news:OmoX8mp6IHA.2056@TK2MSFTNGP04.phx.gbl...
>>>>
>>>> "PaulM" <paul@paulsxp.com> wrote in message
>>>> news:OFn14Lp6IHA.4468@TK2MSFTNGP02.phx.gbl...
>>>>> You can do it with a .reg file, but it does not tell the user what it
>>>>> is about to do. With a vbs file I have a menu come up and let the user
>>>>> know what it is about do do and why and whatever.
>>>>
>>>> There is no reason why you cannot have a mixed environment
>>>> (other than it being clumsy): Do the menu with the VB Script,
>>>> then invoke regedit.exe with the Run method.
>>>>
>>
>>

Re: key and subkey by Michael

Michael
Sun Jul 20 17:52:30 CDT 2008

PaulM wrote:
> This works in a vbscript:
>
> Return=wshshell.Run ("reg delete HKCR\FirefoxHTML\shell\open\ddeexec"
> ,1,true)
> But a cmd window comes up with yes/no prompt. I can not find a way to
> run it without the prompt.
>

Did you try it with the /f switch?


REG DELETE KeyName [/v ValueName | /ve | /va] [/f]

KeyName [\\Machine\]FullKey
Machine Name of remote machine - omitting defaults to the current
machine
Only HKLM and HKU are available on remote machines
FullKey ROOTKEY\SubKey
ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey The full name of a registry key under the selected ROOTKEY
ValueName The value name, under the selected Key, to delete
When omitted, all subkeys and values under the Key are deleted
/ve delete the value of empty value name <no name>
/va delete all values under this key
/f Forces the deletion without propmt

--
Michael Harris



Re: key and subkey by PaulM

PaulM
Sun Jul 20 18:31:26 CDT 2008

I tried all of them /f /va /ve the prompt does not appear, but the reg key
is not deleted.
Oh well I will just play around with it or go back to the old way.

Thanks


"Michael Harris" <mikhar.at.mvps.dot.org> wrote in message
news:eC5XLtr6IHA.1196@TK2MSFTNGP05.phx.gbl...
> PaulM wrote:
>> This works in a vbscript:
>>
>> Return=wshshell.Run ("reg delete HKCR\FirefoxHTML\shell\open\ddeexec"
>> ,1,true)
>> But a cmd window comes up with yes/no prompt. I can not find a way to
>> run it without the prompt.
>>
>
> Did you try it with the /f switch?
>
>
> REG DELETE KeyName [/v ValueName | /ve | /va] [/f]
>
> KeyName [\\Machine\]FullKey
> Machine Name of remote machine - omitting defaults to the current
> machine
> Only HKLM and HKU are available on remote machines
> FullKey ROOTKEY\SubKey
> ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ]
> SubKey The full name of a registry key under the selected ROOTKEY
> ValueName The value name, under the selected Key, to delete
> When omitted, all subkeys and values under the Key are deleted
> /ve delete the value of empty value name <no name>
> /va delete all values under this key
> /f Forces the deletion without propmt
>
> --
> Michael Harris
>
>

Re: key and subkey by PaulM

PaulM
Sun Jul 20 19:11:19 CDT 2008

Update, Did get it to work.
Thanks to all who helped.


"PaulM" <paul@paulsxp.com> wrote in message
news:OntK7Cs6IHA.1080@TK2MSFTNGP06.phx.gbl...
> I tried all of them /f /va /ve the prompt does not appear, but the reg key
> is not deleted.
> Oh well I will just play around with it or go back to the old way.
>
> Thanks
>
>
> "Michael Harris" <mikhar.at.mvps.dot.org> wrote in message
> news:eC5XLtr6IHA.1196@TK2MSFTNGP05.phx.gbl...
>> PaulM wrote:
>>> This works in a vbscript:
>>>
>>> Return=wshshell.Run ("reg delete HKCR\FirefoxHTML\shell\open\ddeexec"
>>> ,1,true)
>>> But a cmd window comes up with yes/no prompt. I can not find a way to
>>> run it without the prompt.
>>>
>>
>> Did you try it with the /f switch?
>>
>>
>> REG DELETE KeyName [/v ValueName | /ve | /va] [/f]
>>
>> KeyName [\\Machine\]FullKey
>> Machine Name of remote machine - omitting defaults to the current
>> machine
>> Only HKLM and HKU are available on remote machines
>> FullKey ROOTKEY\SubKey
>> ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ]
>> SubKey The full name of a registry key under the selected ROOTKEY
>> ValueName The value name, under the selected Key, to delete
>> When omitted, all subkeys and values under the Key are
>> deleted
>> /ve delete the value of empty value name <no name>
>> /va delete all values under this key
>> /f Forces the deletion without propmt
>>
>> --
>> Michael Harris
>>
>>