I did a google search and found tools like devcon and devmanview but they are only useful to disable/enable the device not the device driver. What I want to do is be able to disable/enable a particular device driver via command line. Anybody know any tool which can help me do this?
In my case, I actually want to disable/enable a Nvme Mass storage device driver.
Update-
I tried using the sc.exe suggested, but I didn't succeed in stopping the driver. Any help?
C:\Users\Administrator>sc query nvme
SERVICE_NAME: nvme
TYPE : 1 KERNEL_DRIVER
STATE : 4 RUNNING
(STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
C:\Users\Administrator>sc stop nvme [SC] ControlService FAILED 1052:
The requested control is not valid for this service.
Best Answer
You can use the
sc.exe
utility for this.sc query type= driver | findstr WHAT_IM_LOOKING_FOR
If you find what you're looking for, you can at stop the driver with:
sc stop EXACT_DRIVER_NAME_AS_LISTED_BY_QUERY
Obviously you'll need a shell with administrator privileges to do this. If you're looking to automate this at login, you can make a batch file and install it as an administrator with task scheduler. Tasks installed that require administrator privileges, but were installed by an administrator, will not prompt for privileges at startup, but will be granted them automatically.