sumit dubey
asked on
VB Script Run time error : Object not a collection
I am running some installer on my machine which is giving me error on 78th line. I don't know how to fix hence providing you code snippet from line number 74 to 84:
========================== ========== ========== ========== ==
Function GetInstanceNames
strKeyPath = "SOFTWARE\Microsoft\Micros oft SQL Server\Instance Names"
dReg.EnumKey HKEY_LOCAL_MACHINE,strKeyP ath,subkey s
IsSQLsubkeyFound = FALSE
FOR EACH subkey IN subkeys
'WScript.echo subkey
IF subkey = "SQL" THEN
IsSQLsubkeyFound = TRUE
EXIT FOR
END IF
NEXT
========================== ========== ========== =====
Note : This script basically checks for the sql instance name and then installs simulator installer. This vb script works fine when I have MSSQLSERVER 2008 Express installed on my machine. However currently I have installed MSSQL Server 2012 and having this error. Screenshot attached, in case more info is required please let me know. Thanks!
error-1.jpg
==========================
Function GetInstanceNames
strKeyPath = "SOFTWARE\Microsoft\Micros
dReg.EnumKey HKEY_LOCAL_MACHINE,strKeyP
IsSQLsubkeyFound = FALSE
FOR EACH subkey IN subkeys
'WScript.echo subkey
IF subkey = "SQL" THEN
IsSQLsubkeyFound = TRUE
EXIT FOR
END IF
NEXT
==========================
Note : This script basically checks for the sql instance name and then installs simulator installer. This vb script works fine when I have MSSQLSERVER 2008 Express installed on my machine. However currently I have installed MSSQL Server 2012 and having this error. Screenshot attached, in case more info is required please let me know. Thanks!
error-1.jpg
ASKER
Hi Rgonzo,
I could find below code which probably talks about "d.Reg" :
Set dReg=GetObject("winmgmts:{ impersonat ionLevel=i mpersonate }!\\" & _
strComputer & "\root\default:StdRegProv" )
Apologies in advance if the question is not clear to you. Actually the code was written long back and I am here just to use it as an installer.
I could find below code which probably talks about "d.Reg" :
Set dReg=GetObject("winmgmts:{
strComputer & "\root\default:StdRegProv"
Apologies in advance if the question is not clear to you. Actually the code was written long back and I am here just to use it as an installer.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Maybe try
If Not IsNull(subkeys) Then
For Each subkey In subkeys
WScript.Echo subkey
Next
End If
ASKER
Thanks Rgonzo, the code snippet given by you eliminated previous error (run time error). However now I am having another error as "SQL Instances are not available". Then I checked in registry and found there is no instance name under "SOFTWARE\Microsoft\Micros oft SQL Server" path. May be now I need to check my SQL installation and registry settings. Thanks for your time and help, I will get back to you in case of any further issue.
How do you define dReg?
Regards