Yes, you can open Device Manager from the command line. The fastest way is to press Windows+R, type devmgmt.msc and press Enter, or open Command Prompt and run start devmgmt.msc. There is no separate "Device Manager command line tool" with dozens of switches: the command line's job is simply to launch the graphical Device Manager quickly, and for deeper work you use the built-in tools that do have real text commands, such as PnPUtil, DISM and PowerShell's device cmdlets. This guide covers each method, what it is good for, and where people get stuck.
What You'll Need
- A Windows 10 or Windows 11 PC. The commands below are for Windows; they do not apply to macOS or Linux, which handle hardware differently.
- Administrator rights for anything that installs, removes or resets a device. Simply opening Device Manager works as a standard user, but you will see far fewer options.
- Command Prompt, PowerShell, or the Run box (Windows+R). All three accept the same launch command.
- The name of the device or driver you are dealing with, if you plan to use PnPUtil. You can find it in Device Manager before you start.
Step-by-Step
- Open a command line. Press Windows+R for the Run box, or open Start, type cmd or PowerShell, and choose Run as administrator if you intend to change anything. Menu labels can differ slightly between Windows versions and editions; the Run box is the most consistent route.
- Launch Device Manager. In the Run box or Command Prompt, type
devmgmt.mscand press Enter. In Command Prompt you can also typestart devmgmt.msc. PowerShell acceptsdevmgmt.mscdirectly as well. The Device Manager window opens within a second or two. Note that devmgmt.msc is a Microsoft Management Console file, so it needs the console host, which every normal Windows install includes. - Confirm you have administrator rights. Look for the standard "Show hidden devices" option under the View menu. If some menus appear greyed out, close Device Manager and relaunch your command prompt as administrator, then repeat step 2.
- Show hidden and non-present devices. This is the one thing the command line genuinely adds convenience for. Instead of clicking through menus each time, you can set an environment variable before launching: in Command Prompt, run
set DEVMGR_SHOW_NONPRESENT_DEVICES=1and thenstart devmgmt.mscin the same window. Device Manager then opens with ghost entries for hardware that has been removed. Use this to clean up old drivers that are no longer installed. - Use PnPUtil for real command line driver work. Open an elevated Command Prompt and run
pnputil /enum-driversto list third-party driver packages with their published names (for example oem12.inf). Runpnputil /enum-devices /connectedto list currently attached devices with their instance IDs. These two commands are the backbone of any scripted troubleshooting. - Remove a driver package by command. Once you have the published name from the enumeration step, run
pnputil /delete-driver oem12.inf /uninstall, replacing oem12.inf with the real name. The uninstall switch attempts to remove the device as well. Read the confirmation prompt carefully: this can disconnect the hardware until Windows reinstalls a driver on the next restart. - Scan for hardware changes without the mouse. Run
pnputil /scan-devicesto trigger the same scan as the Scan for hardware changes menu item. This is handy after plugging in a device in a remote session. - Check problem devices via PowerShell. In an elevated PowerShell window, run
Get-PnpDevice -Status Errorto list devices with problems, andGet-PnpDevice -Status Unknownfor devices Windows cannot identify. Add-Classwith a class name such as Net or Display to narrow the list. This gives you the same information Device Manager shows with its warning icons, but in text you can copy into a support ticket. - Restart or disable a device by command. In PowerShell,
Disable-PnpDevice -InstanceId "<id>" -Confirm:$falseandEnable-PnpDevice -InstanceId "<id>" -Confirm:$falsework with the instance ID from Get-PnpDevice. Take the ID exactly as printed, including any backslashes. Disabling a device that your keyboard, mouse or network adapter depends on can leave you without input or connectivity, so only disable hardware you can do without until the next restart. - Open Device Manager at a specific device. There is no supported command line switch to jump straight to one device, so the practical approach is to open Device Manager, then use the View menu's Devices by connection or Devices by type layout and expand the branch you need. If you only need the device's properties, the PowerShell commands above are faster than hunting through trees.
- Save the output for later. Redirect PowerShell output to a file, for example
Get-PnpDevice | Out-File C:\Users\YourName\devices.txt. On a machine that will not boot properly, this snapshot is often the only record of what hardware was present and which driver versions were loaded.
Common Mistakes
- Running PnPUtil without elevation. Enumeration may work, but deletion and installation fail with access errors. Always open the prompt as administrator for changes.
- Deleting a driver to "clean up" and losing the network. Removing a network adapter driver can leave a machine without internet access, which makes reinstalling the driver difficult. Have the installer on a USB stick first.
- Confusing the published name with the file name. PnPUtil uses names like oem7.inf, not the friendly driver name shown in Device Manager. Always run the enumeration command first and copy the exact value.
- Typing devmgmt.msc in a folder-restricted environment. In some locked-down systems, MMC snap-ins are blocked by policy. If the window does not open and no error appears, that is usually policy rather than a broken Windows.
- Using the wrong shell syntax.
set VAR=1is Command Prompt syntax; PowerShell uses$env:VAR=1. Mixing them is a common reason the hidden devices variable appears to do nothing. - Assuming the command line can do everything. There is no text equivalent for every Device Manager action, particularly for rollback to a previous driver. Use the graphical window for that.
Tips
- Pin a shortcut: create a desktop shortcut to
devmgmt.mscand set it to run as administrator, so you skip the elevation step every time. - Run commands in the same window as the environment variable; the variable only applies to that session, which is exactly what you want for a one-off cleanup.
- Export
pnputil /enum-driversoutput before removing anything. It is your rollback list, since Windows does not offer a simple undo for deleted driver packages. - On machines joined to a company network, check whether driver changes are managed by policy before you remove anything; an automatic reinstall may undo your work or trigger an alert.
- For a device that keeps reinstalling itself after removal, the problem is usually a pending update or a driver still staged in the driver store. Removing the package, not just the device, is the fix.
Troubleshooting
If devmgmt.msc does nothing, first check that you typed the extension; without .msc Windows will not know what to open. If a dialog says the snap-in cannot be opened, restart the console host by signing out and back in, then try again. If the machine is managed, contact whoever administers it, because a policy is likely blocking the tool.
If PnPUtil reports access denied, you are almost certainly not elevated. If it reports that no matching devices were found, copy the instance ID again from a fresh enumeration rather than from memory, since IDs change after reinstallation. If a driver removal fails with a file-in-use error, restart and try before any device reattaches, or use Device Manager to uninstall the device first.
If PowerShell says a command is not recognized, confirm you are in the standard Windows PowerShell, not an older shell, and that you typed the hyphenated cmdlet name correctly. If devices disappear after a change, restart immediately: Windows usually reinstalls a basic driver on boot. As a last resort, use System Restore if it was enabled before the change, warning that restoring reverts other software changes made since the restore point as well.
Frequently Asked Questions
Is there a Device Manager command line tool with switches?
No. Device Manager is a graphical MMC snap-in, so the command line launches it. Real text control comes from PnPUtil and PowerShell device cmdlets.
What is the quickest way to open Device Manager?
Windows+R, type devmgmt.msc, press Enter. It works in Command Prompt and PowerShell too.
Does this work on Windows Home editions?
Yes. Devmgmt.msc and PnPUtil are included in both Home and Pro. Some group policy controls only exist in Pro and above.
Can I see removed devices from the command line?
Set the hidden devices environment variable, then launch Device Manager, or use PowerShell's Get-PnpDevice filters for non-present devices.
Do these commands work on a Mac?
No. They are Windows-only. macOS uses different system tools and has no Device Manager equivalent.
Will removing a driver package delete my data?
No, but it can disable hardware until a driver returns. Back up important files and keep installer copies before driver work.