Solved

operating system info

Posted on 2008-09-29
2
264 Views
Last Modified: 2010-07-27
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.
0
Comment
Question by:ankur3020
2 Comments
 
LVL 8

Assisted Solution

by:MatthiasVance
MatthiasVance earned 125 total points
ID: 22598756
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
 

Accepted Solution

by:
ankur3020 earned 0 total points
ID: 22614761
Thanks it is working well.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question