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


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:\Folder\CSNOS.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 & "\root\cimv2")
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



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish