How to completely uninstall driver from Vista?

Hello,

I have a WDM-based NDIS driver (myDriver) and I am trying to port the following Driver Uninstall pseudo-code from XP to Vista:

RemoveDevice()

{

// Get DeviceInfoSet using SetupDiGetClassDevs(&GUID_DEVLASS_NET,…)

// Using SetupEnumDeviceInfo() and SetupDiGetDeviceRegistryProperty(),

// find the driver whose hwID matches myDriver’s hwID

// Once the matching driver is found, do:

SetupDiCallClassInstaller(DIF_REMOVE, …);

}

I observe that the above code will completely uninstall the driver on Windows XP, but not on Windows Vista. By "completely ", I mean that after running RemoveDevice(), the next time I try to install the driver, it should show me the “Warning: driver is unsigned…”. I get this warning on Windows XP, but not on Vista.

I have debugged this and found that, on Windows Vista, myDriver is not removed from C:\WINDOWS\System32\DriverStore\ after executing RemoveDevice(). I also see that I have to check the “Uninstall all system files” checkbox in DeviceManager->Uninstall dialog to remove myDriver “completely”

Is there a change in the Vista uninstaller that I am missing? What should I do in RemoveDevice() to completely remove myDriver??

Thanks,
Ashish


Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545433

Ashish wrote:

Is there a change in the Vista uninstaller that I am missing? What
should I do in RemoveDevice() to completely remove myDriver??

Calling DIF_REMOVE removes device instances, not installed drivers. This is true for both XP and Vista.

The semantics for the hardware wizard are a little different on Vista, which is why you don’t see the warning box more than once.

However, this doesn’t mean the driver is or is not present. If you want to remove drivers from the system, use DriverPackageUninstall() from the DIFX API (again, on both XP and Vista).

Hi Chris,
Thanks for a very helpful answer.

chris.aseltine wrote:

If you want to remove drivers from the system, use
DriverPackageUninstall() from the DIFX API
(again, on both XP and Vista).

I added a call to DriverPackageUninstall() after SetupDiCallClassInstaller(DIF_REMOVE, …) inside RemoveDevice() and the uninstall driver seems to uninstall driver correctly. I am now seeing some problems with InstallDriver(), my driver installation function, the pseudocode for which is as follows:

InstallDriver()
{
SetupDiCreateDeviceInfoList(GUID_DEVCLASS_NET, …);
SetupDiCreateDeviceInfo(…, myDeviceName, …);
SetupDiDeviceRegistryProperty(…, hwidList, …);
SetupDiCallClassInstaller(DIF_REGISTERDEVICE)
UpdateDriverForPlugAndPlayDevices(…, MY_INF_PATH, INSTALLFLAG_FORCE, …)
}

I am wondering whether installation via UpdateDriverForPlugAndPlayDevices() is compatible with uninstallation via DriverPackageUninstall()? Do I have to replace UpdateDriverForPlugAndPlayDevices() with DriverPackageInstall()? I would like to avoid this code-change, if possible.

Thanks,
Ashish


Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545433

Ashish wrote:

I am wondering whether installation via UpdateDriverForPlugAndPlayDevices()
is compatible with uninstallation via DriverPackageUninstall()? Do I have
to replace UpdateDriverForPlugAndPlayDevices() with DriverPackageInstall()?
I would like to avoid this code-change, if possible.

You should preinstall your driver package with DriverPackagePreinstall() before you create any devices. Then when the device is created, setup will find the drivers automatically. That’s the easiest way.