JSI Tip 10626. How can I use built in commands to display the operating system name, version, service pack, and Windows directory?

Jerold Schulman

July 4, 2006

1 Min Read
ITPro Today logo in a gray background | ITPro Today


I have scripted CSNOS.vbs to display the operating system name, version, service pack, and Windows directory of the local computer.

To run CSNOS.vbs:

1. Open a CMD.EXE window.

2. Type cscript //nologo C:FolderCSNOS.vbs and press Enter, where C:Folder is the directory where you placed CSNOS.vbs.

When I run CSNOS.vbs on my Windows XP Professional workstation, which is named JSI009, I receive:

"JSI009","Microsoft Windows XP Professional","5.1.2600","Service Pack 2","C:WINDOWS"

When I run CSNOS.vbs on my domain controller, named JSI001, I receive:

"JSI001","Microsoft(R) Windows(R) Server 2003, Standard Edition","5.2.3790","Service Pack 2, v.2725","C:WINDOWS"

CSNOS.vbs contains:

strComputer = "."Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\" & strComputer & "rootcimv2")Set OS = objWMIService.ExecQuery _ ("SELECT * FROM Win32_OperatingSystem")For Each objOS in OS Wscript.Echo  

" & objOS.CSName &

," _            &  

" & objOS.Caption &

," _            &  

" & objOS.Version &

," _             &  

" & objOS.CSDVersion &

," _            &  

" & objOS.WindowsDirectory &

"Next



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like