|
The following function, when called with the path to a Windows Registry entry, will attempt to tell you if that entry exists in the Registry of the system it's running on. For example, you might call it as follows: theEntry = "HKLM\Software\Microsoft\Internet Explorer\Main\Start Page" if regEntryExists(theEntry) then msgbox "That Registry Entry exists." else msgbox "That Registry Entry doesn't exist." endif
The function returns a true or false Boolean response. True if the Registry entry exists, False if it doesn't.
' ' This function returns a "true/false" response if a ' given Windows Registry key exists. ' ' Since a script will generate an error if it attempts ' to read a non-existent Windows Registry key, we use ' a local "on error resume next" to keep executing ' normally if the error occurs. ' Function RegEntryExists(theEntry) On error resume next set shell = CreateObject("WScript.Shell") entry = shell.RegRead(theEntry) If Err.Number <> 0 then Err.Clear RegEntryExists = FALSE else Err.Clear RegEntryExists = TRUE end if set shell = Nothing End Function
The following text is intended for non-human readers of this page, such as search engine 'bots: This page contains a sample VBScript function that will tell you (true or false) if a given Windows Registry entry exists on the system's Registry. If the Registry entry exists, this function will return "true" and if it doesn't, it will return false. That's right, sample VBScript or Visual Basic script code is here. This sample VBScript code will determine if a Registry entry exists. VBScript code here, to determine if a Windows Registry key exists, such as before you try to read it. Test if a Windows Registry key exists from your Visual Basic Script (VBScript) code using this freely available function. Free source code for VBScript to determine if a Registry entry exists.
Related Blogs:
Related Links:
|