operating system info

vbs code that check which operating system in running and if running system is windows xp or vista then code ends else eject CD/DVD tray. If not possible in vbs then mention in possible language.
ankur3020Asked:
Who is Participating?
 
ankur3020Connect With a Mentor Author Commented:
Thanks it is working well.
0
 
MatthiasVanceConnect With a Mentor Commented:
Hope this will help.

Kind regards,

Matthias Vance
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
 
Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
 
For Each objOperatingSystem in colOperatingSystems
	version = Left(objOperatingSystem.Version, 3)
	if version <> "6.0" and version <> "5.1" then
		OpenCD()
	end if
Next
 
Public Sub OpenCD()
	Set oWMP = CreateObject("WMPlayer.OCX.7" )
	Set colCDROMs = oWMP.cdromCollection
 
	if colCDROMs.Count >= 1 then
	        For i = 0 to colCDROMs.Count - 1
	                colCDROMs.Item(i).Eject
	        Next
	End If
End Sub

Open in new window

0
All Courses

From novice to tech pro — start learning today.