共用方式為


裝置主控台 (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. PnPUtil 工具隨附於每個 Windows 版本,並使用最可靠且安全的 API。 如需使用 PnPutil 而非 Device Console 的詳細資訊,請參閱 取代裝置控制台

Example categories

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

Category Examples
HwIDs 範例 1:尋找所有硬體識別碼
範例 2:使用模式
尋找硬體識別碼範例 3:使用 類別尋找硬體識別碼
Classes 範例 4:在本機電腦上列出類別
ListClass 範例 6:列出裝置安裝類別
中的裝置範例 7:列出多個類別中的裝置
DriverFiles 範例 8:列出所有驅動程式檔案
範例 9:列出特定裝置的驅動程式檔案
DriverNodes 範例 10:依硬體標識碼模式
列出驅動程式套件範例 11:依裝置實例標識碼模式列出驅動程式套件
Resources 範例 12:列出裝置
類別的資源範例 13:依標識符列出裝置的資源
Stack 範例 14:顯示儲存裝置
的驅動程式堆疊範例 15:尋找裝置
的安裝類別範例 16:顯示相關裝置的堆疊
Status 範例 17:顯示本機電腦上
所有裝置的狀態範例 18:依裝置實例標識碼
顯示裝置的狀態範例 19:顯示相關裝置的狀態
Find 範例 20:依硬體標識碼模式
尋找裝置範例 21:依裝置實例標識碼或類別尋找裝置
FindAll 範例 22:尋找 (並尋找所有) 安裝類別中的裝置
ClassFilter 範例 23:顯示安裝類別
的篩選驅動程式範例 24:將篩選驅動程式新增至安裝類別
範例 25:在類別清單中
插入篩選驅動程式範例 26:取代篩選驅動程式
範例 27:變更篩選驅動程式的順序
Enable 範例 28:啟用特定裝置
範例 29:依類別啟用裝置
Disable 範例 30:依標識符模式
停用裝置範例 31:依裝置實例標識碼停用裝置
Update 和 UpdateNI 範例 32:更新通訊埠
的驅動程式範例 44:強制更新硬體抽象層 (HAL)
Install 範例 33:安裝裝置
範例 34:使用自動安裝安裝來安裝裝置
Remove 範例 35:依裝置實例標識碼模式
移除裝置範例 36:移除特定網路裝置
Rescan 範例 37:掃描電腦以尋找新裝置
Restart 範例 38:重新啟動裝置
Reboot 範例 39:重新啟動本機電腦
SetHwID 範例 40:將硬體標識碼指派給舊版裝置
範例 41:將硬體標識元新增至所有舊版裝置
範例 42:從所有舊版裝置
刪除硬體識別碼範例 43:新增、刪除和取代硬體識別碼
範例 44:強制更新 HAL
dp_add、dp_deleted、dp_enum 範例 45:新增和移除驅動程式套件

Example details

下列各節提供完整的 DevCon 範例。

範例 1:尋找所有硬體 ID

DevCon 作業會使用標識碼和標識碼模式來識別裝置。 因此,使用DevCon的常見第一個步驟是在電腦上建立裝置的硬體標識碼參考檔案。

The following command uses the DevCon HwIDs operation, which returns the IDs and the device description. 命令會使用星號 (*) 通配符來代表本機電腦上的所有裝置。

devcon hwids *

由於輸出很長且重複使用,因此請將輸出儲存在文字檔中以供參考。

下列命令會使用重新導向字元 (>) 擴充上一個命令。 The redirection saves the command output in the specified file, hwids.txt.

devcon hwids * > hwids.txt

範例 2:使用型樣尋找硬體 ID

若要尋找特定裝置的硬體識別碼,請使用 命令輸入下列其中一個值:

  • 硬體標識碼或模式
  • 相容的標識碼或模式
  • 裝置實例標識碼或模式
  • 裝置安裝類別的名稱

The following command uses the DevCon HwIDs operation and a pattern to find the hardware IDs of the floppy disk drive on the computer. (使用者假設模式出現在其中一個裝置標識碼中。命令會使用通配符 (*) 來代表任何識別符中可能前面或跟隨單字 floppy 的所有字元。

devcon hwids *floppy*

作為回應,DevCon 會顯示電腦上軟碟機的裝置實例 ID、硬體 ID 和相容 ID。 您可以在後續的 DevCon 命令中使用這些 ID。

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.

在此範例中,片語 「floppy」 只會發生在電腦上的一個裝置的硬體識別碼或相容標識碼中。 如果片語出現在多個裝置的標識碼中,則其標識碼中含有片語 「floppy」 的所有裝置都會出現在輸出中。

範例 3:使用類別尋找硬體識別碼

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. 類別名稱前面的等號符號 (=) 表示指定的值是類別,而不是標識碼。

devcon hwids =ports

作為回應,DevCon 會顯示埠設定類別中三個裝置的硬體標識碼和相容標識碼:

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.

範例 4:在本機電腦上列出類別

由於 DevCon 作業可以使用裝置安裝類別來識別裝置,因此最好在電腦上建立裝置設定類別的參考檔案。

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

devcon classes

由於輸出很長且重複使用,因此請將輸出儲存在文字檔中以供參考。

下列命令會顯示電腦上的所有裝置類別。 It uses the redirection character (>) to save the command output in the specified file, classes.txt.

devcon classes > classes.txt

範例 6:列出裝置設定類別中的裝置

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

devcon listclass net

作為回應,DevCon 會顯示 Net 安裝程式類別中每個裝置的裝置實例識別碼和描述:

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

雖然命令回應很有趣,但它不會在 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

結果顯示列出了 Net 類別中的裝置,並包含該類別中裝置的裝置實例 ID、硬體 ID 和相容 ID。

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.

範例 7:列出多個類別中的裝置

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

devcon listclass diskdrive cdrom tapedrive

作為回應,DevCon 會在這些類別中顯示裝置:

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).

範例 8:列出所有驅動程式檔案

The following command uses the DevCon DriverFiles operation to list the file names of drivers that devices on the system use. 此命令會使用通配符 (*) 來代表系統上的所有裝置。 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

範例 9:列出特定裝置的驅動程式檔案

The following command uses the DevCon DriverFiles operation to search for the device driver used by the mouse device on the local computer. 命令會透過其中一個硬體標識碼 HID\Vid_045e&Pid_0039&Rev_0121來識別裝置。 硬體標識碼會以引號 (" ") 括住,因為它包含 ampersand (&) 符號。

devcon driverfiles "HID\Vid_045e&Pid_0039&Rev_0121"

作為回應,DevCon 會顯示支援滑鼠裝置的兩個設備驅動器:

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.

範例 10:依硬體識別碼模式列出驅動程式套件

The following command uses the DevCon DriverNodes command and an ID pattern to list the driver nodes of software-enumerated devices. 型樣對於尋找可能不在相同安裝類別中的類似裝置的相關資訊很有用。

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*

作為回應,DevCon 會顯示系統上軟體列舉裝置的驅動程序節點:

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.

範例 11:依裝置實例識別碼模式列出驅動程式套件

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*

作為回應,DevCon 會顯示裝置的驅動程序節點,其開頭為的裝置實例標識碼 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.

範例 12:列出裝置類別的資源

The following command uses the DevCon Resources operation to display the resources allocated to devices in the Hdc device setup class. 這個類別包括 IDE 控制器。 語法在類別名稱 hdc 前面加上等於符號 (=),表示指定的值是類別,而不是標識符。

devcon resources =hdc

作為回應,DevCon 會列出配置給本機電腦上的 IDE 控制器的資源:

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.

範例 13:依 ID 列出裝置的資源

The following command uses the DevCon Resources operation to list the resources allocated to the system timer. 命令會使用系統定時器 ACPI\PNP0100的硬體標識碼來指定裝置。

devcon resources *PNP0100

作為回應,DevCon 會顯示系統定時器的資源:

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

下列命令會使用 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"

範例 14:顯示儲存裝置的驅動程式堆疊

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. 等於符號 (=) 在字串前面表示值是類別,而不是標識碼。

devcon stack =Volume

作為回應,DevCon 會顯示 Volume 類別中裝置的預期堆疊。 傳回的資料包含下列資訊:

  • 每個裝置的裝置實例標識碼和描述
  • 裝置設定類別的 GUID 和名稱
  • 上下篩選驅動程式的名稱
  • 控制服務(如果有的話)
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.

範例 15:尋找裝置的設定類別

The DevCon Stack operation returns the setup class of a device in addition to the upper and lower filter drivers. 下列命令會尋找印表機埠介面的安裝類別,方法是尋找其裝置實例標識碼,然後使用裝置實例標識碼來尋找其安裝類別。

The following command uses the DevCon HwIDs operation to find the device instance ID of the printer port interface. 它會在印表機埠硬體識別碼內的 「LPT」 片語上搜尋:

devcon hwids *lpt*

作為回應,DevCon 會傳回裝置實例識別碼(以粗體文字顯示),以及印表機埠介面的硬體識別碼:

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. 標識碼會以引號 (" ") 括住,因為它包含 ampersand (&) 符號。

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

作為回應,DevCon 會顯示印表機埠介面的驅動程式堆疊,包括類別。 顯示器會顯示印表機埠位於 [系統] 類別中:

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. 它會在「網路設置類別」中搜尋其硬體識別碼或相容識別碼中包含 "miniport" 的裝置。

此命令會先將搜尋限制為 Net setup 類別,然後尋找 「miniport」 字串。 它找不到 Net 安裝程式類別中專案以外的裝置。

devcon stack =net *miniport*

作為回應,DevCon 會顯示迷你埠驅動程式的預期堆疊:

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.

範例 17:顯示所有裝置的狀態

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. 命令會使用通配符 (*) 來代表所有裝置。 It uses the redirection character (>) to save the command output in the specified file, status.txt.

devcon status * > status.txt

範例 18:依裝置執行個體 ID 顯示裝置狀態

尋找特定裝置狀態的最可靠方式是使用該裝置的執行個體識別碼。

The following command uses the device instance ID of the I/O controller on the local computer in a DevCon Status command. 這個指令包含裝置的裝置實例識別碼。 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. 標識碼會以引號 (" ") 括住,因為它包含 ampersand (&) 符號。

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

作為回應,DevCon 會顯示 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. 它會搜尋下列裝置:

  • 磁碟驅動器 GenDisk
  • CD-ROM 磁碟驅動器, GenCdRom
  • 軟碟磁碟驅動器、 FDC\GENERIC_FLOPPY_DRIVE
  • STORAGE\Volume
  • 邏輯磁碟管理員, ROOT\DMIO
  • 磁碟區管理員, ROOT\FTDISK
  • 軟盤控制器, ACPI\PNP0700

在指令中,每個 ID 都會以空格與其他 ID 分隔。 請注意, GenDiskGenCdRom 是相容的標識碼,而其他標識符則是硬體標識碼。

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

作為回應,DevCon 會顯示每個裝置的狀態:

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.

範例 20:依硬體 ID 型樣尋找裝置

The following command uses the DevCon Find operation to search for mouse devices. 具體來說,命令會搜尋計算機是否有硬體標識碼或相容標識符的裝置,其中包含 「mou」 一詞:

devcon find *mou*

作為回應,DevCon 會探索兩個滑鼠裝置:

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

因為所有 DevCon 顯示作業也會尋找硬體識別碼,所以您可以使用任何顯示作業來搜尋硬體識別碼。 根據輸出中所需的內容選取作業。 例如,若要在本機計算機上尋找滑鼠相關裝置的設備驅動器,請提交下列命令:

devcon driverfiles *mou*

作為回應,DevCon 會尋找裝置並列出其驅動程式:

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.

範例 21:依裝置執行個體識別碼或類別尋找裝置

The following commands use the DevCon Find operation to display all legacy devices on the local computer. 由於舊版裝置沒有硬體標識碼,因此您必須依其裝置實例標識碼(登錄路徑)、 ROOT\LEGACY或其設定類別 LegacyDriver搜尋它們。

第一個命令會依裝置執行個體識別碼模式尋找舊版驅動程式。 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*

第二個命令會搜尋 LegacyDriver 類別中的所有裝置,以尋找舊版裝置:

devcon find =legacydriver

這兩個命令會產生相同的輸出,在此案例中,會尋找相同的 27 個舊版裝置:

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.

範例 22:尋找 (並尋找所有) 安裝類別中的裝置

The following command uses the DevCon FindAll operation to find all devices on the computer in the Net setup class. 等於符號 (=) 在類別名稱 「Net」 前面,表示指定的值是類別,而不是識別碼。

devcon findall =net

作為回應,DevCon 在 Net 設置類中列出了以下七個設備。 前六個是標準迷你埠驅動程式裝置。 第七個裝置 RAS 異步適配卡是僅視需要安裝的軟體列舉裝置(SW\*)。

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

作為回應,DevCon 會在 Net 安裝類別中列出下列六個裝置:

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.

範例 23:顯示安裝類別的篩選驅動程式

The following command uses the DevCon ClassFilter operation to display the upper filter drivers for the DiskDrive setup class. 因為此命令不包含 classfilter 運算符,因此 DevCon 會顯示 類別的篩選驅動程式,但不會變更它們。

devcon classfilter DiskDrive upper

作為回應,DevCon 會顯示 DiskDrive 類別的上層篩選驅動程式,並確認篩選驅動程式未變更。 In this case, the display shows that devices in the DiskDrive setup class use the PartMgr.sys upper filter driver:

Class filters unchanged.
    PartMgr

範例 24:將篩選驅動程式新增至安裝類別

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.

當命令啟動時,虛擬游標會位於第一個篩選驅動程式之前。 因為該驅動程式不是位於特定驅動程式上,所以 DevCon 會將 Disklog 驅動程式新增至篩選驅動程式清單的結尾。

此命令也會使用 /r 參數,視需要重新啟動系統,讓類別篩選變更生效。

devcon /r classfilter DiskDrive upper +Disklog

作為回應,DevCon 會顯示 DiskDrive 類別目前的上層篩選驅動程式:

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

如果您拼錯驅動程式名稱,或嘗試新增系統上未安裝的驅動程式,命令就會失敗。 除非驅動程式註冊為服務,否則 DevCon 不會新增驅動程式。 That is, DevCon only adds the driver if it has a subkey in the Services registry HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services subkey.

下列命令會測試此保護功能。 它會嘗試將 “Disklgg” (而不是 “Disklog”) 新增至 DiskDrive 類別的上層篩選清單。 輸出示範指令失敗:

devcon /r classfilter DiskDrive upper +Disklgg
devcon failed.

範例 25:在類別清單中插入篩選驅動程式

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

下列清單顯示提交命令之前 DiskDrive 類別的篩選驅動程式:

    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.

此命令也會使用 /r 參數,視需要重新啟動系統,讓類別篩選變更生效。

在此範例中,定位運算子是必不可少的。 在 DevCon 處理任何類別篩選子命令之前,虛擬數據指標位於清單的開頭,而且不會位於任何篩選驅動程式上。 如果您在游標不在驅動程式上時使用 add-before (+) 運算符,DevCon 會將驅動程式新增至清單的開頭。 如果您在游標不在驅動程式上時使用附加元件 (-) 運算符,它會將驅動程式新增至清單的結尾。

作為回應,DevCon 會顯示 DiskDrive 類別目前的上層篩選驅動程式:

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

您也可以使用下列命令來新增 MyFilter 驅動程式,並將它放在 PartMgr 和 Disklog 之間。 在此範例中,第一個子命令 @PartMgr會將虛擬游標放在 PartMgr 篩選驅動程式上。 The second subcommand, +MyFilter, uses the add-after operator (+) to add MyFilter.sys after PartMgr:

devcon /r classfilter DiskDrive upper @PartMgr +MyFilter

範例 26:取代篩選驅動程式

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

下列清單顯示提交命令之前 DiskDrive 類別的篩選驅動程式:

    PartMgr
    MyFilter
    Disklog

第一個子命令會使用 delete 運算子 (!,驚嘆號) 從 DiskDrive 類別的上層篩選驅動程式清單中刪除 MyFilter。 (It doesn't affect the MyFilter.sys file in the C:\Windows\System32\Drivers directory location.)

第二個子命令會使用附加元件運算子 (+) 將新的篩選驅動程式放在已刪除驅動程式先前所佔用的位置。 由於 delete 運算符會將游標保留在已刪除篩選所佔用的位置,因此 add-before () 和 add-after (-+) 運算子具有相同的效果。

此命令也會使用 /r 參數,視需要重新啟動系統,讓類別篩選變更生效。

作為回應,DevCon 會顯示 DiskDrive 類別的新類別篩選組態:

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

範例 27:變更篩選驅動程式的順序

The following command uses the DevCon ClassFilter operation to change the order of filter drivers for the DiskDrive setup class. 具體來說,它會反轉第二個和第三個篩選驅動程式的順序。

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

下列清單顯示在提交命令之前,DiskDrive 類別的篩選驅動程式。 它也會顯示指令的預期結果。

Before After
PartMgr PartMgr
MyNewFilter Disklog
Disklog MyNewFilter

第一個子命令會使用 delete 運算子 (!) 從清單中刪除 Disklog。 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. 開始運算子是必要的,因為虛擬游標只會在清單中向前移動。 最後的子命令會使用附加元件運算子 (+) 在 PartMgr 之後新增 Disklog。

作為回應,DevCon 會顯示 DiskDrive 類別的新類別篩選組態:

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

範例 28:啟用特定裝置

The following command uses the DevCon Enable operation to enable a previously disabled programmable interrupt controller. 受控制者已停用,然後重新啟用以更正系統問題。 由於此範例中的控制器硬體標識碼包含星號 (*PNP0000),因此命令會使用單引號字元 (') 來指示 DevCon,以精確如命令中所指定的方式尋找硬體識別碼。 如果命令在此實例中未使用引號字元 ('),DevCon 會將 值中的星號 (*) 解譯為通配符。

devcon enable '*PNP0000

作為回應,DevCon 會顯示裝置的裝置實例識別碼,並說明您必須重新啟動系統才能啟用裝置:

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.

下列命令會將 /r 參數新增至上一個命令。 參數 /r 會視需要重新啟動系統,以完成作業。

devcon /r enable '*PNP0000

作為回應,DevCon 會啟用裝置,然後重新啟動系統,讓啟用作業生效。

當系統啟動時,請使用 DevCon status 命令來確認裝置已啟用:

devcon status '*PNP0000

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

範例 29:依類別啟用裝置

The following command enables all printer devices on the computer by specifying the Printer setup class in a DevCon Enable command. 此命令包含 /r 參數,其會視需要重新啟動系統,讓啟用作業生效。

devcon /r enable =Printer

作為回應,DevCon 會顯示在 Printer 類別中找到的印表機裝置實例識別碼,並報告印表機已啟用。 雖然命令包含 /r 參數,但系統不會重新啟動,因為不需要重新啟動才能啟用印表機。

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

範例 30:依 ID 型樣停用裝置

The following command uses the DevCon Disable operation to disable the USB devices on the local computer. 它會以硬體識別碼模式 (USB*) 識別裝置。 此模式會比對任何以 「USB」 開頭的硬體識別碼或相容標識碼的裝置。此命令包含 /r 參數,其會視需要重新啟動系統,讓停用作業生效。

Note

使用標識碼模式停用裝置之前,請先判斷哪些裝置可能受到影響。 在顯示命令中使用 模式,例如 devcon status USB*devcon hwids USB*

devcon /r disable USB*

作為回應,DevCon 會顯示USB裝置的裝置實例標識碼,並回報其已停用。 雖然命令包含 /r 參數,但系統不會重新啟動,因為不需要重新啟動才能停用裝置。

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.

範例 31:透過裝置執行個體識別碼停用裝置

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. 每個裝置實例 ID 都以空格與其他實例 ID 分隔。

當裝置標識碼包含 ampersand (&) 符號時,值會以引號括住 (" ")。 此命令包含 /r 參數,其會視需要重新啟動系統,讓停用作業生效。

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

作為回應,DevCon 會顯示USB裝置的裝置實例標識碼,並回報其已停用。 雖然命令包含 /r 參數,但系統不會重新啟動,因為不需要重新啟動才能停用裝置。

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.

範例 32:更新通訊埠的驅動程式

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. 此命令只會影響其整個硬體標識碼 *PNP0501 為 (包括星號 *) 的裝置。

您可以使用此命令,將系統上的已簽署驅動程式取代為替代驅動程式,以進行測試或疑難排解,或將裝置與相同驅動程式的最新版本相關聯。

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 會顯示下列成功訊息:

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. 因此,DevCon 無法更新驅動程式,並顯示失敗訊息:

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

範例 33:安裝裝置

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

作為回應,DevCon 會報告它已安裝裝置。 也就是說,DevCon 會為新裝置建立裝置節點,並更新裝置的驅動程序檔案。

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

範例 34:使用自動安裝安裝來安裝裝置

下列範例示範如何在自動安裝 Microsoft Windows XP 期間安裝 Microsoft 回送配接器。

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).

然後在自動安裝檔的 區段中新增下列 DevCon 命令 [GUIRunOnce]

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

此命令會使用其硬體標識碼 *MSLOOP來識別回送適配卡。 值\*MSLOOP前面的單引號字元 (') 會通知 DevCon 以字面方式解譯字串。 因此,DevCon 會將星號 (*) 解譯為硬體標識碼的一部分,而不是通配符。

The command also specifies that DevCon use the Netloop.inf file (on the floppy disk) in the installation. 參數 /r 會視需要重新啟動計算機,以完成安裝。

最後,將網路設定新增至無人值守安裝檔案,並執行無人值守安裝程式。

範例 35:依裝置實例識別碼模式移除裝置

The following command uses the DevCon Remove operation to remove all USB devices from the computer. 它會使用裝置實例標識碼模式來識別裝置,該模式符合以 「USB」 字串開頭的任何裝置實例識別碼(登錄路徑)。 The command uses the at symbol (@) to distinguish the device instance ID from a hardware ID or compatible ID. 此命令也包含 /r 參數,可視需要重新啟動系統,讓移除生效。

Warning

使用標識碼模式移除裝置之前,請先判斷哪些裝置可能受到影響。 在顯示命令中使用 模式,例如 devcon status @usb\*devcon hwids @usb\*

devcon /r remove @usb\*

作為回應,DevCon 會顯示已移除裝置的裝置實例標識碼:

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.

範例 36:移除特定網路裝置

The following command uses the DevCon Remove operation to uninstall the NDISWAN miniport driver from the local computer. 命令會指定 Net 類別,然後在類別中指定硬體識別碼或相容標識碼包含 「ndiswan」 的裝置,以精簡搜尋。此命令也包含 /r 參數,其會視需要重新啟動系統,讓移除生效。

Warning

使用標識碼模式移除裝置之前,請先判斷哪些裝置可能受到影響。 在顯示命令中使用 模式,例如 devcon status =net *ndiswandevcon hwids =net *ndiswan*

devcon /r remove =net *ndiswan*

作為回應,DevCon 會顯示已移除裝置的裝置實例標識碼:

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

範例 37:掃描電腦以尋找新裝置

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

devcon rescan

作為回應,DevCon 會報告其已掃描系統,但找不到任何新裝置:

Scanning for new hardware.
Scanning completed.

範例 38:重新啟動裝置

The following command uses the DevCon Restart operation to restart the loopback adapter on the local computer. 命令會將搜尋限制為 Net setup 類別,並在該類別內指定回送適配卡 @'ROOT\*MSLOOP\0000的裝置實例識別碼。

The at symbol (@) identifies the string value as a device instance ID. 單引號字元 (') 會通知 DevCon 以字面方式解譯字串。 因此,DevCon 會將星號 (*) 解譯為標識符的一部分,而不是通配符。

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

作為回應,DevCon 會顯示裝置的裝置實例標識碼,並報告結果:

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

範例 39:重新啟動本機電腦

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.

您可以將此命令包含在需要系統重新啟動的腳本和批次檔中。

devcon reboot

回應中,DevCon 會顯示一則訊息,指出其正在重新啟動電腦(重新啟動本機計算機)。

DevCon uses the standard ExitWindowsEx function to reboot. 如果使用者在計算機上開啟檔案或程式未關閉,系統就不會重新啟動。 它會等到使用者回應系統提示以關閉檔案或結束程序為止。

範例 40:將硬體識別碼指派給舊版裝置

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

命令會使用裝置的裝置 ROOT\LEGACY_BEEP\0000 實例標識碼,因為嗶聲舊版裝置沒有硬體標識碼或相容的標識符。 The command uses the at symbol (@) to indicate that the string is a device instance ID.

命令不會使用任何符號參數來放置標識碼。 根據預設,DevCon 會將新的硬體識別碼新增至硬體識別碼清單的結尾。 在此情況下,因為裝置沒有其他硬體標識碼,因此標識元放置無關緊要。

devcon sethwid @ROOT\LEGACY_BEEP\0000 := beep

作為回應,DevCon 會顯示訊息,指出它已新增 beep 至裝置的硬體標識符清單。 它還顯示產生的硬體 ID 清單。 在此情況下,清單中只有一個硬體識別碼:

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

範例 41:將硬體識別碼新增至所有舊版裝置

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

此命令會使用減號 (-) 參數,將新的硬體識別元新增至裝置的硬體標識符清單結尾,以防其中一個裝置存在慣用的硬體識別符。 它也會使用裝置實例標識符模式 @ROOT\LEGACY*,來識別電腦上的舊版裝置,也就是所有具有以 開頭之裝置實例標識碼的 ROOT\LEGACY*裝置。

devcon sethwid @ROOT\LEGACY* := -legacy

作為回應,DevCon 會顯示所有受影響裝置所產生的硬體標識碼清單:

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).

將相同的硬體識別碼指派給一組裝置之後,您可以使用其他 DevCon 作業,在單一命令中檢視和變更裝置。

例如,下列命令會顯示所有舊版裝置的狀態:

devcon status legacy

範例 42:從所有舊版裝置刪除硬體 ID

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

命令會使用硬體標識碼 legacy 來識別具有該硬體標識碼的所有裝置。 它會使用 delete 運算子 (!) 來刪除 legacy 硬體識別碼。

devcon sethwid legacy := !legacy

作為回應,DevCon 會顯示所有受影響裝置所產生的硬體標識碼清單:

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).

範例 43:新增、刪除及取代硬體 ID

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. 在針對裝置執行 DevCon 命令之前,裝置具有下列硬體識別碼清單:

Hw3 Hw4

下列命令會使用加號 (+) 來新增標識符值 Hw1 ,以及 Hw2 DeviceX 硬體識別碼清單的開頭。 因為標識碼 Hw2 已經出現在清單中,因此會移動標識碼值,而不會新增。 The command uses the at symbol (@) to identify the device by its device instance ID.

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

作為回應,DevCon 會顯示裝置的新硬體識別碼清單。 和 Hw2 識別碼Hw1值會以指定的順序出現在標識子清單的開頭:

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

此外,DevCon 會報告它已修改一個硬體標識符清單,也就是單一裝置的硬體標識符清單。

下列命令會使用 delete 運算子 (!) 來刪除 Hw1 硬體識別碼。 然後,它會列出沒有符號參數的硬體標識碼 Hw5 。 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

作為回應,DevCon 會顯示 DeviceX 產生的硬體識別碼清單:

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

下列命令會使用 equals (=) 參數,將 DeviceX 清單中的所有硬體識別碼取代為單一硬體識別碼 DevX

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

作為回應,DevCon 會顯示 DeviceX 產生的硬體識別碼清單:

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

成功訊息表示 DevCon 修改了一台裝置的硬體識別碼。

範例 44:強制更新 HAL

下列範例說明如何使用 DevCon 來更新電腦上的 HAL。 目前的 HAL 是一種使用進階設定和電源介面 (ACPI) 和進階可程式化插斷控制器 (APIC) 建置的單處理器_up(適用於計算機)。 測試人員想要將類型變更為多處理器 (_mp) ACPI APIC HAL,以供測試之用。

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. 命令會使用加號 (+) 來指定 acpiapic_mp 為 HAL 清單中的第一個硬體識別碼。 此命令會使用 delete 運算子 (!) 從 HAL 的識別碼清單中刪除 acpiapic_up 硬體識別碼。

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

作為回應,DevCon 會顯示下列 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 會顯示下列成功訊息:

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

範例 45:新增和移除驅動程式套件

下列範例示範如何使用 DevCon 在驅動程式存放區中新增、刪除和顯示協力廠商 (OEM) 驅動程式套件。

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. 此命令包含 Toaster 範例驅動程式 INF 檔案的完整限定路徑。

此命令適用於第三方 (OEM) 驅動程式和裝置,但您可以使用 Toaster 範例來測試命令。

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.

將 INF 檔案複製到驅動程式存放區之前,Windows 會將檔案的二進位版本與驅動程式存放區中的類似檔案進行比較。 它會檢查以確認沒有具有相同 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. 它只會報告現有檔案的名稱,如下列 DevCon 輸出所示:

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.

下列命令會列出所有 OEM 驅動程式套件及其幾個屬性:

devcon dp_enum

作為回應,DevCon 會產生下列輸出:

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. 您可以使用此資訊來刪除與檔案相關聯的驅動程式套件。

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

回應中,DevCon 會顯示訊息,指出命令成功:

Driver Package 'oem2.inf' deleted.

The OEM.inf* file name is required in the DevCon Dp_delete operation. 如果您嘗試使用 INF 檔案的原始名稱,命令會失敗,如下列 DevCon 輸出所示:

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