#156769 - 2006-02-07 04:23 PM
Re: ScanHardware
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
I'm assuming you are looking for a WMI way to do it, and for that I can't help. But if you are willing to use an external utility devcon is your friend.
|
Top
|
|
|
|
#156770 - 2006-02-07 04:23 PM
Re: ScanHardware
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
|
Thanks
But it's not exactly the process I'm looking for. It is close though When you enter the Device Manager you can select "Scan for Hardware Changes" it is a slightly different process then the hdwwiz.cpl you mentioned
[edit] yeah I know about devcon, but I believe there must be a "windows" way to do it as well.
Edited by apronk (2006-02-07 04:24 PM)
|
Top
|
|
|
|
#156772 - 2006-02-08 08:50 AM
Re: ScanHardware
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
|
Jooel, thanks for your efforts After looking into the matter even further it seems your first option was the most suitable altho not in the fashion you've state it. Let me try to explain the whole thing.
Once a machine gets hookedup to our network the loginscript I've wrote sets the registry paths for Device Drivers to a network location. But since the machine is already installed and found no drivers for certain hardware items it isn't gonna look again after the paths are changed. Thats where this scanned comes in. the "Scan for Hardware Changes" in the device manager doesnt change anything because the devices aren't changed. However I did find that if you remove the unknown device and then scan for hardware changes. (also like Allen stated devcon does the trick for scanning for hardware changes) it does work. But when you rightclick the unknown device and then invoke the "update driver" function it also works, I think this could be done in Win32_PnPEntity wich can enumerate all hardware devices just have to try to get it to return devices that have no drivers.
|
Top
|
|
|
|
#156773 - 2006-02-08 09:12 AM
Re: ScanHardware
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
|
(Update) I've writtem a script that shows the devices that don't have any drivers yet, only thing left to do it to get the script to actually remove the devices from the device manager and then a script that scans for "new hardware" and all should be fine
Code:
$strComputer = "." $objWMIService = GetObject("winmgmts:\\" + $strComputer + "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * from Win32_PNPEntity Where ConfigManagerErrorCode <> 0")
For Each $objItem in $colItems ? "Name: " + $objItem.Name Next
|
Top
|
|
|
|
#156779 - 2006-02-08 11:58 AM
Re: ScanHardware
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
|
Indeed, but I still have to find out how to remove the hardware Listing it is no problem.
|
Top
|
|
|
|
#156781 - 2006-02-08 01:25 PM
Re: ScanHardware
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
|
So far I can conclude this: 1. Scan with WMI wich devices don't have drivers (code posted earlier). 2. Use WMI to get the DeviceID. 3. Pass the DeviceID to Devcon to remove the HW (this works sucky to say the least) Devcon removes more thn bargained for. 4. Let devcon scan for new HW (this does work nicely), devices get detected and the drivers get installed from the path I've specified in the registry.
So if there is a way that WMI can remove the devices im basically finished although I'd prefer to do everything from withitn Kix/WMI.
Again thanks for your efforts, I apreciate it alot
|
Top
|
|
|
|
#156784 - 2006-02-08 02:21 PM
Re: ScanHardware
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
|
So far I have this: It basically works, but the removing part removes WAAAAYY yoo many devices, needless to say it's buggy as shizne. Code:
$strComputer = "." $objWMIService = GetObject("winmgmts:\\" + $strComputer + "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * from Win32_PNPEntity Where ConfigManagerErrorCode <> 0")
For Each $objItem in $colItems ? "Name: " + $objItem.Name ? "Attempting to Remove " + $objItem.Name $DeviceID = CStr($objItem.DeviceID) Shell "%comspec% /c %windir%\system32\devcon.exe remove " + "$DeviceID" Next Shell "%comspec% /c %windir%\system32\devcon.exe rescan"
[edit]
Just forget the way devcon removes hardware, it does indeed remove hardware but also hardware you did not specify, basically it sucks, im not spending more time on devcon for removing hardware.
Edited by apronk (2006-02-08 02:27 PM)
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 252 anonymous users online.
|
|
|