Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9135437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:49:27+00:00 2026-06-17T08:49:27+00:00

Can anyone point me to a vbscript (using WMI) to find out the installed

  • 0

Can anyone point me to a vbscript (using WMI) to find out the installed SQL Server version. I have a scenario where either SQL Server 2008 R2 or SQL Server 2012 could be installed on a machine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:49:27+00:00Added an answer on June 17, 2026 at 8:49 am

    Based on the code in the first Google search result here:

    Dim WMI, Col, Prod, Q
    Set WMI = GetObject("WinMgmts:")
    Q = "Select * FROM Win32_Product WHERE Vendor = " & _
        "'Microsoft Corporation' AND Name LIKE 'SQL Server%Database Engine Services'"
    Set Col = WMI.ExecQuery(Q)
    For Each Prod in Col
      if left(Prod.version, 3) = "11." then
        msgbox "SQL Server 2012 was found!" & vbCrLf & prod.version
      elseif left(Prod.version, 4) = "10.5" then
        msgbox "SQL Server 2008 R2 was found!" & vbCrLf & prod.version
      end if
    Next
    Set Col = Nothing
    Set WMI = Nothing
    

    Note that WMI is not the fastest way to do this. Have you considered checking the registry directly instead of going through WMI?

    UPDATE given OP’s solution using the registry instead, and with the assumption that exactly one of 2008R2 or 2012 could be installed:

    RegKey2012 = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\" & _
                 "Microsoft SQL Server\MSSQL11.MSSQLSERVER\"
    If RegKeyExists(RegKey2012) Then 
      WScript.StdOut.Write("2012") 
    Else 
      WScript.StdOut.Write("2008R2") 
    End If 
    
    Function RegKeyExists(Key) 
      Dim oShell, entry 
      On Error Resume Next 
      Set oShell = CreateObject("WScript.Shell") 
      entry = oShell.RegRead(Key) 
      If Err.Number <> 0 Then 
        Err.Clear 
        RegKeyExists = False 
      Else 
        Err.Clear 
        RegKeyExists = True 
      End If 
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone point me out whats wrong with the configuration I have to execute
Can anyone point out my mistake in trying to find the value of a
Can anyone point me out or explain what is the difference between android Home
Can anyone point me to some rules to follow when using using Rich Text
Can anyone point me to an example of using sqlite with Monodroid? I've been
Can anyone point me to an example of a program using camera on iPad
Can anyone point me towards documentation on this? I'm using Devise + CanCan in
Can anyone point out a good many-to-many database tutorial for CodeIgniter. Just trying to
Can anyone point out the flaw in this code? I'm retrieving some HTML with
Can anyone point out an extension where we can add articles in another language,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.