Uninstall for good

Most companies will want to ship a driver with a nice installation wizard.
It is easy from there to do the installation job in one step, by calling
UpdateDriverForPlugAndPlayDevices().

Why is there no symmetrical function for uninstalling a driver?

In the uninstaller for my driver, I’d like not only to remove the device
from the device manager but also to remove all files that have been created
during the installation. Unfortunately, this is a difficult thing to do, if
at all possible, because one would need to remove the driver file (ok, let’s
reasonably assume it was copied into system32\drivers) but also the INF
which has been renamed as OEM_XXX.INF. I’m not even referring to the
various registry keys that are created.

How should one proceed to completely remove the footprint of a driver, or at
least the files it created, when uninstalling? I’m working on a virtual
device driver and it makes a lot of sense to uninstall it when uninstalling
the associated application.

Mat

This is Microsoft’s designed behavior. You might want to completely cleanup
after yourself, but they have other ideas. We have repeatedly discussed how
to do this on a test system. On a production system, in my opinion, this is
Microsoft’s problem, not yours, and you should just go with the flow.

=====================
Mark Roddy

-----Original Message-----
From: Mathieu Routhier [mailto:xxxxx@encentrus.com]
Sent: Monday, September 20, 2004 3:02 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Uninstall for good

Most companies will want to ship a driver with a nice installation wizard.
It is easy from there to do the installation job in one step, by calling
UpdateDriverForPlugAndPlayDevices().

Why is there no symmetrical function for uninstalling a driver?

In the uninstaller for my driver, I’d like not only to remove the device
from the device manager but also to remove all files that have been created
during the installation. Unfortunately, this is a difficult thing to do, if
at all possible, because one would need to remove the driver file (ok, let’s
reasonably assume it was copied into system32\drivers) but also the INF
which has been renamed as OEM_XXX.INF. I’m not even referring to the
various registry keys that are created.

How should one proceed to completely remove the footprint of a driver, or at
least the files it created, when uninstalling? I’m working on a virtual
device driver and it makes a lot of sense to uninstall it when uninstalling
the associated application.

Mat


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@stratus.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

This is extremely hard and Microsoft is working to fix this in the future.
The problems right now are what happens if someone else starts installing
the same stuff you are. For instance if you have a class installer /
property page provider, and a second product starts using the same class,
you don’t want to remove the class installer since it is still in use.

Don’t try to uninstall things to this level right now, it isn’t worth the
effort. Note: I do have a proceedure for doing this by hand on a test
machine, but I never recomend it for a shipping product.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply

“Mathieu Routhier” wrote in message
news:xxxxx@ntdev…
> Most companies will want to ship a driver with a nice installation wizard.
> It is easy from there to do the installation job in one step, by calling
> UpdateDriverForPlugAndPlayDevices().
>
> Why is there no symmetrical function for uninstalling a driver?
>
> In the uninstaller for my driver, I’d like not only to remove the device
> from the device manager but also to remove all files that have been
created
> during the installation. Unfortunately, this is a difficult thing to do,
if
> at all possible, because one would need to remove the driver file (ok,
let’s
> reasonably assume it was copied into system32\drivers) but also the INF
> which has been renamed as OEM_XXX.INF. I’m not even referring to the
> various registry keys that are created.
>
> How should one proceed to completely remove the footprint of a driver, or
at
> least the files it created, when uninstalling? I’m working on a virtual
> device driver and it makes a lot of sense to uninstall it when
uninstalling
> the associated application.
>
> Mat
>
>
>

To remove the OEM_XXX.INF I use something like this:

HKEY hKey = SetupDiOpenDevRegKey(
DeviceInfoSet, // IN HDEVINFO DeviceInfoSet,
&DeviceInfoData, // IN PSP_DEVINFO_DATA DeviceInfoData,
DICS_FLAG_GLOBAL, // IN DWORD Scope,
0, // IN DWORD HwProfile,
DIREG_DRV, // IN DWORD KeyType,
KEY_QUERY_VALUE); // IN REGSAM samDesired

RegQueryValueEx(
hKey, // HKEY hKey,
TEXT(“InfPath”), // LPCTSTR lpValueName,
NULL, // LPDWORD lpReserved,
&dwType, // LPDWORD lpType,
(LPBYTE)szInfPath, // LPBYTE lpData,
&dwSize); // LPDWORD lpcbData

