Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I tried searching but I can't seem to be find anything besides USB detection. I want to make a script that detects when the speaker and microphone ports has a device plugged in. Is this possible to do? Make the script run (some other stuff) when you plug in a headset for example.

share|improve this question

1 Answer 1

You should be able to invoke a script by running a status query after calling WMI Class Win32_bus Class

On Error Resume Next 

strComputer = "." 
Set objWMIService = GetObject("winmgmts:" _ 
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 

Set colItems = objWMIService.ExecQuery("Select * from Win32_Bus") 
For Each objItem in colItems 
 WScript.Echo("Availability: " + objItem.Availability); 
 WScript.Echo("Status: " + objItem.Status); 
Next

Read this page for more clarity : Computer System Hardware Classes

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.