Re: Check if registry registry key exists and then add values to runonce by Steven
Steven
Wed Aug 17 09:53:29 CDT 2005
Const HKEY_CURRENT_USER = &H80000001
Dim strComputer, strKeyPath, strValueName
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer &
"\root\default:StdRegProv")
strKeyPath = "[Path you want to check]"
strValueName = "[Value you want to check for]"
objRegistry.GetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
If NOT IsNull(dwValue) Then
'// The key exists, write to it
Dim objWSH
Set objWSH = WScript.CreateObject("WScript.Shell")
'// Requires: [Name, value, REG_type]
objWSH.RegWrite
"HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce\", "[Value]"
,"[REG_TYPE]"
Set objWSH = Nothing
End If
Set objRegistry = Nothing
'// Rest of your script here
Hope this helps :o)
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"Mariette Knap [SBS MVP]" <mariette@smallbizserver.local> wrote in message
news:uMfLgLzoFHA.3912@TK2MSFTNGP10.phx.gbl...
> Hi all,
>
> I have done some scripting but I am no expert. I need to check if a
registry
> key (not a string value) exists on a client computer. If the key exists it
> should add some value to the HKCU runonce hive. If the key does exists it
> should do nothing and run the rest in the script.
>
> How do I do that?
>
> Bye
> Mariette Knap
> www.smallbizserver.net
>
>