TCHAR szInfFullPath[MAX_PATH];
int iLen = wsprintf( szInfFullPath, TEXT(“%s\Inf\%s”), _tgetenv(
TEXT(“WINDIR”) ), szInfPath );
if (!DeleteFile( szInfFullPath ) && GetLastError() != ERROR_FILE_NOT_FOUND)
DisplayError(TEXT(“DeleteFile .INF”));

PaoloC

----- Original Message -----
From: “Mathieu Routhier”
To: “Windows System Software Devs Interest List”
Sent: Monday, September 20, 2004 9:01 PM
Subject: [ntdev] Uninstall for good

> Most companies will want to ship a driver with a nice installation wizard.
> It is easy from there to do the installation job in one step, by calling
> UpdateDriverForPlugAndPlayDevices().
>
> Why is there no symmetrical function for uninstalling a driver?
>
> In the uninstaller for my driver, I’d like not only to remove the device
> from the device manager but also to remove all files that have been
created
> during the installation. Unfortunately, this is a difficult thing to do,
if
> at all possible, because one would need to remove the driver file (ok,
let’s
> reasonably assume it was copied into system32\drivers) but also the INF
> which has been renamed as OEM_XXX.INF. I’m not even referring to the
> various registry keys that are created.
>
> How should one proceed to completely remove the footprint of a driver, or
at
> least the files it created, when uninstalling? I’m working on a virtual
> device driver and it makes a lot of sense to uninstall it when
uninstalling
> the associated application.
>
> Mat
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@tin.it
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

Check out devcon remove. Note that the source code for devcon.exe is in the
DDK under src\setup\devcon.
With respect to removing files you will have to add that to devcon.exe or
perhaps from within your driver inf file, but devcon we indeed uninstall all
instants of your driver.

Sincerely;
William Michael Jones

“Mathieu Routhier” wrote in message
news:xxxxx@ntdev…
> Most companies will want to ship a driver with a nice installation wizard.
> It is easy from there to do the installation job in one step, by calling
> UpdateDriverForPlugAndPlayDevices().
>
> Why is there no symmetrical function for uninstalling a driver?
>
> In the uninstaller for my driver, I’d like not only to remove the device
> from the device manager but also to remove all files that have been
created
> during the installation. Unfortunately, this is a difficult thing to do,
if
> at all possible, because one would need to remove the driver file (ok,
let’s
> reasonably assume it was copied into system32\drivers) but also the INF
> which has been renamed as OEM_XXX.INF. I’m not even referring to the
> various registry keys that are created.
>
> How should one proceed to completely remove the footprint of a driver, or
at
> least the files it created, when uninstalling? I’m working on a virtual
> device driver and it makes a lot of sense to uninstall it when
uninstalling
> the associated application.
>
> Mat
>
>
>

Yes, I already use a method which is inspired (read ‘ripped’) from devcon.
This unloads the driver and removes the device from the device manager, but
it does not delete the associated files and stuff. I wish it would…!

Mat

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Michael Jones
Sent: Monday, September 20, 2004 3:34 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Uninstall for good

Check out devcon remove. Note that the source code for devcon.exe is in the
DDK under src\setup\devcon.
With respect to removing files you will have to add that to devcon.exe or
perhaps from within your driver inf file, but devcon we indeed uninstall all
instants of your driver.

Sincerely;
William Michael Jones

“Mathieu Routhier” wrote in message
news:xxxxx@ntdev…
> Most companies will want to ship a driver with a nice installation wizard.
> It is easy from there to do the installation job in one step, by calling
> UpdateDriverForPlugAndPlayDevices().
>
> Why is there no symmetrical function for uninstalling a driver?
>
> In the uninstaller for my driver, I’d like not only to remove the device
> from the device manager but also to remove all files that have been
created
> during the installation. Unfortunately, this is a difficult thing to do,
if
> at all possible, because one would need to remove the driver file (ok,
let’s
> reasonably assume it was copied into system32\drivers) but also the INF
> which has been renamed as OEM_XXX.INF. I’m not even referring to the
> various registry keys that are created.
>
> How should one proceed to completely remove the footprint of a driver, or
at
> least the files it created, when uninstalling? I’m working on a virtual
> device driver and it makes a lot of sense to uninstall it when
uninstalling
> the associated application.
>
> Mat
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@encentrus.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Very nice! I vaguely remembered something in SetupApi that did that. Glad
to know that it works for you!

