Condividi tramite


Esempi di Console del dispositivo (DevCon.exe)

This article provides examples to demonstrate various Device Console (DevCon.exe) commands, including hardware identifiers (IDs), classes, driver files, installing and scanning, and more.

Important

Administrators are recommended to use the PnPUtil command line tool rather than the Device Console sample. Lo strumento PnPUtil viene fornito con ogni versione di Windows e usa le API più affidabili e sicure disponibili. Per altre informazioni sull'uso di PnPutil invece della console del dispositivo, vedere Sostituzione della console del dispositivo.

Example categories

The article provides examples for the following categories of Device Console commands, or DevCon for short.

Category Examples
HwIDs Esempio 1: Trovare tutti gli ID
hardwareEsempio 2: Trovare GLI ID hardware usando un modello
Esempio 3: Trovare GLI ID hardware usando una classe
Classes Esempio 4: Elencare le classi nel computer locale
ListClass Esempio 6: Elencare i dispositivi in una classe
di configurazione del dispositivoEsempio 7: Elencare i dispositivi in più classi
DriverFiles Esempio 8: Elencare tutti i file
driverEsempio 9: Elencare i file driver di un dispositivo specifico
DriverNodes Esempio 10: Elencare i pacchetti driver in base al modello
ID hardwareEsempio 11: Elencare i pacchetti driver in base al modello id istanza del dispositivo
Resources Esempio 12: Elencare le risorse di una classe di dispositivi
Esempio 13: Elencare le risorse di un dispositivo in base all'ID
Stack Esempio 14: Visualizzare lo stack di driver per i dispositivi
di archiviazioneEsempio 15: Trovare la classe di installazione di un dispositivo
Esempio 16: Visualizzare lo stack per i dispositivi correlati
Status Esempio 17: Visualizzare lo stato di tutti i dispositivi nel computer
localeEsempio 18: Visualizzare lo stato di un dispositivo in base all'ID
istanza del dispositivoEsempio 19: Visualizzare lo stato dei dispositivi correlati
Find Esempio 20: Trovare i dispositivi in base al modello
ID hardwareEsempio 21: Trovare i dispositivi in base all'ID o alla classe dell'istanza del dispositivo
FindAll Esempio 22: Trovare (e trovare tutti) i dispositivi in una classe di installazione
ClassFilter Esempio 23: Visualizzare i driver di filtro per una classe
di installazioneEsempio 24: Aggiungere un driver di filtro a una classe
di installazioneEsempio 25: Inserire un driver di filtro nell'elenco
classiEsempio 26: Sostituire un driver
di filtroEsempio 27: Modificare l'ordine dei driver di filtro
Enable Esempio 28: Abilitare un dispositivo
specificoEsempio 29: Abilitare i dispositivi per classe
Disable Esempio 30: Disabilitare i dispositivi in base a un modello
IDEsempio 31: Disabilitare i dispositivi in base all'ID istanza del dispositivo
Aggiornare e aggiornare l'nic Esempio 32: Aggiornare il driver per le porte
di comunicazioneEsempio 44: aggiornare forzatamente il livello di astrazione hardware (HAL)
Install Esempio 33: Installare un dispositivo
Esempio 34: Installare un dispositivo usando l'installazione automatica
Remove Esempio 35: Rimuovere i dispositivi in base al modello
id istanza del dispositivoEsempio 36: Rimuovere un dispositivo di rete specifico
Rescan Esempio 37: Analizzare il computer per individuare nuovi dispositivi
Restart Esempio 38: Riavviare un dispositivo
Reboot Esempio 39: Riavviare il computer locale
SetHwID Esempio 40: Assegnare un ID hardware a un dispositivo
legacyEsempio 41: Aggiungere un ID hardware a tutti i dispositivi
legacyEsempio 42: Eliminare un ID hardware da tutti i dispositivi
legacyEsempio 43: Aggiungere, eliminare e sostituire gli ID
hardwareEsempio 44: aggiornare forzatamente l'HAL
dp_add, dp_deleted, dp_enum Esempio 45: Aggiungere e rimuovere pacchetti driver

Example details

Gli esempi DevCon completi sono disponibili nelle sezioni seguenti.

Esempio 1: Trovare tutti gli ID hardware

Le operazioni DevCon usano ID e modelli ID per identificare i dispositivi. Di conseguenza, un primo passaggio comune per l'uso di DevCon consiste nel creare un file di riferimento id hardware per i dispositivi nel computer.

The following command uses the DevCon HwIDs operation, which returns the IDs and the device description. Il comando usa il carattere jolly asterisco (*) per rappresentare tutti i dispositivi nel computer locale.

devcon hwids *

Poiché l'output è lungo e usato ripetutamente, salvare l'output in un file di testo per riferimento.

Il comando seguente estende il comando precedente con il carattere di reindirizzamento (>). The redirection saves the command output in the specified file, hwids.txt.

devcon hwids * > hwids.txt

Esempio 2: Trovare GLI ID hardware usando un modello

Per trovare gli ID hardware di un determinato dispositivo, immettere uno dei valori seguenti con il comando :

  • ID hardware o modello
  • ID o modello compatibile
  • ID o modello dell'istanza del dispositivo
  • Nome della classe di installazione del dispositivo

The following command uses the DevCon HwIDs operation and a pattern to find the hardware IDs of the floppy disk drive on the computer. L'utente presuppone che il modello venga visualizzato in uno degli ID dispositivo. Il comando usa il carattere jolly (*) per rappresentare tutti i caratteri che potrebbero precedere o seguire la parola floppy in uno qualsiasi degli ID.

devcon hwids *floppy*

In risposta, DevCon visualizza l'ID istanza del dispositivo, l'ID hardware e l'ID compatibile dell'unità disco floppy nel computer. È possibile usare questi ID nei comandi DevCon successivi.

FDC\GENERIC_FLOPPY_DRIVE\5&39194F6D&0&0
    Name: Floppy disk drive
    Hardware ID's:
        FDC\GENERIC_FLOPPY_DRIVE
    Compatible ID's:
        GenFloppyDisk
1 matching device(s) found.

In questo esempio, la frase "floppy" si verifica nell'ID hardware o nell'ID compatibile di un solo dispositivo nel computer. Se la frase si verifica nell'ID di più dispositivi, tutti i dispositivi con la frase "floppy" nei relativi ID vengono visualizzati nell'output.

Esempio 3: Trovare GLI ID hardware usando una classe

The following command uses the DevCon HwIDs operation and a device setup class to find the hardware IDs of all devices in the Ports device setup class. Il simbolo uguale (=) che precede il nome della classe indica che il valore specificato è una classe e non un ID.

devcon hwids =ports

In risposta, DevCon visualizza gli ID hardware e gli ID compatibili dei tre dispositivi nella classe di installazione Porte:

ACPI\PNP0401\4&B4063F4&0
    Name: ECP Printer Port (LPT1)
    Hardware ID's:
        ACPI\PNP0401
        *PNP0401
ACPI\PNP0501\1
    Name: Communications Port (COM1)
    Hardware ID's:
        ACPI\PNP0501
        *PNP0501
ACPI\PNP0501\2
    Name: Communications Port (COM2)
    Hardware ID's:
        ACPI\PNP0501
        *PNP0501
3 matching device(s) found.

Esempio 4: Elencare le classi nel computer locale

Poiché le operazioni DevCon possono usare la classe di installazione del dispositivo per identificare i dispositivi, è utile creare un file di riferimento delle classi di installazione dei dispositivi nel computer.

The following command uses the DevCon Classes operation, which returns a list and description of all classes on the computer.

devcon classes

Poiché l'output è lungo e usato ripetutamente, salvare l'output in un file di testo per riferimento.

Il comando seguente visualizza tutte le classi di dispositivo nel computer. It uses the redirection character (>) to save the command output in the specified file, classes.txt.

devcon classes > classes.txt

Esempio 6: Elencare i dispositivi in una classe di configurazione del dispositivo

The following command uses the DevCon ListClass operation to list the devices in Net, the device setup class for network adapters.

devcon listclass net

In risposta, DevCon visualizza l'ID istanza del dispositivo e la descrizione di ogni dispositivo nella classe Net setup:

Listing 6 device(s) for setup class "Net" (Network adapters).
PCI\VEN_10B7&DEV_9200&SUBSYS_00BE1028&REV_78\4&BB7B4AE&0&60F0: 3Com 3C920 Integrated Fast Ethernet Controller (3C905C-TX Compatible)
ROOT\MS_L2TPMINIPORT\0000                                   : WAN Miniport (L2TP)
ROOT\MS_NDISWANIP\0000                                      : WAN Miniport (IP)
ROOT\MS_PPPOEMINIPORT\0000                                  : WAN Miniport (PPPOE)
ROOT\MS_PPTPMINIPORT\0000                                   : WAN Miniport (PPTP)
ROOT\MS_PTIMINIPORT\0000                                    : Direct Parallel

Anche se la risposta del comando è interessante, non fornisce gli ID hardware dei dispositivi nella classe di installazione net.

The following command uses the DevCon HwIDs operation to list the devices in the Net setup class. In a DevCon HwIDs command, the equals symbol (=) precedes the value to indicate that the value is a class and not an ID.

devcon hwids =net

La visualizzazione risultante elenca i dispositivi nella classe Net e include l'ID istanza del dispositivo, gli ID hardware e gli ID compatibili dei dispositivi nella classe .

PCI\VEN_10B7&DEV_9200&SUBSYS_00BE1028&REV_78\4&BB7B4AE&0&60F0
    Name: 3Com 3C920 Integrated Fast Ethernet Controller (3C905C-TX Compatible)
    Hardware ID's:
        PCI\VEN_10B7&DEV_9200&SUBSYS_00BE1028&REV_78
        PCI\VEN_10B7&DEV_9200&SUBSYS_00BE1028
        PCI\VEN_10B7&DEV_9200&CC_020000
        PCI\VEN_10B7&DEV_9200&CC_0200
    Compatible ID's:
        PCI\VEN_10B7&DEV_9200&REV_78
        PCI\VEN_10B7&DEV_9200
        PCI\VEN_10B7&CC_020000
        PCI\VEN_10B7&CC_0200
 PCI\VEN_10B7
        PCI\CC_020000
 PCI\CC_0200
ROOT\MS_L2TPMINIPORT\0000
    Name: WAN Miniport (L2TP)
    Hardware ID's:
        ms_l2tpminiport
ROOT\MS_NDISWANIP\0000
    Name: WAN Miniport (IP)
    Hardware ID's:
        ms_ndiswanip
ROOT\MS_PPPOEMINIPORT\0000
    Name: WAN Miniport (PPPOE)
    Hardware ID's:
        ms_pppoeminiport
ROOT\MS_PPTPMINIPORT\0000
    Name: WAN Miniport (PPTP)
    Hardware ID's:
        ms_pptpminiport
ROOT\MS_PTIMINIPORT\0000
    Name: Direct Parallel
    Hardware ID's:
        ms_ptiminiport
6 matching device(s) found.

Esempio 7: Elencare i dispositivi in più classi

The following command uses the DevCon ListClass operation to list the devices in the DiskDrive, CDROM, and TapeDrive classes.

devcon listclass diskdrive cdrom tapedrive

In risposta, DevCon visualizza i dispositivi in tali classi:

Listing 1 device(s) for setup class "DiskDrive" (Disk drives).
IDE\DISKWDC_WD204BA_____________________________16.13M16\4457572D414D3730323136333938203120202020: WDC WD204BA
Listing 1 device(s) for setup class "CDROM" (DVD/CD-ROM drives).
IDE\CDROMSAMSUNG_DVD-ROM_SD-608__________________2.2_____\4&13B4AFD&0&0.0.0: SAMSUNG DVD-ROM SD-608
No devices for setup class "TapeDrive" (Tape drives).

Esempio 8: Elencare tutti i file driver

The following command uses the DevCon DriverFiles operation to list the file names of drivers that devices on the system use. Il comando usa il carattere jolly (*) per rappresentare tutti i dispositivi nel sistema. Because the output is extensive, it uses the redirection character (>) to save the command output in the specified file, driverfiles.txt.

devcon driverfiles * > driverfiles.txt

Esempio 9: Elencare i file driver di un dispositivo specifico

The following command uses the DevCon DriverFiles operation to search for the device driver used by the mouse device on the local computer. Il comando identifica il dispositivo in base a uno dei relativi ID hardware, HID\Vid_045e&Pid_0039&Rev_0121. L'ID hardware è racchiuso tra virgolette (" ") perché include il simbolo di e commerciale (&).

devcon driverfiles "HID\Vid_045e&Pid_0039&Rev_0121"

In risposta, DevCon visualizza i due driver di dispositivo che supportano il dispositivo mouse:

HID\VID_045E&PID_0039\6&DC36FDE&0&0000
    Name: Microsoft USB IntelliMouse Optical
    Driver installed from c:\windows\inf\msmouse.inf [HID_Mouse_Inst]. 2 file(s)
 used by driver:
        C:\WINDOWS\System32\DRIVERS\mouhid.sys
        C:\WINDOWS\System32\DRIVERS\mouclass.sys
1 matching device(s) found.

Esempio 10: Elencare i pacchetti driver in base al modello ID hardware

The following command uses the DevCon DriverNodes command and an ID pattern to list the driver nodes of software-enumerated devices. I modelli sono utili per trovare informazioni su dispositivi simili che potrebbero non trovarsi nella stessa classe di installazione.

The following command uses the ID pattern sw* to specify devices with hardware IDs or compatible IDs that begin with "sw" for software-enumerated devices.

devcon drivernodes sw*

In risposta, DevCon visualizza i nodi driver dei dispositivi enumerati dal software nel sistema:

SW\{A7C7A5B0-5AF3-11D1-9CED-00A024BF0407}\{9B365890-165F-11D0-A195-0020AFD156E4}

 Name: Microsoft Kernel System Audio Device
DriverNode #0:
    Inf file is c:\windows\inf\wdmaudio.inf
    Inf section is WDM_SYSAUDIO
    Driver description is Microsoft Kernel System Audio Device
    Manufacturer name is Microsoft
    Provider name is Microsoft
    Driver date is 7/1/2001
    Driver version is 5.1.2535.0
    Driver node rank is 0
    Driver node flags are 00002244
        Inf is digitally signed
SW\{B7EAFDC0-A680-11D0-96D8-00AA0051E51D}\{9B365890-165F-11D0-A195-0020AFD156E4}

    Name: Microsoft Kernel Wave Audio Mixer
DriverNode #0:
    Inf file is c:\windows\inf\wdmaudio.inf
    Inf section is WDM_KMIXER
    Driver description is Microsoft Kernel Wave Audio Mixer
    Manufacturer name is Microsoft
    Provider name is Microsoft
    Driver date is 7/1/2001
    Driver version is 5.1.2535.0
    Driver node rank is 0
    Driver node flags are 00002244
        Inf is digitally signed
SW\{CD171DE3-69E5-11D2-B56D-0000F8754380}\{9B365890-165F-11D0-A195-0020AFD156E4}

    Name: Microsoft WINMM WDM Audio Compatibility Driver
DriverNode #0:
    Inf file is c:\windows\inf\wdmaudio.inf
    Inf section is WDM_WDMAUD
    Driver description is Microsoft WINMM WDM Audio Compatibility Driver
    Manufacturer name is Microsoft
    Provider name is Microsoft
    Driver date is 7/1/2001
    Driver version is 5.1.2535.0
    Driver node rank is 0
    Driver node flags are 00002244
        Inf is digitally signed
3 matching device(s) found.

Esempio 11: Elencare i pacchetti driver in base al modello id istanza del dispositivo

The following command uses the DevCon DriverNodes operation to list the driver packages of all devices with device instance IDs that begin with ROOT\MEDIA for devices in the Enum\Root\Media registry subkey. The command uses the at symbol (@) to indicate that the phrase is in the device instance ID.

devcon drivernodes @ROOT\MEDIA*

In risposta, DevCon visualizza i nodi driver dei dispositivi con un ID istanza del dispositivo che inizia con ROOT\MEDIA:

ROOT\MEDIA\MS_MMACM
    Name: Audio Codecs
DriverNode #0:
    Inf file is c:\windows\inf\wave.inf
    Inf section is MS_MMACM
    Driver description is Audio Codecs
    Manufacturer name is (Standard system devices)
    Provider name is Microsoft
    Driver date is 7/1/2001
    Driver version is 5.1.2535.0
    Driver node rank is 0
    Driver node flags are 00002240
        Inf is digitally signed
ROOT\MEDIA\MS_MMDRV
    Name: Legacy Audio Drivers
DriverNode #0:
    Inf file is c:\windows\inf\wave.inf
    Inf section is MS_MMDRV
    Driver description is Legacy Audio Drivers
    Manufacturer name is (Standard system devices)
    Provider name is Microsoft
    Driver date is 7/1/2001
    Driver version is 5.1.2535.0
    Driver node rank is 0
    Driver node flags are 00002240
        Inf is digitally signed
ROOT\MEDIA\MS_MMMCI
    Name: Media Control Devices
DriverNode #0:
    Inf file is c:\windows\inf\wave.inf
    Inf section is MS_MMMCI
    Driver description is Media Control Devices
    Manufacturer name is (Standard system devices)
    Provider name is Microsoft
    Driver date is 7/1/2001
    Driver version is 5.1.2535.0
    Driver node rank is 0
    Driver node flags are 00002240
        Inf is digitally signed
ROOT\MEDIA\MS_MMVCD
    Name: Legacy Video Capture Devices
DriverNode #0:
    Inf file is c:\windows\inf\wave.inf
    Inf section is MS_MMVCD
    Driver description is Legacy Video Capture Devices
    Manufacturer name is (Standard system devices)
    Provider name is Microsoft
    Driver date is 7/1/2001
    Driver version is 5.1.2535.0
    Driver node rank is 0
    Driver node flags are 00002240
        Inf is digitally signed
ROOT\MEDIA\MS_MMVID
    Name: Video Codecs
DriverNode #0:
    Inf file is c:\windows\inf\wave.inf
    Inf section is MS_MMVID
    Driver description is Video Codecs
    Manufacturer name is (Standard system devices)
    Provider name is Microsoft
    Driver date is 7/1/2001
    Driver version is 5.1.2535.0
    Driver node rank is 0
    Driver node flags are 00002240
        Inf is digitally signed
5 matching device(s) found.

Esempio 12: Elencare le risorse di una classe di dispositivi

The following command uses the DevCon Resources operation to display the resources allocated to devices in the Hdc device setup class. Questa classe include controller IDE. La sintassi precede il nome hdc della classe con il simbolo uguale (=) per indicare che il valore specificato è una classe e non un ID.

devcon resources =hdc

In risposta, DevCon elenca le risorse allocate ai controller IDE nel computer locale:

PCI\VEN_8086&DEV_244B&SUBSYS_00000000&REV_02\3&29E81982&0&F9
    Name: Intel(r) 82801BA Bus Master IDE Controller
    Device is currently using the following resources:
        IO  : ffa0-ffaf
PCIIDE\IDECHANNEL\4&37E53584&0&0
    Name: Primary IDE Channel
    Device is currently using the following resources:
        IO  : 01f0-01f7
        IO  : 03f6-03f6
        IRQ : 14
PCIIDE\IDECHANNEL\4&37E53584&0&1
    Name: Secondary IDE Channel
    Device is currently using the following resources:
        IO  : 0170-0177
        IO  : 0376-0376
        IRQ : 15
3 matching device(s) found.

Esempio 13: Elencare le risorse del dispositivo in base all'ID

The following command uses the DevCon Resources operation to list the resources allocated to the system timer. Il comando usa l'ID hardware del timer di sistema, ACPI\PNP0100, per specificare il dispositivo.

devcon resources *PNP0100

In risposta, DevCon visualizza le risorse del timer di sistema:

ROOT\*PNP0100\PNPBIOS_8
    Name: System timer
    Device has the following resources reserved:
        IO  : 0040-005f
        IRQ : 0
1 matching device(s) found.

Il comando seguente usa l'ID istanza del dispositivo del timer di sistema nel comando DevCon resources . The command uses the at symbol (@) to indicate that the string is a device instance ID and not a hardware ID or compatible ID.

devcon resources "@ACPI\PNP0100\4&b4063f4&0"

Esempio 14: Visualizzare lo stack di driver per i dispositivi di archiviazione

The following command uses the DevCon Stack operation to search for devices in the Volume setup class and display the expected driver stack for those devices. Il simbolo di uguale (=) precede la stringa per indicare che il valore è una classe e non un ID.

devcon stack =Volume

In risposta, DevCon visualizza lo stack previsto per i dispositivi nella classe Volume. I dati restituiti includono le informazioni seguenti:

  • ID istanza del dispositivo e descrizione di ogni dispositivo
  • GUID e nome della classe di installazione del dispositivo
  • Nomi dei driver di filtro superiore e inferiore
  • Controllo dei servizi (se presenti)
STORAGE\VOLUME\1&30A96598&0&SIGNATURE32323533OFFSET271167600LENGTH6E00D0C00
    Name: Generic volume
    Setup Class: {71A27CDD-812A-11D0-BEC7-08002BE2092F} Volume
    Class upper filters:
        VolSnap
    Controlling service:
        (none)
STORAGE\VOLUME\1&30A96598&0&SIGNATURE32323533OFFSET7E00LENGTH27115F800
    Name: Generic volume
    Setup Class: {71A27CDD-812A-11D0-BEC7-08002BE2092F} Volume
    Class upper filters:
        VolSnap
    Controlling service:
        (none)
2 matching device(s) found.

Esempio 15: Trovare la classe di installazione di un dispositivo

The DevCon Stack operation returns the setup class of a device in addition to the upper and lower filter drivers. I comandi seguenti individuano la classe di installazione dell'interfaccia della porta della stampante individuandone l'ID istanza del dispositivo e quindi usando l'ID istanza del dispositivo per trovare la relativa classe di installazione.

The following command uses the DevCon HwIDs operation to find the device instance ID of the printer port interface. Cerca nella frase "LPT" all'interno dell'ID hardware della porta della stampante:

devcon hwids *lpt*

In risposta, DevCon restituisce l'ID istanza del dispositivo (visualizzato in grassetto) e l'ID hardware dell'interfaccia della porta della stampante:

LPTENUM\MICROSOFTRAWPORT\5&CA97D7E&0&LPT1
    Name: Printer Port Logical Interface
    Hardware ID's:
        LPTENUM\MicrosoftRawPort958A
        MicrosoftRawPort958A
1 matching device(s) found.

The next command uses the DevCon Stack operation to find the device setup class of the device represented by the device instance ID. The command uses the at symbol (@) to identify the ID as a device instance ID. L'ID è racchiuso tra virgolette (" ") perché include il simbolo di e commerciale (&).

devcon stack "@LPTENUM\MICROSOFTRAWPORT\5&CA97D7E&0&LPT1"

In risposta, DevCon visualizza lo stack di driver per l'interfaccia della porta della stampante, compresa la classe. Lo schermo rivela che la porta della stampante si trova nella classe System:

LPTENUM\MICROSOFTRAWPORT\5&CA97D7E&0&LPT1
    Name: Printer Port Logical Interface
    Setup Class: {4D36E97D-E325-11CE-BFC1-08002BE10318} System
    Controlling service:
        (none)
1 matching device(s) found.

The following command uses the DevCon Stack operation to display the expected stack for miniport driver devices. Cerca i dispositivi nella classe di configurazione rete che hanno "miniport" nel loro ID hardware o ID compatibile.

Questo comando limita prima la ricerca alla classe Net setup e quindi trova la stringa "miniport". Non trova dispositivi diversi dagli elementi della classe Net setup.

devcon stack =net *miniport*

In risposta, DevCon visualizza lo stack previsto per i driver miniport:

ROOT\MS_L2TPMINIPORT\0000
    Name: WAN Miniport (L2TP)
    Setup Class: {4D36E972-E325-11CE-BFC1-08002BE10318} Net
    Controlling service:
        Rasl2tp
ROOT\MS_PPPOEMINIPORT\0000
    Name: WAN Miniport (PPPOE)
    Setup Class: {4D36E972-E325-11CE-BFC1-08002BE10318} Net
    Controlling service:
        RasPppoe
    Lower filters:
        NdisTapi
ROOT\MS_PPTPMINIPORT\0000
    Name: WAN Miniport (PPTP)
    Setup Class: {4D36E972-E325-11CE-BFC1-08002BE10318} Net
    Controlling service:
        PptpMiniport
    Lower filters:
        NdisTapi
ROOT\MS_PTIMINIPORT\0000
    Name: Direct Parallel
    Setup Class: {4D36E972-E325-11CE-BFC1-08002BE10318} Net
    Controlling service:
        Raspti
    Lower filters:
        PtiLink
4 matching device(s) found.

Esempio 17: Visualizzare lo stato di tutti i dispositivi

The following command uses the DevCon Status operation to find the status of all devices on the local computer. It then saves the status in the status.txt file for logging or later review. Il comando usa il carattere jolly (*) per rappresentare tutti i dispositivi. It uses the redirection character (>) to save the command output in the specified file, status.txt.

devcon status * > status.txt

Esempio 18: Visualizzare lo stato di un dispositivo in base all'ID istanza del dispositivo

Il modo più affidabile per trovare lo stato di un particolare dispositivo consiste nell'usare l'ID istanza del dispositivo.

The following command uses the device instance ID of the I/O controller on the local computer in a DevCon Status command. Il comando include l'ID istanza del dispositivo, PCI\VEN_8086&DEV_1130&SUBSYS_00000000&REV_02\3&29E81982&0&00. The command uses the at symbol (@) to identify the string as a device instance ID. L'ID è racchiuso tra virgolette (" ") perché include il simbolo di e commerciale (&).

devcon status "@PCI\VEN_8086&DEV_1130&SUBSYS_00000000&REV_02\3&29E81982&0&00"

In risposta, DevCon visualizza lo stato del controller di I/O:

PCI\VEN_8086&DEV_1130&SUBSYS_00000000&REV_02\3&29E81982&0&00
    Name: Intel(R) 82815 Processor to I/O Controller - 1130
    Driver is running.
1 matching device(s) found.

The following command uses the DevCon Status operation to display the status of particular storage-related devices. Cerca i dispositivi seguenti:

  • Disco GenDisk
  • CD-ROM unità, GenCdRom
  • Unità disco floppy, FDC\GENERIC_FLOPPY_DRIVE
  • Volumi STORAGE\Volume
  • Gestione dischi logici, ROOT\DMIO
  • Gestione volumi, ROOT\FTDISK
  • Controller disco floppy, ACPI\PNP0700

Nel comando ogni ID è separato dagli altri in base agli spazi. Si noti che GenDisk e GenCdRom sono ID compatibili, mentre gli altri ID sono ID hardware.

devcon status GenDisk GenCdRom FDC\GENERIC_FLOPPY_DRIVE STORAGE\Volume ROOT\DMIO ROOT\FTDISK ACPI\PNP0700

In risposta, DevCon visualizza lo stato di ogni dispositivo:

FDC\GENERIC_FLOPPY_DRIVE\1&3A2146F1&0&0
    Name: Floppy disk drive
    Driver is running.
IDE\CDROMSAMSUNG_DVD-ROM_SD-608__________________2.2_____\4&13B4AFD&0&0.0.0
    Name: SAMSUNG DVD-ROM SD-608
    Driver is running.
IDE\DISKWDC_WD204BA_____________________________16.13M16\4457572D414D373032313633393820312
0202020
    Name: WDC WD204BA
    Driver is running.
ROOT\DMIO\0000
    Name: Logical Disk Manager
    Driver is running.
ROOT\FLOPPYDISK\0000
    Device has a problem: 28.
ROOT\FLOPPYDISK\0002
    Device has a problem: 01.
ROOT\FLOPPYDISK\0003
    Device has a problem: 01.
ROOT\FLOPPYDISK\0004
    Device is currently stopped.
ROOT\FTDISK\0000
    Name: Volume Manager
    Driver is running.
STORAGE\VOLUME\1&30A96598&0&SIGNATUREEA1AA9C7OFFSET1770DF800LENGTH3494AEA00
    Name: Generic volume
    Driver is running.
STORAGE\VOLUME\1&30A96598&0&SIGNATUREEA1AA9C7OFFSET7E00LENGTH1770CFC00
    Name: Generic volume
    Driver is running.
11 matching device(s) found.

Esempio 20: Trovare i dispositivi in base al modello ID hardware

The following command uses the DevCon Find operation to search for mouse devices. In particolare, il comando cerca i dispositivi con ID hardware o ID compatibili che includono la frase "mou":

devcon find *mou*

In risposta, DevCon individua due dispositivi mouse:

ROOT\*PNP0F03\1_0_21_0_31_0                                 : Microsoft PS/2 Mouse
ROOT\RDP_MOU\0000                                           : Terminal Server Mouse Driver

Poiché tutte le operazioni di visualizzazione devCon trovano anche ID hardware, è possibile usare qualsiasi operazione di visualizzazione per cercare gli ID hardware. Selezionare l'operazione in base al contenuto necessario nell'output. Ad esempio, per trovare i driver di dispositivo per i dispositivi correlati al mouse in un computer locale, inviare il comando seguente:

devcon driverfiles *mou*

In risposta, DevCon trova i dispositivi ed elenca i relativi driver:

HID\VID_045E&PID_0039\6&DC36FDE&0&0000
    Name: Microsoft USB IntelliMouse Optical
    Driver installed from c:\windows\inf\msmouse.inf [HID_Mouse_Inst]. 2 file(s) used by d
river:
        C:\WINDOWS\System32\DRIVERS\mouhid.sys
        C:\WINDOWS\System32\DRIVERS\mouclass.sys
ROOT\RDP_MOU\0000
    Name: Terminal Server Mouse Driver
    Driver installed from c:\windows\inf\machine.inf [RDP_MOU]. 2 file(s) used by driver:
        C:\WINDOWS\System32\DRIVERS\termdd.sys
        C:\WINDOWS\System32\DRIVERS\mouclass.sys
2 matching device(s) found.

Esempio 21: Trovare i dispositivi in base all'ID o alla classe dell'istanza del dispositivo

The following commands use the DevCon Find operation to display all legacy devices on the local computer. Poiché i dispositivi legacy non hanno un ID hardware, è necessario cercarli in base all'ID istanza del dispositivo (percorso del Registro di sistema), ROOT\LEGACYo alla relativa classe di installazione, LegacyDriver.

Il primo comando trova i driver legacy utilizzando un modello di ID istanza del dispositivo. The at symbol (@) precedes the ID pattern to indicate that the value is a device instance ID. The value is followed by the wildcard character (*) to instruct the command to find all devices in the specified ID, the ROOT\Legacy subkey:

devcon find @root\legacy*

Il secondo comando trova i dispositivi legacy cercando tutti i dispositivi nella classe LegacyDriver:

devcon find =legacydriver

Entrambi i comandi producono lo stesso output, in questo caso, trovando gli stessi 27 dispositivi legacy:

ROOT\LEGACY_AFD\0000                                        : AFD Networking Support Environment
ROOT\LEGACY_BEEP\0000                                       : Beep
ROOT\LEGACY_DMBOOT\0000                                     : dmboot
ROOT\LEGACY_DMLOAD\0000                                     : dmload
ROOT\LEGACY_FIPS\0000                                       : Fips
ROOT\LEGACY_GPC\0000                                        : Generic Packet Classifier
ROOT\LEGACY_IPSEC\0000                                      : ipsec
ROOT\LEGACY_KSECDD\0000                                     : ksecdd
ROOT\LEGACY_MNMDD\0000                                      : mnmdd
ROOT\LEGACY_MOUNTMGR\0000                                   : mountmgr
ROOT\LEGACY_NDIS\0000                                       : ndis
ROOT\LEGACY_NDISTAPI\0000                                   : Remote Access NDIS TAPI Driver
ROOT\LEGACY_NDISUIO\0000                                    : NDIS Usermode I/O Protocol
ROOT\LEGACY_NDPROXY\0000                                    : NDProxy
ROOT\LEGACY_NETBT\0000                                      : netbt
ROOT\LEGACY_NULL\0000                                       : Null
ROOT\LEGACY_PARTMGR\0000                                    : PartMgr
ROOT\LEGACY_PARVDM\0000                                     : ParVdm
ROOT\LEGACY_RASACD\0000                                     : Remote Access Auto Connection Driver
ROOT\LEGACY_RDPCDD\0000                                     : RDPCDD
ROOT\LEGACY_RDPWD\0000                                      : RDPWD
ROOT\LEGACY_TCPIP\0000                                      : tcpip
ROOT\LEGACY_TDPIPE\0000                                     : TDPIPE
ROOT\LEGACY_TDTCP\0000                                      : TDTCP
ROOT\LEGACY_VGASAVE\0000                                    : VgaSave
ROOT\LEGACY_VOLSNAP\0000                                    : VolSnap
ROOT\LEGACY_WANARP\0000                                     : Remote Access IP ARP Driver
27 matching device(s) found.

