How can I manually load/unload a driver in Windows Vista?

I think one of my drivers is causing some of my Windows Vista machines to boot extremely slow. Since the perf log is basically no help, I want to try manually unloading/loading drivers to see if any take a considerable amount of time to start up. How can I do this?


Solution 1:

Drivers and Services have a very similiar control interface in Windows. You can set the "Start" value on their entry in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services to "Disabled", reboot, and see how the machine does booting w/o that driver loading.

To find out the "Service" name for a given driver examine the "Details" tab of the device in "Device Manager" and look at the "Service" entry. Once you have that, you can record the current startup status of the driver by examining the "Start" value in the driver's key under the "Services" key I mentioned earlier. Change the "Start" value to 4 to disable the driver on the subsequent boot. (And change it back to what you found when you're done testing!)

You could certainly script this change using the command-line REG program. This CMD script below would change the "Start" type for the service name passed on the command-line to disabled after displaying the current start type:

@echo off
if "%1"=="" goto syntax

reg query "HKLM\System\CurrentControlSet\Services\%1" /v Start > NUL 2>NUL
if errorlevel 1 goto no_service

echo Current Start setting for service "%1":
reg query "HKLM\System\CurrentControlSet\Services\%1" /v Start | find /i "Start"

reg add "HKLM\System\CurrentControlSet\Services\%1" /v Start /t REG_DWORD /d 4 /f > NUL 2> NUL
echo Service "%1" set to Disbled.
goto end

:no_service
echo The service specified, "%1" was not found!
goto end

:syntax
echo %0 service_name_to_disable

:end

You might have some luck figuring out what the driver is doing by using the "Process Monitor" boot logging functionality, too.

Solution 2:

Pasting my quick&dirty snippet regarding "devcon" utility. I used this with Ultrium drivers, but works with any other. Not sure if it works in Vista:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272     # download devcon

# For device (status)
devcon driverfiles *Ultrium*
devcon drivernodes *Ultrium*
devcon find *Ultrium*           # also remote -m:\\machine
devcon findall *Ultrium*        # w/removed     # also remote -m:\\machine
devcon hwids *Ultrium*          # also remote -m:\\machine
devcon resources *Ultrium*      # also remote -m:\\machine
devcon stack *Ultrium*          # also remote -m:\\machine
devcon status *Ultrium*

# For device (disruptive):
devcon help disable *Ultrium*
devcon help enable *Ultrium*
devcon help restart *Ultrium*
devcon help sethwid *Ultrium*       # also remote -m:\\machine
devcon help rescan

# For device (disruptive)
devcon help install <file.inf> <hwid>   # give it *exact* hwid as in inf file; if failed will install NULL driver, remove it
                    # *DEFUNCT* for tape: becomes ROOT\TAPEDRIVE\0000 instead SCSI\VENDOR_MODEL
devcon help update          # forces use of driver, even if better is already on the system (4 unsigned drivers).
devcon help updateni
devcon help remove          # this will remove device (DevMgmt->Uninstall), not uninstall driver!


# For classes
devcon help classes         # also remote -m:\\machine
devcon help listclass           # also remote -m:\\machine


# For machine
devcon reboot               # also remote -m:\\machine