I need a script to find out what devices are active

Asked By 10 points N/A Posted on -
qa-featured

Hi,

I have a computer which runs on windows XP and I am looking to use a script either VBS or batch in order to find out what devices are active at that instant. The structure of the code should be something similar to this IF the Printer is plugged In:

Show Dialog: Your HP Printer is plugged in.

ELSE: Do nothing.

Anyone who has the knowledge in this field please help.

SHARE
Answered By 0 points N/A #103926

I need a script to find out what devices are active

qa-featured

Hello,

I have worked many times to get info about active ports of my laptop, anyhow i never ever come up with such type of code but i can share with you the codes i have come up with in order to get information about active devices and ports. For example once i required to know the installed hardware’s on my system so i used bash$ ls dev command to get this info, it lists down all the hardware devices installed. And once i want to get information about the open ports so i used map command, it helps me to tell where the desired port is busy or idle and another code for currently active device is :

 # Code snippets from /etc/rc.d/init.d/network # … # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 [ -x /sbin/ifconfig ] || exit 0 # … for i in $interfaces ; do if ifconfig $i 2>/dev/null | grep -q "UP" >/dev/null 2>&1 ; then action "Shutting down interface $i: " ./ifdown $i boot fi # The GNU-specific "-q" option to "grep" means "quiet", i.e., #+ producing no output. # Redirecting output to /dev/null is therefore not strictly necessary. # … echo "Currently active devices:" echo `/sbin/ifconfig | grep ^[a-z] | awk '{print $1}'` # ^^^^^ should be quoted to prevent globbing. # The following also work. # echo $(/sbin/ifconfig | awk '/^[a-z]/ { print $1 })' # echo $(/sbin/ifconfig | sed -e 's/ .*//')

 HOPE YOU FIND IT USEFUL AND I AM ALWAYS AVAILABLE TO HELP, FEEL FREE IF YOU NEED MORE ASSISTANCE

 

Related Questions