# which scripting language is this?



## mainak10 (Aug 18, 2011)

I am a windows system administrator.I want to learn scripting for reducing my work in windows servers.Where can I learn good scripting.Please tell me which scripting language is used below:

strServers = "servers.txt"
Set objNetwork = CreateObject("Wscript.Network") 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForReading = 1
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
Set objFile = objFSO.OpenTextFile(strServers, intForReading, False)
x = 1
While Not objFile.AtEndOfStream
strServer = objFile.ReadLine
If Ping(strServer) = True Then
objExcel.Cells(1, 1).Value = "Server Name"
objExcel.Cells(1, 2).Value = "Operating System"
objExcel.Cells(1, 3).Value = "Service Pack"
objExcel.Cells(1, 1).Font.Bold = TRUE
objExcel.Cells(1, 2).Font.Bold = TRUE
objExcel.Cells(1, 3).Font.Bold = TRUE
objExcel.Cells(1, 1).Font.Size = 10
objExcel.Cells(1, 2).Font.Size = 10
objExcel.Cells(1, 3).Font.Size = 10
objExcel.Cells(1, 1).Font.ColorIndex = 3
objExcel.Cells(1, 2).Font.ColorIndex = 3
objExcel.Cells(1, 3).Font.ColorIndex = 3

y = 1
x = x + 1
objExcel.Cells(x,y).value = strServer 
Set objWMIService = GetObject("winmgmts:\\" & strServer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")

'--------------------------------------Win32_OperatingSystem-----------------------
For Each objOperatingSystem in colOperatingSystems
If err.number <> 0 Then 
temp = "Not Available" 
Else
temp = objOperatingSystem.Caption 'OS Name
y = y + 1
objExcel.Cells(x,y).value = temp
temp = objOperatingSystem.ServicePackMajorVersion 'ServicePackMajorVersion
'temp = objOperatingSystem.ServicePackMinorVersion

y = y + 1
objExcel.Cells(x,y).value = temp
End If
Next
'----------------------------------------End of Win32_OperatingSystem--------------

With objExcel
.Range("A1:B1").Select
.Cells.EntireColumn.AutoFit
End With
Else
MsgBox strServer & " is offline."
End If
Wend
MsgBox "Done"
Function Ping(strServer)
Dim objShell, boolCode
Set objShell = CreateObject("WScript.Shell")
boolCode = objShell.Run("Ping -n 1 -w 300 " & strServer, 0, True)
If boolCode = 0 Then
Ping = True
Else
Ping = False
End If
End Function


----------



## Squashman (Apr 4, 2003)

Looks like a VB Macro for Excel.


----------



## Rockn (Jul 29, 2001)

I would learn PowerShell as a scripting language. It is pretty much the defacto language to learn now.


----------