Esempio 22: Trovare (e trovare tutti) i dispositivi in una classe di installazione

The following command uses the DevCon FindAll operation to find all devices on the computer in the Net setup class. Il simbolo di uguale (=) precede il nome della classe "Net" per indicare che il valore specificato è una classe e non un ID.

devcon findall =net

In risposta, DevCon elenca i sette dispositivi seguenti nella classe net setup. I primi sei sono dispositivi driver miniport standard. Il settimo dispositivo, l'adattatore asincrono RAS, è un dispositivo enumerato software (SW\*) installato solo in base alle esigenze.

PCI\VEN_10B7&DEV_9200&SUBSYS_00BE1028&REV_78\4&BB7B4AE&0&60F0: 3Com 3C920 Integrated Fast
Ethernet Controller (3C905C-TX Compatible)
ROOT\MS_L2TPMINIPORT\0000                                   : WAN Miniport (L2TP)
ROOT\MS_NDISWANIP\0000                                      : WAN Miniport (IP)
ROOT\MS_PPPOEMINIPORT\0000                                  : WAN Miniport (PPPOE)
ROOT\MS_PPTPMINIPORT\0000                                   : WAN Miniport (PPTP)
ROOT\MS_PTIMINIPORT\0000                                    : Direct Parallel
SW\{EEAB7790-C514-11D1-B42B-00805FC1270E}\ASYNCMAC          : RAS Async Adapter
7 matching device(s) found.

The following command compares the output from the DevCon Find and DevCon FindAll operations by running a DevCon Find command with the same parameters as the previous DevCon FindAll command:

devcon find =net

In risposta, DevCon elenca i sei dispositivi seguenti nella classe net setup:

PCI\VEN_10B7&DEV_9200&SUBSYS_00BE1028&REV_78\4&BB7B4AE&0&60F0: 3Com 3C920 Integrated Fast
Ethernet Controller (3C905C-TX Compatible)
ROOT\MS_L2TPMINIPORT\0000                                   : WAN Miniport (L2TP)
ROOT\MS_NDISWANIP\0000                                      : WAN Miniport (IP)
ROOT\MS_PPPOEMINIPORT\0000                                  : WAN Miniport (PPPOE)
ROOT\MS_PPTPMINIPORT\0000                                   : WAN Miniport (PPTP)
ROOT\MS_PTIMINIPORT\0000                                    : Direct Parallel
6 matching device(s) found.

Predictably, the DevCon Find command, which returns only currently installed devices, doesn't list the software-enumerated device because the device isn't installed.

Esempio 23: Visualizzare i driver di filtro per una classe di installazione

The following command uses the DevCon ClassFilter operation to display the upper filter drivers for the DiskDrive setup class. Poiché questo comando non include operatori classfilter, DevCon visualizza i driver di filtro per la classe, ma non li modifica.

devcon classfilter DiskDrive upper

In risposta, DevCon visualizza i driver di filtro superiore per la classe DiskDrive e conferma che i driver di filtro non vengono modificati. In this case, the display shows that devices in the DiskDrive setup class use the PartMgr.sys upper filter driver:

Class filters unchanged.
    PartMgr

Esempio 24: Aggiungere un driver di filtro a una classe di installazione

The following command uses the DevCon ClassFilter operation to add a fictitious filter, Disklog.sys, to the list of upper filter drivers for the DiskDrive setup class.

This command uses the add-after (+, the plus symbol) ClassFilter operator to load the Disklog driver after the PartMgr driver so it receives data that PartMgr.sys already processed.

All'avvio del comando, il cursore virtuale viene posizionato prima del primo driver di filtro. Poiché non è posizionato in un determinato driver, DevCon aggiunge il driver Disklog alla fine dell'elenco di driver di filtro.

Il comando usa anche il /r parametro , che riavvia il sistema in base alle esigenze per rendere effettiva la modifica del filtro della classe.

devcon /r classfilter DiskDrive upper +Disklog

In risposta, DevCon visualizza i driver di filtro superiore correnti per la classe DiskDrive:

Class filters changed. Class devices must be restarted for changes to take effect.
    PartMgr
    Disklog

Se si scrive in modo errato il nome del driver o si tenta di aggiungere un driver che non è installato sul sistema, il comando ha esito negativo. DevCon non aggiunge un driver a meno che il driver non sia registrato come servizio. That is, DevCon only adds the driver if it has a subkey in the Services registry HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services subkey.

Il comando seguente verifica questa funzionalità di protezione. Tenta di aggiungere "Disklgg" (anziché "Disklog") all'elenco dei filtri superiori per la classe DiskDrive. L'output dimostra che il comando ha esito negativo:

devcon /r classfilter DiskDrive upper +Disklgg
devcon failed.

Esempio 25: Inserire un driver di filtro nell'elenco classi

The following command uses the DevCon ClassFilter operation to add a fictitious filter driver, MyFilter.sys, to the list of upper filter drivers for the DiskDrive setup class. The command places MyFilter.sys between PartMgr.sys and Disklog.sys in the load order:

devcon /r classfilter DiskDrive upper @Disklog -MyFilter

L'elenco seguente mostra i driver di filtro per la classe DiskDrive prima dell'invio del comando:

    PartMgr
    Disklog

The first subcommand, @Disklog, uses the positioning operator (@, the at symbol) to place the virtual cursor on the Disklog filter driver. The second subcommand, -MyFilter, uses the add-before operator (-, the minus symbol) to add MyFilter.sys before Disklog.sys.

Il comando usa anche il /r parametro , che riavvia il sistema in base alle esigenze per rendere effettiva la modifica del filtro della classe.

L'operatore di posizionamento è essenziale in questo esempio. Prima che DevCon elabori i sottocomandi classfilter, il cursore virtuale si trova all'inizio dell'elenco e non è posizionato su alcun driver di filtro. Se si usa l'operatore add-before (+) quando il cursore non è posizionato su un driver, DevCon aggiunge il driver all'inizio dell'elenco. Se si usa l'operatore add-after (-) quando il cursore non è posizionato su un driver, il driver viene aggiunto alla fine dell'elenco.

In risposta, DevCon visualizza i driver di filtro superiore correnti per la classe DiskDrive:

Class filters changed. Class devices must be restarted for changes to take effect.
    PartMgr
    MyFilter
    Disklog

È anche possibile usare il comando seguente per aggiungere il driver MyFilter e inserirlo tra PartMgr e Disklog. In questo esempio, il primo sottocomando, @PartMgrposiziona il cursore virtuale sul driver di filtro PartMgr. The second subcommand, +MyFilter, uses the add-after operator (+) to add MyFilter.sys after PartMgr:

devcon /r classfilter DiskDrive upper @PartMgr +MyFilter

Esempio 26: Sostituire un driver di filtro

The following command uses the DevCon ClassFilter operation to replace the original copy of MyFilter.sys with a new and improved version, MyNewFilter.sys, in the list of filter drivers for the DiskDrive setup class:

devcon /r classfilter DiskDrive upper !MyFilter +MyNewFilter

L'elenco seguente mostra i driver di filtro per la classe DiskDrive prima dell'invio del comando:

    PartMgr
    MyFilter
    Disklog