Unfortunately, I’m still not convinced that I should even dare fooling with
that. Sounds like risky territory :frowning:

Mat

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of PaoloC
Sent: Monday, September 20, 2004 3:23 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Uninstall for good

To remove the OEM_XXX.INF I use something like this:

HKEY hKey = SetupDiOpenDevRegKey(
DeviceInfoSet, // IN HDEVINFO DeviceInfoSet,
&DeviceInfoData, // IN PSP_DEVINFO_DATA DeviceInfoData,
DICS_FLAG_GLOBAL, // IN DWORD Scope,
0, // IN DWORD HwProfile,
DIREG_DRV, // IN DWORD KeyType,
KEY_QUERY_VALUE); // IN REGSAM samDesired

RegQueryValueEx(
hKey, // HKEY hKey,
TEXT(“InfPath”), // LPCTSTR lpValueName,
NULL, // LPDWORD lpReserved,
&dwType, // LPDWORD lpType,
(LPBYTE)szInfPath, // LPBYTE lpData,
&dwSize); // LPDWORD lpcbData

TCHAR szInfFullPath[MAX_PATH];
int iLen = wsprintf( szInfFullPath, TEXT(“%s\Inf\%s”), _tgetenv(
TEXT(“WINDIR”) ), szInfPath );
if (!DeleteFile( szInfFullPath ) && GetLastError() != ERROR_FILE_NOT_FOUND)
DisplayError(TEXT(“DeleteFile .INF”));

PaoloC

----- Original Message -----
From: “Mathieu Routhier”
To: “Windows System Software Devs Interest List”
Sent: Monday, September 20, 2004 9:01 PM
Subject: [ntdev] Uninstall for good

> Most companies will want to ship a driver with a nice installation wizard.
> It is easy from there to do the installation job in one step, by calling
> UpdateDriverForPlugAndPlayDevices().
>
> Why is there no symmetrical function for uninstalling a driver?
>
> In the uninstaller for my driver, I’d like not only to remove the device
> from the device manager but also to remove all files that have been
created
> during the installation. Unfortunately, this is a difficult thing to do,
if
> at all possible, because one would need to remove the driver file (ok,
let’s
> reasonably assume it was copied into system32\drivers) but also the INF
> which has been renamed as OEM_XXX.INF. I’m not even referring to the
> various registry keys that are created.
>
> How should one proceed to completely remove the footprint of a driver, or
at
> least the files it created, when uninstalling? I’m working on a virtual
> device driver and it makes a lot of sense to uninstall it when
uninstalling
> the associated application.
>
> Mat
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@tin.it
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@encentrus.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

> Why is there no symmetrical function for uninstalling a driver?

No. Microsoft does not want the drivers to be ever removed from a system.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

About the only way I have found to easily remove a driver and all its
affects after install is to re-image from a backup image of the OS
partition, or to set a check point in XP and use System Restore. Obviously
the former is the most reliable but also the most pain in the ass to use.
System Restore only works on XP but is fairly reliable for NTFS partitions.
I have seen it fail on FAT32 partitions or duplicate FAT32 directory
structures.

Gee Don, I had it on good authority that you were the resident guru on
uninstall. One of my peers even flung one of your threads my way saying
“See, I told you so!” I giggled and basically ignored him. :slight_smile:


The personal opinion of
Gary G. Little

“Mathieu Routhier” wrote in message
news:xxxxx@ntdev…
> Most companies will want to ship a driver with a nice installation wizard.
> It is easy from there to do the installation job in one step, by calling
> UpdateDriverForPlugAndPlayDevices().
>
> Why is there no symmetrical function for uninstalling a driver?
>
> In the uninstaller for my driver, I’d like not only to remove the device
> from the device manager but also to remove all files that have been
created
> during the installation. Unfortunately, this is a difficult thing to do,
if
> at all possible, because one would need to remove the driver file (ok,
let’s
> reasonably assume it was copied into system32\drivers) but also the INF
> which has been renamed as OEM_XXX.INF. I’m not even referring to the
> various registry keys that are created.
>
> How should one proceed to completely remove the footprint of a driver, or
at
> least the files it created, when uninstalling? I’m working on a virtual
> device driver and it makes a lot of sense to uninstall it when
uninstalling
> the associated application.
>
> Mat
>
>
>