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\Microsoft SQL Server\Instance Names"
      dReg.EnumKey  HKEY_LOCAL_MACHINE,strKeyPath,subkeys
      IsSQLsubkeyFound = FALSE
      FOR EACH subkey IN subkeys
            'WScript.echo subkey
            IF subkey = "SQL" THEN
                  IsSQLsubkeyFound = TRUE
                  EXIT FOR
            END IF
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!
sumit dubeyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


How do you define dReg?

sumit dubeyAuthor Commented:
Hi Rgonzo,

I could find below code which probably talks about "d.Reg" :

Set dReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    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.
Are you sure the key ("SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names") exists?

Have you controlled in regedit?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Maybe try

If Not IsNull(subkeys) Then
For Each subkey In subkeys
    WScript.Echo subkey
End If

Open in new window

sumit dubeyAuthor Commented:
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\Microsoft 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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.