Il primo sottocomando usa l'operatore delete (!, il punto esclamativo) per eliminare MyFilter dall'elenco dei driver di filtro superiore per la classe DiskDrive. (It doesn't affect the MyFilter.sys file in the C:\Windows\System32\Drivers directory location.)

Il secondo sottocomando usa l'operatore add-after (+) per posizionare il nuovo driver di filtro nella posizione occupata in precedenza dal driver eliminato. Poiché l'operatore delete lascia il cursore nella posizione occupata dal filtro eliminato, gli operatori add-before (-) e add-after (+) hanno lo stesso effetto.

Il comando usa anche il /r parametro , che riavvia il sistema in base alle esigenze per rendere effettiva la modifica del filtro della classe.

In risposta, DevCon mostra la nuova configurazione del filtro di classe per la classe DiskDrive:

Class filters changed. Class devices must be restarted for changes to take effect.
    PartMgr
    MyNewFilter
    Disklog

Esempio 27: Modificare l'ordine dei driver di filtro

The following command uses the DevCon ClassFilter operation to change the order of filter drivers for the DiskDrive setup class. In particolare, inverte l'ordine dei driver filtro secondo e terzo.

devcon /r classfilter DiskDrive upper !Disklog =@PartMgr +Disklog

L'elenco seguente mostra i driver di filtro per la classe DiskDrive prima dell'invio del comando. Mostra anche il risultato previsto del comando.

Before After
PartMgr PartMgr
MyNewFilter Disklog
Disklog MyNewFilter

Il primo sottocomando usa l'operatore delete (!) per eliminare Disklog dall'elenco. The second subcommand uses the start operator (=, the equals symbol) to move the virtual cursor back to the starting position and the positioning operator (@, the at symbol) to place the cursor on the PartMgr driver. L'operatore start è necessario perché il cursore virtuale si sposta solo in avanti nell'elenco. Il sottocomando finale usa l'operatore add-after (+) per aggiungere Disklog dopo PartMgr.

In risposta, DevCon mostra la nuova configurazione del filtro di classe per la classe DiskDrive:

Class filters changed. Class devices must be restarted for changes to take effect.
    PartMgr
    Disklog
    MyNewFilter

Esempio 28: Abilitare un dispositivo specifico

The following command uses the DevCon Enable operation to enable a previously disabled programmable interrupt controller. Il controllo è disabilitato e quindi riabilitabile per correggere un problema di sistema. Poiché l'ID hardware del controller in questo esempio include un asterisco (*PNP0000), il comando usa il carattere virgolette singolo (') per indirizzare DevCon a trovare l'ID hardware esattamente come specificato nel comando. Se il comando non usava il carattere virgolette (') in questa istanza, DevCon interpreta l'asterisco (*) nel valore come carattere jolly.

devcon enable '*PNP0000

In risposta, DevCon visualizza l'ID istanza del dispositivo e spiega che è necessario riavviare il sistema per abilitare il dispositivo:

ACPI\PNP0000\4&B4063F4&0                                    : Enabled on reboot
Not all of 1 device(s) enabled, at least one requires reboot to complete the operation.

You can respond by rebooting the system manually, or by using the DevCon Reboot operation.

Il comando seguente aggiunge il /r parametro al comando precedente. Il /r parametro riavvia il sistema in base alle esigenze per completare un'operazione.

devcon /r enable '*PNP0000

In risposta, DevCon abilita il dispositivo e quindi riavvia il sistema per rendere effettiva l'operazione di abilitazione.

All'avvio del sistema, usare un comando DevCon status per verificare che il dispositivo sia abilitato:

devcon status '*PNP0000

ACPI\PNP0000\4&B4063F4&0
    Name: Programmable interrupt controller
    Driver is running.

Esempio 29: Abilitare i dispositivi per classe

The following command enables all printer devices on the computer by specifying the Printer setup class in a DevCon Enable command. Il comando include il /r parametro , che riavvia il sistema in base alle esigenze per rendere effettiva l'operazione di abilitazione.

devcon /r enable =Printer

In risposta, DevCon visualizza l'ID istanza del dispositivo della stampante trovata nella classe Printer e segnala che la stampante è abilitata. Anche se il comando include il /r parametro , il sistema non viene riavviato perché non è necessario un riavvio per abilitare la stampante.

LPTENUM\HEWLETT-PACKARDDESKJET_1120C\1&7530F08&0&LPT1.4        : Enabled
1 device(s) enabled.

Esempio 30: Disabilitare i dispositivi in base a un modello ID

The following command uses the DevCon Disable operation to disable the USB devices on the local computer. Identifica i dispositivi in base a un modello ID hardware (USB*). Questo modello corrisponde a qualsiasi dispositivo con un ID hardware o un ID compatibile che inizia con "USB". Il comando include il /r parametro , che riavvia il sistema in base alle esigenze per rendere effettiva l'operazione di disabilitazione.

Note

Prima di usare un modello ID per disabilitare un dispositivo, determinare quali dispositivi potrebbero essere interessati. Usare il modello in un comando di visualizzazione, ad esempio devcon status USB* o devcon hwids USB*.

devcon /r disable USB*

In risposta, DevCon visualizza gli ID istanza del dispositivo dei dispositivi USB e segnala che sono disabilitati. Anche se il comando include il /r parametro , il sistema non viene riavviato perché non è necessario riavviare i dispositivi.

USB\ROOT_HUB\4&2A40B465&0
: Disabled
USB\ROOT_HUB\4&7EFA360&0
: Disabled
USB\VID_045E&PID_0039\5&29F428A4&0&2
: Disabled
3 device(s) disabled.

Esempio 31: Disattivare i dispositivi in base all'ID istanza del dispositivo

The following command uses the DevCon Disable operation to disable the USB devices on the local computer. The command uses the at symbol (@) to identify the devices by their device instance IDs. Ogni ID istanza del dispositivo è separato dagli altri da uno spazio.

Quando l'ID dispositivo include il simbolo e commerciale (&), il valore è racchiuso tra virgolette (" "). Il comando include il /r parametro , che riavvia il sistema in base alle esigenze per rendere effettiva l'operazione di disabilitazione.

devcon /r disable "@USB\ROOT_HUB\4&2A40B465&0" "@USB\ROOT_HUB\4&7EFA360&0" "@USB\VID_045E&PID_0039\5&29F428A4&0&2"

In risposta, DevCon visualizza gli ID istanza del dispositivo dei dispositivi USB e segnala che sono disabilitati. Anche se il comando include il /r parametro , il sistema non viene riavviato perché non è necessario riavviare i dispositivi.

USB\ROOT_HUB\4&2A40B465&0
: Disabled
USB\ROOT_HUB\4&7EFA360&0
: Disabled
USB\VID_045E&PID_0039\5&29F428A4&0&2
: Disabled
3 device(s) disabled.

Esempio 32: Aggiornare il driver per le porte di comunicazione

The following command uses the DevCon Update operation to replace the current device driver for communication ports on the system with a test driver specified in the test.inf file. Il comando influisce solo sui dispositivi l'intero ID *PNP0501 hardware (incluso l'asterisco *).

È possibile usare questo comando per sostituire i driver firmati nel sistema con driver alternativi per il test o la risoluzione dei problemi oppure per associare i dispositivi alla versione più recente degli stessi driver.

devcon update c:\windows\inf\test.inf *PNP0501

In response, DevCon displays a Hardware Installation warning explaining that the driver didn't pass Windows Logo testing. If you select the Continue Anyway option on the dialog, the installation continues.

DevCon visualizza quindi il messaggio di operazione riuscita seguente:

Updating drivers for *PNP0501 from c:\windows\inf\test.inf.
Drivers updated successfully.

You can also use the DevCon UpdateNI operation, the noninteractive version of the DevCon Update operation, to update drivers. The DevCon UpdateNI operation is identical to the DevCon Update operation except it suppresses all user prompts that require a response and assumes the default response to the prompt.

The following command uses the DevCon UpdateNI operation to install the test driver:

devcon updateni c:\windows\inf\test.inf *PNP0501

In this case, DevCon doesn't display the Hardware Installation warning. Instead, it assumes the default response, Stop Installation. Di conseguenza, DevCon non può aggiornare i driver e visualizza un messaggio di errore:

Updating drivers for *PNP0501 from c:\windows\inf\test.inf.
devcon failed.

Esempio 33: Installare un dispositivo

The following command uses the DevCon Install operation to install a keyboard device on the local computer. The command includes the full path to the setup information (INF) file keyboard.inf for the device and a hardware ID *PNP030b:

devcon /r install c:\windows\inf\keyboard.inf *PNP030b

In risposta, DevCon segnala che è stato installato il dispositivo. Ovvero, DevCon crea un nodo del dispositivo per il nuovo dispositivo e aggiorna i file del driver per il dispositivo.

Device node created. Install is complete when drivers files are updated...
Updating drivers for *PNPO30b from c:\windows\inf\keyboard.inf
Drivers updated successfully.

Esempio 34: Installare un dispositivo usando l'installazione automatica

Nell'esempio seguente viene illustrato come installare l'adapter Microsoft Loopback durante un'installazione automatica di Microsoft Windows XP.

To install this device during an unattended setup, begin by adding the following files to a floppy disk: devcon.exe and netloop.inf (C:\Windows\inf\netloop.inf).

Aggiungere quindi il comando DevCon seguente nella [GUIRunOnce] sezione del file di installazione automatica:

a:\devcon /r install a:\Netloop.inf '*MSLOOP

Questo comando identifica l'adattatore loopback usando il relativo ID hardware, *MSLOOP. Il carattere virgolette singolo (') che precede il valore \*MSLOOP indica a DevCon di interpretare la stringa letteralmente. Di conseguenza, DevCon interpreta l'asterisco (*) come parte dell'ID hardware e non come carattere jolly.

The command also specifies that DevCon use the Netloop.inf file (on the floppy disk) in the installation. Il /r parametro riavvia il computer in base alle esigenze per completare l'installazione.

Infine, aggiungere le impostazioni di configurazione di rete al file di installazione automatica ed eseguire l'installazione automatica.

Esempio 35: Rimuovere i dispositivi in base al modello ID di istanza del dispositivo

The following command uses the DevCon Remove operation to remove all USB devices from the computer. Identifica i dispositivi in base a un modello di ID istanza del dispositivo che corrisponde a qualsiasi ID istanza del dispositivo (percorso del Registro di sistema) che inizia con la stringa "USB". The command uses the at symbol (@) to distinguish the device instance ID from a hardware ID or compatible ID. Il comando include anche il /r parametro che riavvia il sistema in base alle esigenze per rendere effettiva la rimozione.

Warning

Prima di usare un modello ID per rimuovere un dispositivo, determinare quali dispositivi potrebbero essere interessati. Usare il modello in un comando di visualizzazione, ad esempio devcon status @usb\* o devcon hwids @usb\*.

devcon /r remove @usb\*

In risposta, DevCon visualizza l'ID istanza del dispositivo dei dispositivi rimossi:

USB\ROOT_HUB\4&2A40B465&0                             : Removed
USB\ROOT_HUB\4&7EFA360&0                              : Removed
USB\VID_045E&PID_0039\5&29F428A4&0&2                  : Removed
3 device(s) removed.

Esempio 36: Rimuovere un dispositivo di rete specifico

The following command uses the DevCon Remove operation to uninstall the NDISWAN miniport driver from the local computer. Il comando specifica la classe Net e quindi affina la ricerca specificando i dispositivi nella classe il cui ID hardware o ID compatibile includono "ndiswan". Il comando include anche il /r parametro , che riavvia il sistema in base alle esigenze per rendere effettiva la rimozione.

Warning

Prima di usare un modello ID per rimuovere un dispositivo, determinare quali dispositivi potrebbero essere interessati. Usare il modello in un comando di visualizzazione, ad esempio devcon status =net *ndiswan o devcon hwids =net *ndiswan*.

devcon /r remove =net *ndiswan*

In risposta, DevCon visualizza l'ID istanza del dispositivo rimosso:

ROOT\MS_NDISWANIP\0000 : Removed 1 device(s) removed.

Esempio 37: Analizzare il computer per individuare nuovi dispositivi

The following command uses the DevCon Rescan operation to scan the local computer for new devices.

devcon rescan

In risposta, DevCon segnala che ha analizzato il sistema ma non ha trovato nuovi dispositivi:

Scanning for new hardware.
Scanning completed.

Esempio 38: Riavviare un dispositivo

The following command uses the DevCon Restart operation to restart the loopback adapter on the local computer. Il comando limita la ricerca alla classe Net setup e, all'interno di tale classe, specifica l'ID istanza del dispositivo dell'adattatore loopback, @'ROOT\*MSLOOP\0000.

