Scan for hardware changes in Windows using command line

How can I scan for hardware changes in Windows using the command line? I'm looking for the same functionality as right-click "Scan for Hardware Changes" in the Device Manager.


Solution 1:

Get a copy of Microsoft's devcon utility. Then use the following to scan for new hardware:

devcon rescan

Solution 2:

It seems that Windows 10 ships with PnPUtil.exe. Run pnputil.exe /scan-devices from administrative command prompt to scan for hardware changes.

Create a batch file with the command. Create a shortcut to the file on Desktop by selecting "Send to Desktop" option from context menu (right click) of the file. Now you can change properties of the shortcut (shortcut -> Properties -> Advanced) to always run with administrative access.

This shortcut is easily available from Windows search. So, a Win button plus few keystrokes can do the job.

https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/devcon https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/pnputil