?
Solved

operating system info

Posted on 2008-09-29
2
Medium Priority
?
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Assisted Solution

by:MatthiasVance
MatthiasVance earned 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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 …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

752 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