Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


check for existence registry key

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,23780
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> check for existence registry key
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 check for existence registry key - 7/19/2005 8:59:07 AM   
  Bezerk

 

Posts: 22
Score: 0
Joined: 6/20/2005
From: Netherlands
Status: offline
I want to check if an registry key exists, if not then install a hotfix.
But that's not the hard part.

See the code:

Dim WSHShell
Dim objAdr
On error resume next

On error resume next
Set WSHShell = WScript.CreateObject("WScript.Shell")
test = wshshell.RegRead
test("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix\KB8")
wscript.echo test
If objAdr.Keyexists(test) Then
msgbox "hotfix ok"
else msgbox "hotfix bad"

end if

My test says empty, who has an idea? of a code snipet to help me.
 
 
Post #: 1
 
 RE: check for existence registry key - 7/19/2005 9:25:45 AM   
  sethsdad


Posts: 115
Score: 0
Joined: 4/4/2005
From: USA
Status: offline
the OERN is messing you up.  Try this:

Dim WSHShell
Dim objAdr
On error resume next
Set WSHShell = WScript.CreateObject("WScript.Shell")
test = wshshell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\HotFix\KB8")
If error.number > 0 Then
msgbox "hotfix bad"
else msgbox "hotfix ok"
end if
wscript.echo test

(in reply to Bezerk)
 
 
Post #: 2
 
 RE: check for existence registry key - 7/19/2005 9:38:53 AM   
  ehvbs

 

Posts: 2169
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
[sethsdad, you are too fast for me!]

Some slightly other version:

  Dim sPath
  Dim aKeys
  Dim WSHShell
  Dim sKey
  Dim vRegValue

  sPath        = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix\"
  aKeys        = Array( "KB329115\Installed", "KB828749\Installed", "RealOS\Installed" )
  Set WSHShell = WScript.CreateObject( "WScript.Shell" )
  For Each sKey In aKeys
      vRegValue = readRegistry( WSHShell, sPath + sKey )
      If IsEmpty( vRegValue ) Then
         msgbox "hotfix " + sKey + " bad"
      Else
         msgbox "hotfix " + sKey + " ok"
      End If
  Next

Function readRegistry( oShell, sKey )
  Dim vRegValue ' starts Empty
On Error Resume Next
  vRegValue = oShell.RegRead( sKey )
On Error GoTo 0
  readRegistry = vRegValue
End Function

(in reply to Bezerk)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> check for existence registry key Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts