halm
halm

Reputation: 377

The Uninstall section of my .INF

I'm working on extending an existing USB device driver, and have been struggling learn how the .INF file works. I believe that I have it right now, the driver installs and works. It also shows up in the "Add/Remove Programs" list.

I find that when I uninstall the driver from Add/Remove, it seems to do little if anything. This was in the .INF as I inherited it:

[myUninstall]
DelReg = myDelReg

[MyDelReg]
HKLM, "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\myName"

I can find no other references, not even where "myName" is installed in the registry Uninstall.

I've changed the .INF to have this:

[DefaultUninstall]
myUninstall

[myUninstall]
DelFiles = ... a list of files ...
DelDirs  = UNINST.Dirs
DelReg   = UNINST.Regs
Cleanup  = 1

[UNINST.Dirs]
%16422%\%InstallDir%

[UNINST.Regs]
myDev.AddReg
myDev.CommonRegs


[myDev.AddReg]      ; same definition used for installing
HKR,,Drivers,Subclasses,,"wave,midi,mixer,aux"
...

[myDev,CommonRegs]  ; same definition used for installing
HKR, Parameters, BufferSize, 0x0010001, 256
...

Still, whether I uninstall from the Control Panel Add/Remove programs or do it from the device manager, the system doesn't complain and nothing seems to happen. I've looked at the output of "dpinst /c" and the setupapi.log, and neither tell me much. dpinst shows no error but is clearly not even trying to execute my uninstall section.

I find a lot of verbiage online and examples of uninstall sections, but very little in the way of explanation. I did stumble across one sentence in 1 forum today that implied that PnP device .INF's don't use Uninstall. Perhaps this is my issue?

  1. am I wrong in thinking that I can have Uninstall in this .INF?
  2. is there some other way to tell what is happening?
  3. is my only recourse to write a separate uninstaller?

Upvotes: 3

Views: 2207

Answers (3)

stu
stu

Reputation: 8805

So the inf file can be used to perform some uninstallation actions, but basically you're just manually calling an arbitrary section in the inf file at uninstall time.

So if you run this:

rundll32 setupapi.dll,InstallHinfSection TestUninstall 132 .\test.inf

and you have a section in your inf file:

[TestUninstall.NT$ARCH$]
Delreg = Test.DelReg


[SlideCbt.DelReg]
...

that works. Just note that this breaks the whole Universal INF thing because you can't have a Delreg action in a universal inf file.

Upvotes: 0

Anders
Anders

Reputation: 101756

I don't think DefaultUninstall is a standard section in the way DefaultInstall is. Often you will see the UninstallString ARP entry just calling DefaultUninstall by name.

The documentation in this area is pretty bad and there is a split between the basic SetupAPI/SetupX INF files and the Advanced INF files (AdvPack).

The only 3rd-party exception I know of is TweakUI.inf from the Windows 95 PowerToys.

It has parts that look like this:

...

[Optional Components]
TweakUIInstall

[TweakUIInstall]
CopyFiles = ...
AddReg    = ...
Ini2Reg   = ...
...
InstallType    = 10 ;Typical, Custom.
Uninstall      = DefaultUnInstall

[DefaultUnInstall]
DelFiles  = ...
DelReg    = ...

But I think that only works with the optional components feature, not basic uninstallation. TweakUI v1.33 (Tweakui.exe SFX archive) has some more NT related entries and I believe the way it writes the UninstallString for NT even writes the wrong INF section. Wrong or not, it manually has to specify a INF section for normal uninstall.

Upvotes: 0

dparakh
dparakh

Reputation: 180

AFIK, the INF files do not participate in uninstallation.

You will need to write a separate uninstaller if you want to perform proper cleanup.

Further note that with Vista and beyond, Windows also includes a Driver Store, where it silently copies the driver package (inf and files references from the inf). If you want to perform a full cleanup, the driver store should also be cleaned up.

Upvotes: 0

Related Questions