PDA

View Full Version : cd player (W98)



ehpjr
05-31-2002, 01:56 AM
I want write a script to check and see if the cdplayer.exe is running and if so, is it playing or is it paused. I have used GetObject to see if excel, word, access are running but I can't get that to work on accessory apps like notepad, cdplayer, paint.
Thanks for any help.

Jama
06-02-2002, 07:09 PM
Although you can write a script to check if cdplayer.exe is running or not, you will not be able to retrieve its current state. You can’t see if it’s playing, paused or stopped, nor can you control it programmatically. This is because cdplayer.exe lacks an OLE object. OLE stands for Object Linking and Embedding. It’s the interface through which you can interact with and or control an application from a script or another application.

Applications can be “scriptable” fully, partially or they can be “not scriptable” depending on how the developer intended it to be.

If you need a “scriptable” cdplayer, then I suggest you look some where else, cause cdplayer.exe is a no starter!

As for how to check if cdplayer.exe is running, you can query the win32_process class to retrieve all running instances where name is cdplayer.exe.
Here is a sample code;

AppToCheck = "cdplayer.exe"
list = 0

For Each Process In GetObject(_
"winmgmts:").InstancesOf("win32_process")

If Process.Name = AppToCheck Then
list = list + 1
pName = Process.Name
End If
Next

wscript.echo "there are " & list & " copies of " & pName & " running"

Set list = Nothing

If you need a more in-depth explanation on OLE, then check this web page. It’s written for Jscript but the concept of OLE is the same regardless of how you access it.

<a target="_blank" href=http://www.webreference.com/js/column55/automation.html>http://www.webreference.com/js/column55/automation.html</a>

Jama

ehpjr
06-19-2002, 03:32 AM
Thanks. I tried this but it says it can't find these objects GetObject("winmgmts:").InstancesOf("win32_process")