DevCon - CMD


Overview

DevCon (Device Console) is a command-line tool that acts as an alternative to Device Manager. It allows users to manage devices and drivers from the command line on Windows operating systems. DevCon is particularly useful for scripting and automation in environments where GUI interaction is not feasible, such as servers or remote systems.

Syntax

The generic syntax for DevCon is:

devcon [Command] [Options] [HardwareID | Class | DeviceInstanceID | ...]

Commands vary based on the operation you intend to perform, such as install, remove, update, enable, disable, and more.

Options/Flags

DevCon uses a variety of flags and options that modify its behavior:

  • install <inf-file> <hw-id>: Install a device using the specified .inf file and hardware ID.
  • remove <id>: Remove a device using its hardware ID or instance ID.
  • update <inf-file> <hw-id>: Update a device driver using the specified .inf file and hardware ID.
  • enable <id>: Enable a device.
  • disable <id>: Disable a device.
  • status <id>: Display the status of a specific device.
  • rescan: Scan for new hardware changes.
  • classes: Display all device setup classes on the computer.
  • listclass <class>: List all devices in a specific setup class.
  • reboot: Reboot the system.

Replace <inf-file> with the path to the driver’s INF file, <hw-id> with the hardware ID, and <id> with a DeviceInstanceID or hardware ID.

Examples

  1. Install a device:
    devcon install c:\drivers\example.inf "PCI\VEN_1234&DEV_5678"
    
  2. Remove a device:
    devcon remove "@USB\VID_0000&PID_0000\5&3a332a2&0&1"
    
  3. Enable a device:
    devcon enable "ACPI\PNP0303"
    
  4. Rescan for hardware changes:
    devcon rescan
    

Common Issues

  • Driver not found: Ensure the .inf file path and hardware ID are correct.
  • Permissions: DevCon requires administrative permissions to execute most commands.
  • Device identification: Incorrect or non-specific hardware IDs can lead to targeting the wrong device.

To avoid issues, always verify hardware IDs and run the command prompt as an administrator.

Integration

DevCon can be effectively combined with batch scripts or Powershell to automate the setup and management of devices. For example:

@echo off
devcon remove "PCI\VEN_1000"
devcon rescan

This script removes a device and immediately initiates a scan for hardware changes.

  • Device Manager: GUI tool for managing devices.
  • Powershell Cmdlets for Device Management: Offers more complex and capable management features via script.

For further reading, refer to Microsoft’s official documentation: Windows Dev Center: DevCon

By using DevCon, administrators and power users can streamline device management, tailor setup processes, and automate routine tasks, enhancing efficiency when handling Windows devices and drivers.