Have you ever wondered if there is a programmatic way to detect all the SQL Server instances on a single machine? Well, no worries, copy the following code given below and save it as SQLInfo.Vbs and run this script using C:\CScript SQLInfo.Vbs or just dobule click on the script.
Contents of SQLInfo.Vbs:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\Microsoft\SqlServer\ComputerManagement")
Set colItems = objWMIService.ExecQuery( "SELECT * FROM SqlService",,48)
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "SqlService instance"
Wscript.Echo "-----------------------------------"
Wscript.Echo "DisplayName: " & objItem.DisplayName
Wscript.Echo "ServiceName: " & objItem.ServiceName
Wscript.Echo "SQLServiceType: " & objItem.SQLServiceType
Next
No comments:
Post a Comment