The at symbol (@) identifies the string value as a device instance ID. Il carattere virgolette singole (') indica a DevCon di interpretare la stringa letteralmente. Di conseguenza, DevCon interpreta l'asterisco (*) come parte dell'ID e non come carattere jolly.

devcon restart =net @'ROOT\*MSLOOP\0000

In risposta, DevCon visualizza l'ID istanza del dispositivo e segnala il risultato:

ROOT\*MSLOOP\0000                                              : Restarted
1 device(s) restarted.

Esempio 39: Riavviare il computer locale

The following command uses the DevCon Reboot operation to reboot the operating system on the local computer and to associate the reboot with a hardware installation. Unlike the /r parameter, the DevCon Reboot operation doesn't depend on the return code from another operation.

È possibile includere questo comando in script e file batch che richiedono il riavvio del sistema.

devcon reboot

In risposta, DevCon visualizza un messaggio che indica che sta riavviando il computer (Riavvio del computer locale).

DevCon uses the standard ExitWindowsEx function to reboot. Se l'utente ha file aperti nel computer o un programma non si chiude, il sistema non viene riavviato. Attende fino a quando l'utente non risponde alle richieste di sistema di chiudere i file o terminare il processo.

Esempio 40: Assegnare un ID hardware a un dispositivo legacy

The following command uses the DevCon SetHwID operation to assign the hardware ID beep to the legacy beep device.

Il comando usa l'ID istanza del dispositivo ROOT\LEGACY_BEEP\0000 perché il dispositivo legacy di beep non dispone di ID hardware o ID compatibili. The command uses the at symbol (@) to indicate that the string is a device instance ID.

Il comando non usa parametri di simboli per posizionare l'ID. Per impostazione predefinita, DevCon aggiunge nuovi ID hardware alla fine di un elenco di ID hardware. In questo caso, poiché il dispositivo non ha altri ID hardware, il posizionamento dell'ID è irrilevante.

devcon sethwid @ROOT\LEGACY_BEEP\0000 := beep

In risposta, DevCon visualizza un messaggio che indica che è stato aggiunto beep all'elenco di ID hardware per il dispositivo. Visualizza anche l'elenco di ID hardware risultante. In questo caso, nell'elenco è presente un solo ID hardware:

ROOT\LEGACY_BEEP\0000                              : beep
Modified 1 hardware ID(s).

Esempio 41: Aggiungere un ID hardware a tutti i dispositivi legacy

The following command uses the DevCon SetHwID operation to add the hardware ID, legacy, to the list of hardware IDs for all legacy devices.

Il comando usa il parametro meno simbolo (-) per aggiungere il nuovo ID hardware alla fine dell'elenco di ID hardware per il dispositivo, nel caso in cui esista un ID hardware preferito per uno dei dispositivi. Usa anche un modello id istanza del dispositivo, @ROOT\LEGACY*, per identificare i dispositivi legacy nel computer, ovvero tutti i dispositivi con un ID istanza del dispositivo che inizia con ROOT\LEGACY*.

devcon sethwid @ROOT\LEGACY* := -legacy

In risposta, DevCon visualizza gli elenchi di ID hardware risultanti per tutti i dispositivi interessati:

ROOT\LEGACY_AFD\0000                                        : legacy
ROOT\LEGACY_BEEP\0000                                    : beep,legacy
ROOT\LEGACY_CRCDISK\0000                                    : legacy
ROOT\LEGACY_DMBOOT\0000                                     : legacy
ROOT\LEGACY_DMLOAD\0000                                     : legacy
ROOT\LEGACY_FIPS\0000                                       : legacy
...
ROOT\LEGACY_WANARP\0000                                     : legacy
Modified 27 hardware ID(s).

Dopo aver assegnato lo stesso ID hardware a un gruppo di dispositivi, è possibile usare le altre operazioni DevCon per visualizzare e modificare i dispositivi in un singolo comando.

Ad esempio, il comando seguente visualizza lo stato di tutti i dispositivi legacy:

devcon status legacy

Esempio 42: Eliminare un ID hardware da tutti i dispositivi legacy

The following command uses the DevCon SetHwID operation to delete the hardware ID legacy from the list of hardware IDs for all legacy devices.

Il comando usa l'ID legacy hardware per identificare tutti i dispositivi con tale ID hardware. Usa l'operatore delete (!) per eliminare l'ID legacy hardware.

devcon sethwid legacy := !legacy

In risposta, DevCon visualizza gli elenchi di ID hardware risultanti per tutti i dispositivi interessati:

ROOT\LEGACY_AFD\0000                                        :
ROOT\LEGACY_BEEP\0000                                    : beep
ROOT\LEGACY_CRCDISK\0000                                    :
ROOT\LEGACY_DMBOOT\0000                                     :
ROOT\LEGACY_DMLOAD\0000                                     :
ROOT\LEGACY_FIPS\0000                                       :
...
ROOT\LEGACY_WANARP\0000                                     :
Modified 27 hardware ID(s).

Esempio 43: Aggiungere, eliminare e sostituire gli ID hardware

The following examples show how to use the various features of the DevCon SetHwID operation.

This series of examples uses a fictitious device, DeviceX, with the device instance ID, ROOT\DeviceX\0000. Prima dell'esecuzione dei comandi DevCon per il dispositivo, il dispositivo include l'elenco seguente di ID hardware:

Hw3 Hw4

Il comando seguente usa il simbolo più (+) per aggiungere i valori Hw1 ID e Hw2 all'inizio di un elenco di ID hardware per DeviceX. Poiché l'ID Hw2 è già visualizzato nell'elenco, il valore ID viene spostato, non aggiunto. The command uses the at symbol (@) to identify the device by its device instance ID.

devcon sethwid @ROOT\DEVICEX\0000 := +Hw1 Hw2

In risposta, DevCon visualizza il nuovo elenco di ID hardware per il dispositivo. I Hw1 valori e Hw2 ID vengono visualizzati all'inizio dell'elenco ID nell'ordine specificato:

ROOT\DEVICEX\0000                         : Hw1,Hw2,Hw3,Hw4
Modified 1 hardware ID(s).

DevCon segnala inoltre che è stato modificato un elenco di ID hardware, ovvero l'elenco di ID hardware di un singolo dispositivo.

Il comando seguente usa l'operatore delete (!) per eliminare l'ID Hw1 hardware. Elenca quindi l'ID Hw5 hardware senza un parametro simbolo. Without symbol parameters, SetHwID adds the hardware ID to the end of the hardware ID list for the device.

This command demonstrates that unlike the other symbol parameters for the DevCon SetHwID operation, the delete operator (!) applies only to the hardware ID that it prefixes.

devcon sethwid @ROOT\DeviceX\0000 := !Hw1 Hw5

In risposta, DevCon visualizza l'elenco di ID hardware risultante per DeviceX:

ROOT\DEVICEX\0000                         : Hw2,Hw3,Hw4,Hw5
Modified 1 hardware ID(s).

Il comando seguente usa il parametro equals (=) per sostituire tutti gli ID hardware nell'elenco per DeviceX con un singolo ID hardware, DevX.

devcon sethwid @ROOT\DeviceX\0000 := =DevX

In risposta, DevCon visualizza l'elenco di ID hardware risultante per DeviceX:

ROOT\DEVICEX\0000                         : DevX
Modified 1 hardware ID(s).

Il messaggio di operazione riuscita indica che DevCon ha modificato l'ID hardware di un dispositivo.

Esempio 44: aggiornare forzatamente l'HAL

L'esempio seguente illustra come usare DevCon per aggiornare hal nel computer. L'hal corrente è un uniprocessore (_up) compilato con advanced configuration and power interface (ACPI) e advanced programmable interrupt controller (APIC), in base alle esigenze del computer. Un tester vuole modificare il tipo in un multiprocessore (_mp) ACPI APIC HAL a scopo di test.

The first command uses the DevCon SetHwID operation to change the hardware ID of the HAL from acpiapic_up, the hardware ID for uniprocessor HALs, to acpiapic_mp, the hardware ID for multiprocessor HALs.

You must change the hardware ID because the INF file (.inf) for the HAL includes drivers for both uniprocessor and multiprocessor HALs. The system selects the most appropriate driver from the INF file (.inf) based on the hardware ID of the device. If you don't change the hardware ID, the DevCon Update command reinstalls the same uniprocessor HAL driver.

In the following example, the command identifies the HAL by its instance ID, ROOT\ACPI_HAL\0000, as indicated by the at symbol (@) preceding the ID. Il comando usa il simbolo più (+) per specificare acpiapic_mp come primo ID hardware nell'elenco per HAL. Il comando usa l'operatore delete (!) per eliminare l'ID hardware dall'elenco acpiapic_up di ID per HAL.

devcon sethwid @ROOT\ACPI_HAL\0000 := +acpiapic_mp !acpiapic_up

In risposta, DevCon visualizza il nuovo elenco di ID hardware seguente per HAL:

ROOT\ACPI_HAL\0000                         : acpiapic_mp
Modified 1 hardware ID(s).

The following command uses the DevCon Update operation to update the driver for the HAL:

devcon update c:\windows\inf\hal.inf acpiapic_mp

DevCon visualizza quindi il messaggio di operazione riuscita seguente:

Updating drivers for acpiapic_mp from c:\windows\inf\hal.inf.
Drivers updated successfully.

Esempio 45: Aggiungere e rimuovere pacchetti driver

Gli esempi seguenti illustrano come usare DevCon per aggiungere, eliminare e visualizzare pacchetti driver OEM (Third-Party) nell'archivio driver.

The first command, a DevCon Dp_add operation, copies the INF file (.inf) for the Toaster sample driver in the Windows Driver Kit (WDK) to the driver store, that is, to the %Windir%\inf directory. Il comando include il percorso completo del file INF per il driver di esempio Toaster.

Questo comando è destinato a driver e dispositivi OEM di terze parti, ma è possibile usare l'esempio Toaster per testare i comandi.

devcon dp_add C:\WinDDK\5322\src\general\toaster\inf\i386\toaster.inf

In response, DevCon reports that it added the Toaster INF file to the driver store and named it Oem2.inf:

Driver Package 'oem2.inf' added.

Prima che il file INF venga copiato nell'archivio driver, Windows confronta la versione binaria del file con i file simili nell'archivio driver. Verifica che non siano presenti file binari con lo stesso nome INF. For example, if you repeat the command to add the Toaster.inf file to the driver store, DevCon doesn't create a new OEM*.inf file. Segnala solo il nome del file esistente, come illustrato nell'output DevCon seguente:

devcon dp_add C:\WinDDK\5322\src\general\toaster\inf\i386\toaster.inf
Driver Package 'oem2.inf' added.

devcon dp_add C:\WinDDK\5322\src\general\toaster\inf\i386\toaster.inf
Driver Package 'oem2.inf' added.

To remove the driver package for the Toaster driver from the driver store, you must use the OEM*.inf file name for the driver. To find the file name for the driver, use the DevCon Dp_enum operation.

Il comando seguente elenca tutti i pacchetti driver OEM e alcune delle relative proprietà:

devcon dp_enum

In risposta, DevCon genera l'output seguente:

c:\WinDDK\5322\tools\devcon\i386>devcon dp_enum
The following 3rd party Driver Packages are on this machine:
oem2.inf
    Provider: Microsoft
    Class: unknown

The output indicates that the driver package supplied by Microsoft with the unspecified device class (Toaster) is named OEM2.inf. È possibile usare queste informazioni per eliminare il pacchetto driver associato al file.

The following command deletes the OEM2.inf file from the driver store, along with its associated precompiled INF (.pnf) and catalog (.cat) files. The command uses the OEM2.inf file name:

devcon dp_delete oem2.inf

In risposta, DevCon visualizza un messaggio che indica l'esito positivo del comando:

Driver Package 'oem2.inf' deleted.

The OEM.inf* file name is required in the DevCon Dp_delete operation. Se si tenta di usare il nome originale del file INF, il comando ha esito negativo, come illustrato nell'output DevCon seguente:

devcon dp_delete C:\WinDDK\5322\src\general\toaster.inf
Deleting the specified Driver Package from the machine failed.
devcon failed.