The more I program in vbscript the more I appreciate normal visual basic programming! I can't seem to get anything done with this scripting! Anyways below I have provided a function im writing which checks the registy for a key...if the key does not exist my ubound(arrsubkeys) is causing an error...i have tried to error trap this so i can return a false with no sucsess...any suggestions?
function AppInstalled(ApplicationName) 'this checks the registry if the application is already installed returns true / false
Dim oReg,strkeypath, arrSubKeys, subkey, strcomputer, index
strComputer = "."
strKeyPath = "SOFTWARE\myAPPS"
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
'*** Here is where the error hits if the key does not exist
'*** if it does exist everything is just fine!
for index = 0 to ubound(arrSubKeys) 'loop through the registry and find if the app is installed
if lcase(arrsubkeys(index)) = lcase(applicationname) then
AppInstalled = true
exit function
end if
next
AppInstalled = False
end function
function AppInstalled(ApplicationName) 'this checks the registry if the application is already installed returns true / false
Dim oReg,strkeypath, arrSubKeys, subkey, strcomputer, index
strComputer = "."
strKeyPath = "SOFTWARE\myAPPS"
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
'*** Here is where the error hits if the key does not exist
'*** if it does exist everything is just fine!
for index = 0 to ubound(arrSubKeys) 'loop through the registry and find if the app is installed
if lcase(arrsubkeys(index)) = lcase(applicationname) then
AppInstalled = true
exit function
end if
next
AppInstalled = False
end function