Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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); 

Read this page for more clarity : Computer System Hardware Classes

share|improve this answer

Your Answer


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.