Flickr Photos

Young Red Fox
Red Fox eating rowan berries
Roe Deer
Leopard in the rain
Lion mum taking care of cubs
Male Lion
Lion Cubs Playing
Leopard
Lazy Spotted Hyena
Female Lion
Cheetah
Golden Jackal

Enabling/Disabling devices using command line on windows

I needed to disable smartcard reader on my client laptop because for some reason it had two smartcard readers and I only needed to use one so I had to disable that device on every laptop which I installed so I wanted to make it a bit easier for me.

First of all you need to download DevCon from Microsoft website.

For some really weird reason I wanted to disable all Nokia devices on my system I use:
devcon disable *nokia*
This will disable all device which have word nokia on their id, description or so on.

When I want to enable all Nokia devices I just say:
devcon enable *nokia*

If you know which device you want to disable/enable but you don’t know how to disable it just use
devcon hwids *
and search your device from that list. Then you need to find something which is only with that device so you won’t enable/disable wrong devices.
You can do that using find with devcon:
devcon find *nokia*
and you should see which device devcon see. If it only find one device then you can use that *nokia* string but if it finds more than one device then you need to find better string for devcon (example hwid if nothing else).

Because I’m lazy I do small script for everything =)
My enable script is on.bat:


devcon enable *%1*

and off.bat script:

devcon disable *%1*

So I can just say: on nokia and all my Nokia devices will be enabled or off nokia and all Nokia devices will be disabled :-)
When I want to know if something is enabled or disabled (when you example want to write script where you need that information you can do something like that (my ask.bat):


@echo off

set x=0

devcon status "*%1*"|find /i "running" && set x=1

if %x%==0 echo Nope it's not running

if %x%==1 echo Yep it's running

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>