PDA

You are currently viewing a search engine-friendly (archive) version of this page.

View Full Version : Enable/Disable Hardware in Windows 2000 with VB?


Talismaniac
May 24, 2001, 05:18 pm
I am looking for a way to disable one piece of hardware (digital pad) from a Windows 2000 machine. This pad is used for two different CAD programs, one requires special drivers from the pad and the other won't work with the drivers.

I would like to make a program in Visual Basic that will toggle the hardware enabled or disabled depending on what CAD program is being used.

Any know of some sample code or modules to do this or something similar enough I can make it work?


------------------
The Ultimate (http://www.traitnet.com/ubblist.htm) List for PC Support!

Tonker
May 25, 2001, 10:24 am
I'm afraid I don't know very much about win2k. I know in NT4 you can use netstart or netstop from the command prompt to start and stop devices. You can probably make a system call in VB to invoke these if they work in 2k.

You might also try the Operating System forum. They might have some ideas.

Good luck,

------------------

Talismaniac
May 25, 2001, 10:43 am
Thanks Tonker, that works for services, is it possible to get to the device manager from the net command? Or can I start and stop devices using services?

------------------
The Ultimate (http://www.traitnet.com/ubblist.htm) List for PC Support!

<FONT COLOR="#800080" SIZE="1" FACE="Verdana, Arial">This message has been edited by Talismaniac on May 25, 2001 at 07:46 AM</font>

Tonker
May 25, 2001, 10:50 am
I think it is possible. We do it here when we need to restart the drivers for our PCMCIA Card Readers. Here is an example of the batch file I have to do that. LunaCR is the driver that I want to stop.

net stop LunaCR
net start LunaCR

I don't actually know how to make an operating system call in VB, but how hard can it be, right? http://www.helpfromtechs.com/ubb/smilies/wink.gif

------------------

Talismaniac
May 25, 2001, 11:11 am
I might be missing something but I think that will only work if the device is dependent on a service.

------------------
The Ultimate (http://www.traitnet.com/ubblist.htm) List for PC Support!

Tonker
May 25, 2001, 11:58 am
You could be right. I've never really played with device drivers much. You might want to see if you can find the name of the driver in devices under control panel, then see if net stop and net start work on them.

------------------

Talismaniac
May 25, 2001, 12:05 pm
I did, it doesn't.

I haven't been able to find anything on the internet for this either. It doesn't seem like it would be all that uncommon of a task.

Anyway, thanks for the help!

------------------
The Ultimate (http://www.traitnet.com/ubblist.htm) List for PC Support!

Talismaniac
May 30, 2001, 04:40 pm
Some one from another board showed me a way using Send Keys. I have been able to make it work in a VB EXE.

I have one more question though, is there a way to test if the device is enabled first?

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "devmgmt.msc"
While WshShell.AppActivate("Device Manager") = False
Wend
WshShell.AppActivate "Device Manager"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "Mice"
WshShell.SendKeys "{Right}"
WshShell.SendKeys "{Down}"
WshShell.SendKeys "+{F10}"
WshShell.SendKeys "D"
WshShell.SendKeys "%Y"
WshShell.SendKeys "%{F4}"

------------------
The Ultimate (http://www.traitnet.com/ubblist.htm) List for PC Support!