Beginners Guide To Dev Con

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Beginners Guide to Devcon

What is Devcon:
Devcon is a what they call a command line utility for interacting with hardware on a machine. It can do loads
of fairly powerful things with just simple commands. The ones we are interested in here are mainly enabling
and disabling devices so that windows can start up properly. Because its command line there isnt any
windows forms or GUI screens for it and its all controlled from a DOS box with text. This makes it difficult for
more modern users to get to grips with as they never really have to go into a DOS box these days.
What you need:
To use Devcon properly you need to download and install four free bits of software.
http://support.microsoft.com/?kbid=311272
Devcon itself
http://www.autoitscript.com/autoit3/downloads.php These are optional
AutoIt and SciTE
Hibernate Trigger
http://www.desimonesystems.com/suspendtrigger/index.php
Download all these and install them. The Devcon download isnt actually an installer its just an auto extract zip
file. I would recommend you uninstall it to c:\devcon, you will see why later. Of course this has to be on your
car PC or it isnt going to work. Once unpacked go into the Devcon folder and then into either the i386 folder
or ia64 if your running 64bit windows (unlikely), then copy the Devcon.exe directly onto the root of the C
drive. Thats c:\, if windows isnt on your C drive copy it onto the root of that drive instead. Just accept the
default locations for all the other programs AutoIt and SciTE can be on any PC as they are programming tools
but Hibernate needs to be on the car PC too.
Getting started:
Right lets start doing what this is all about. This is a beginners guide so I am not going to go into all the
Devcon commands but if you want you can have a play.
First of we need to open a DOS box so go to start then run and in the run window that opens type cmd
without the quotes. You will now have a new window opened with some text and a flashing cursor. Type cd
c:\ again without the quotes. This changes the directory to where you have Devcon (this is why I got you to
copy Devcon here because its easy) if you didnt put Devcon there then change the path to where ever it is.
You should now have this.

Just to see what you can all do we will type devcon ? you will get a return like this with all the base
commands.

Here you will see the three commands we are going to use which are hwids, enable and disable.
First what you need to do is get the hardware ID of the device your having problems. To get this you use the
hwids (hardware ids) command. Type devcon /hwids *usb* the *usb* part limits the search to usb devices
only since thats what we are having problems with. You could just use devcon /hwids * and it will return
every bit of hardware you have but the list could be huge. Again you MUST be doing this part on your car PC
as the ID will change between different machines. Ok you have done that and you get a window that looks like
this.

I will pick on the Bluetooth adapter just because its on the machine I am using but you need to look for the
device or devices thats causing you the problem. From the picture bellow you can see that there is a hardware
ID with a PID number.

In this case its Pid_8103 but yours will be different. You can use the whole USB\Vid.. but why make life
difficult and type more. Ok so you have done that and you have your ID right? Believe it or not your just
about done as you have done the hard bit. With this ID we are ready to use the other two commands which will
look like this.
"c:\devcon disable *pid_8103*"
"c:\devcon enable *pid_8103*"
Remember you need to substitute your ID in there and where you have Devcon. If you like you can type this
in, go to device manager and you will see device getting disabled and enabled. You will also get a message
back in the DOS box telling you if it has worked or not. At this point you could open notepad type in one of the
commands save it as a .bat file, do the same with the other command and your done. A .bat file is whats
known as a batch file if you didnt know and you can actually run it by double clicking it try it if you like. The
problem with this is that it is messy and as you PC goes up and down you get the DOS box appearing for every
.bat file you run. This is why I will show you how to use AutoIt to do this as its invisible.
Using AutoIt to make a program:
This isnt the place to get technical with AutoIt so just copy the text I type and change the bits you need to but I
would recommend having a look through the software itself as its actually really powerful and can do a lot
more than your about to right now. Ok lets start and open SciTE which will be under the AutoIt bit in your
start/programs. This is little more than a fancy notepad that makes using AutoIt much easier. Now you have
done that copy the text below and paste it into SciTE.
#include <Process.au3>
$rc = _RunDos("c:\devcon disable *pid_8103*")
Copy and paste the whole thing. The command _RunDos is the part that allows us to run the command without
it showing a horrible DOS box.
If you have done it right you will get something like the picture below. Now change the PID number to
whatever yours is and dont forget the path to Devcon if it isnt in c:\ but be careful not to add any extra spaces
and stuff or it wont work.

I have underlined the bit you need to look at to change so obviously you wont have the red line. Now you want
to save this so go to file/save as and give it a name. As this is the disable one you will use it when going into
hibernation so call it something like stop.au3 but its up to you. Next you want to compile this into a .exe so go
to tools/compile. You will get a window like bellow but it will have your names and locations in it.

You can get all fancy and compile it with your own icon if you like but for now just keep it simple. Check the
names and click compile. Congratulations if your reading this you have probably just written your first
program, who said you couldnt write code? Leave the beer for now though and lets get this finished. Thats
the disable one done so repeat the above for the enable. You can just edit the code above to read.
#include <Process.au3>
$rc = _RunDos("c:\devcon enable *pid_8103*")
With your ID and path of course save it as start.au3 or whatever and compile it to another .exe. Ok your nearly
there copy your two programs into c:\ and you can test them if you like by double clicking them. This time the
only way you will know if it has worked is by looking at the device manager and its invisible now.
Getting this to all work:
To get all this to execute going into hibernate and coming back out from it we use a program called Hibernate
Trigger. This senses what the PC is doing and will run the programs you have just compiled. If you havent
already install it and put a shortcut to it in the start/all programs/startup. This just makes sure that if you ever
completely reboot your PC or switch it off Hibernate Trigger will start again. Start the program and you will
get a window like this only the paths will be blank.

Type in the paths to your programs, this is why I like to use c:\ for the programs as its easy. All you have to do
now is minimise and your done. Note if you click the cross you will shut the program down but minimise puts
it down by the system clock ready to do its thing. I should add that when all this happens it does it very quickly
so you wont have any performance issues with it slowing the PC down
Like I said thats it your done and you can test it. If you have done everything like I said and got the right IDs
your PC will now work perfectly and nobody will know whats happening in the background.
A coupe of things I should add is that you might have a couple of devices causing you problems. All you have
to do is repeat the line $rc = _RunDos("c:\devcon enable *pid_8103*") putting in the other ID until you have
added them all like this.
#include <Process.au3>
$rc = _RunDos("c:\devcon enable *pid_8103*")
$rc = _RunDos("c:\devcon enable *pid_8104*")
$rc = _RunDos("c:\devcon enable *pid_8105*")
There are many more things you can do this way like starting stopping programs auto mouse clicks and the list
goes on so this is really just a very basic intro and its up to you now to learn and do your thing.
Now you can get the beer out

You might also like