[Tutorial] Custom INF Uninstall Template *Updated 07-20-07*

Discuss & post Update Pack addons here.
Post Reply
User avatar
ricktendo64
Posts: 3213
Joined: Mon May 22, 2006 12:27 am
Location: Honduras

[Tutorial] Custom INF Uninstall Template *Updated 07-20-07*

Post by ricktendo64 » Mon Jun 04, 2007 7:03 pm

I wrote this template to create a INF Uninstaller for those small apps that come in zip files and don't have any install/uninstallers.

Code: Select all

;ricktendo64 2007

[Version]
Signature=$Windows NT$

;Add this to your [Optional Componenets]
[Add This]
AddReg=Uninstall.AddReg

;Tells the INF what directory & sub-folder the [Program.Files] are located
[DestinationDirs]
Program.Files=16422,%PROG_DIR%

;Adds option to "Add or Remove Programs"
[Uninstall.AddDelReg]
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%PROG_NAME%","DisplayIcon",0,"%16422%\%PROG_DIR%\Program.exe"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%PROG_NAME%","DisplayName",0,"%PROG_NAME%"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%PROG_NAME%","DisplayVersion",0,"%VERS%"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%PROG_NAME%","NoModify",0x10001,01,00,00,00
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%PROG_NAME%","NoRepair",0x10001,01,00,00,00
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%PROG_NAME%","UninstallString",0,"rundll32.exe advpack.dll,LaunchINFSection %MAIN_INF%,Uninstall"

;Uninstall section that will be launched
[Uninstall]
BeginPrompt         =BeginUnInsPrompt
RunPreSetupCommands =Close.Program:1 ;<- The ":1" Flag Hides the taskkill.exe CMD window (does not need to be in section name)
DelFiles            =Program.Files,PNF.File
DelDirs             =Program.Dirs
ProfileItems        =Program.DelShortcut
DelReg              =Uninstall.AddDelReg
UpdateInis          =sysoc.Edit
EndPrompt           =EndUnInsPrompt
RunPostSetupCommands=Dir.Delete,Launch.Website
Cleanup             =1

;Closes program executable if running before uninstall
[Close.Program]
TASKKILL /F /IM Program.exe
;for XP Home compatibility
TSKILL Program ;<- tskill fails if you add the file extention (bad example: tskill program.exe)

;Program files to delete, will not work without a DestinationDir
[Program.Files]
Program.exe
Program.ini
ShellExt.dll,,,1 ;The ",1" flag is used if the file is in use, so entries will be added to the registry to delete it on next boot.

;Obsolote PNF file created during Windows Setup (Requires a entry in DestinationDirs example PNF.File=17)
[PNF.File]
addon.PNF

;Deletes Start Menu shortcut using profileitems the secret is the ",0x00000002" flag (also used is 3 and 4)
[Program.DelShortcut]
Name  =%PROG_NAME%,0x00000002
SubDir=%SUB_DIR%

;Removes addon entry from sysoc.inf so Cleanup=1 does not break Add/Rem Windows Components
[sysoc.Edit]
%17%\sysoc.inf,Componets,Whatever Is Under [Optional Components]=*

;Deletes Program Folder (will only delete empty folder)
[Program.Dirs]
%16422%/%PROG_DIR%

;Deletes Folders and files in them
[Dir.Delete]
rundll32.exe advpack.dll,DelNodeRunDLL32 %16422%\%PROG_DIR%,<flag>

[Launch.Website]
rundll32.exe url.dll,FileProtocolHandler http://www.ryanvm.net/msfn/

;Uninstall Prompt
[BeginUnInsPrompt]
Title     =%PROG_NAME% Uninstaller
Prompt    =Are you sure you want to remove %PROG_NAME% from your computer?
ButtonType=YESNO ;<- YESNO or OKCANC

;Optional End Prompt (not really nessesary just tells you the uninstall was a success.)
[EndUnInsPrompt]
Prompt=%PROG_NAME% was successfully removed from your computer.

;Here you tell the INF what all the variables are (Example: lets say %VAR% so under strings you add VAR=VARIABLE)
[Strings]
MAIN_INF ="Program.inf"
PROG_DIR ="Program Folder"
PROG_NAME="Program Name"
SUB_DIR  ="Start Menu Sub"
For more info like ProfileItems Uninstall and other inf flags try reading a couple of good INF Tutorials, all this is in there:
INF DOC
OSR PDF GUIDE
MSDN PDF GUIDE

How to use "Add Remove Windows Components" to Install/Uninstal :)

If you want you can also use "Add/Remove Windows Components" to add a Install/Uninstall entry

In your addons entry*.ini ommit HIDE from the [sysoc] edit, this shows your Optional Component's addon name in add/rem comp
[sysoc]
Optional Component=ocgen.dll,OcEntry,AddOn.inf,HIDE,7
Add a "Uninstall=" section to your Optional Component. Optional, you can add IconIndex= followed by the number of your prefered Icon (if anybody knows the DLL that has these icons please let me know, I don't think its moricons.dll)

Code: Select all

[Optional Components]
Any Name

[Any Name]
OptionDesc  ="Program Name" ;this will display your program's name in add/rem comp
Tip         ="Program Info Tip." ;Info tip in add/rem comp
Modes       =0,1,2,3
AddReg      =AddOn.AddReg
CopyFiles   =AddOn.Files
ProfileItems=AddOn.Shortcut
Uninstall   =Uninstall.Section  ;<- ADD THIS
IconIndex   =20
Now for the Uninstall section:
Now you wont be able to use some of the INF uninstall tricks like RunPost/PreSetupCommands, Begin/EndPrompt. They only work with advpack.dll.
Its pretty straight forward, same as Uninstall above but a little more simple

Code: Select all

[Uninstall.Section]
DelFiles    =AddOn.Files
DelDirs     =AddOn.Dirs
ProfileItems=AddOn.DelShortcut
Etc. Etc.
Tip: Do NOT! use Cleanup=1 reason is you can later re-install the program using add remove comp
Last edited by ricktendo64 on Mon Jul 30, 2007 12:28 pm, edited 14 times in total.

User avatar
Mrs Peel
The Dominatrix Recoded
Posts: 1344
Joined: Tue Jan 17, 2006 2:02 am
Location: Aotearoa
Contact:

Post by Mrs Peel » Fri Jun 15, 2007 9:36 am

Oh I have so SO needed a tutorial for this for over a year! This is the main area where I became UNstuck (and thus despondent) with updating all my addon packs - which I had intended to rewrite them all with uninstallers.

Since this might be the very thing to UNstick me I shall thank you by honouring your generous efforts with a forum sticky ;)

Cheers m'dears!

User avatar
Mrs Peel
The Dominatrix Recoded
Posts: 1344
Joined: Tue Jan 17, 2006 2:02 am
Location: Aotearoa
Contact:

Post by Mrs Peel » Fri Jun 15, 2007 9:43 am

PS: Oh I see you have linked to the INF tutorials that I PDFed for us last year. Yikes I wasn't even able to get my head around those at the time, so I hope this tutorial of yours helps me make better sense of them than I did back then!

I expect I will be back here again to ask you a zillion blonde questions about this so you better brace yourself and wish me luck.... lots and LOTS of luck.... LOL!

User avatar
ENU_user
Posts: 1253
Joined: Wed Jan 25, 2006 1:42 pm

Post by ENU_user » Fri Jun 15, 2007 10:59 am

another good point to add to all inf tutorials and inf templates is that you should use search and replace

if the template is suited for search&replace you got a good template anyways

set all the program location shortcuts and have naming parts more understandable to you, and in the inf var naming by
using the "replace all" in your editor find the word "Program" and replace with the word "winrar" no quotes.

now you got a template with "winrar" vars as the program location and shortcuts, install and uninstall prompt sections .etc

add to this template the rest of sections and you got a great template for you and for anyone to work with.

with the new changes to the inf, easily find the sections you need to overview
save and go test !

User avatar
ricktendo64
Posts: 3213
Joined: Mon May 22, 2006 12:27 am
Location: Honduras

Post by ricktendo64 » Fri Jun 15, 2007 12:14 pm

Thats why I put it up, is for other INF AddOn makers who make their own uninstall entries they can try out the cool Prompt and App Kill tricks, so... I dont think I need to explain a whole lot, you guys already know most of it :P

The only thing difrent about this INF uninstaller that I wanted to get accross to you guys is

Code: Select all

BeginPrompt= ;Uninstall Prompt/Question?
RunPreSetupCommands= ;Kills Running Program (Optional)
ProfileItems= ;Deletes Program Shortcuts
EndPrompt= ;Uninstall End Success
I got another VERY Important tip for you guys

Code: Select all

Cleanup=1
Do NOT use this... It breaks Add Remove Windows Components

EDIT: Another cool tip is:
If you have a file that is stubborn and wont get deleted because its in use (Example: Shell Extention DLL's) use this flag do get it deleted on reboot

Code: Select all

DelFiles=ShellExt

[ShellExt]
ShellExt.dll,,,1
Dont worry the ,,,1 flag will NOT affect CopyFiles so its safe for you to use (However FGCBA will give you an error... Ignore it)

rootfile
Posts: 66
Joined: Mon Jul 03, 2006 11:46 am

Wow, a great guide

Post by rootfile » Fri Jun 15, 2007 4:07 pm

But what would be the code for deleting a shortcut in the startup folder. Or is that possible without deleting other shortcuts in the folder?

User avatar
ricktendo64
Posts: 3213
Joined: Mon May 22, 2006 12:27 am
Location: Honduras

Post by ricktendo64 » Fri Jun 15, 2007 4:36 pm

0x00000002 or will not delete the subdir if it has any other shortcuts. It will only remove it if empty.

Now the startup folder is a tough one, if there is only one shortcut present it might delete the folder (try 0x00000003)

User avatar
RogueSpear
Posts: 1155
Joined: Tue Nov 23, 2004 9:50 pm
Location: Buffalo, NY

Post by RogueSpear » Fri Jun 15, 2007 6:55 pm

Awesome post Rick :D

This will definately be put to good use.

rootfile
Posts: 66
Joined: Mon Jul 03, 2006 11:46 am

RE: Startup Folder

Post by rootfile » Fri Jun 15, 2007 7:13 pm

Now the startup folder is a tough one, if there is only one shortcut present it might delete the folder (try 0x00000003)
OK. Thanks.

As an alternative, could I use an ordinary .CMD or Autoscript compiled file to call the PROG_NAME%","UninstallString",0,"rundll32.exe advpack.dll,LaunchINFSection %MAIN_INF%,Uninstall"
command, eg.

Code: Select all

PROG_NAME%","UninstallString",0,"myautoitscript.exe"

That way you could issue the uninstall command AFTER you use the batch or autoit script to delete the starup shortcut.

User avatar
ricktendo64
Posts: 3213
Joined: Mon May 22, 2006 12:27 am
Location: Honduras

Post by ricktendo64 » Fri Jun 15, 2007 7:34 pm

Or you could "AddReg" to "RunOnce" a rundll32.exe advpack.dll,LaunchINFSection to lauch a custom section to do DelFiles or RunPostSetupCommads... Look at my Flashget or USDownloader addons for some idea.

For ProfileItems Uninstall you can look and see how Microsoft does it... You can find an example in ACCESSOR.IN_ in your XP CD

BTW here is an example addon of the shell extention dll that was givin me hell so I used the ,,,1 flag on it to delete the file if in use http://www.wincert.net/forum/index.php?showtopic=1177

yumeyao
Moderator
Posts: 1718
Joined: Sun Aug 27, 2006 9:24 pm
Location: Taiyuan, Shanxi, PR China

Post by yumeyao » Fri Jun 15, 2007 8:02 pm

remove a dir. is there any parament to switch removing/remaining a dir that is not empty?
Image
My work list(Hosted by dumpydooby)

User avatar
ricktendo64
Posts: 3213
Joined: Mon May 22, 2006 12:27 am
Location: Honduras

Post by ricktendo64 » Fri Jun 15, 2007 9:37 pm

Yes... You can do it using AddReg just give me the location and folder name before & after and I can maybe put an example together.
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\ Example,,,%16422%
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\ Example,FolderNameA,,"FolderNameB"
You can even set atributes and rename files and folders ;)

User avatar
Preputium64
Posts: 104
Joined: Fri Nov 10, 2006 1:22 pm
Contact:

Post by Preputium64 » Mon Jul 09, 2007 11:46 am

Hi I made v8.1.0178.00 Türkçe (true addon) but I need help about uninstaler... Please inspect this addon and please help me for uninstall part?

Preputium64_WLM_Addon_v8.1.0178.00.cab

Md5: B8C8C7E281D986FC1EC8B39AE25AD63E
thanx...

P.S: my english not enought. Sorry my english...:D

P.S2: this is a turkish addon

User avatar
ricktendo64
Posts: 3213
Joined: Mon May 22, 2006 12:27 am
Location: Honduras

Post by ricktendo64 » Mon Jul 09, 2007 12:29 pm

Please in the future post the INF only... BTW I don't see any INF Uninstall section and I don't really have time right now to go thru the INF and make you one.
IMO this addon is best made using the silent switch method, MSI addons add allot of funny stuff in the registry that might break the upgrade of the program.

But the addon is nicely done, good job so far

User avatar
Preputium64
Posts: 104
Joined: Fri Nov 10, 2006 1:22 pm
Contact:

Post by Preputium64 » Mon Jul 09, 2007 12:47 pm

Please in the future post the INF only...
sorry i did not know
BTW I don't see any INF Uninstall section and I don't really have time right now to go thru the INF and make you one
you don't see because i delete because it isn't work.
make I. I wish... :D
IMO this addon is best made using the silent switch method, MSI addons add allot of funny stuff in the registry that might break the upgrade of the program.
I don't prefer msi pack cause this need svcpack.inf or runonceex.cmd...
But the addon is nicely done, good job so far
thank you...

User avatar
ricktendo64
Posts: 3213
Joined: Mon May 22, 2006 12:27 am
Location: Honduras

Post by ricktendo64 » Mon Jul 09, 2007 2:01 pm

Shark has a editable SVCPACK compatible addon. He also has instructions on how to edit the msi with orca to make it svcpack compatible http://www.msfn.org/board/index.php?showtopic=65292

User avatar
ricktendo64
Posts: 3213
Joined: Mon May 22, 2006 12:27 am
Location: Honduras

Post by ricktendo64 » Fri Jul 20, 2007 10:14 am

Updated... Re-added Cleanup=1 and how to stop it from breaking add/rem components (UpdateInis trick by Mitsuko Aninikkou)
Also added how Lauch Website upon Uninstall using RunPostSetupCommands and PNF deletion

Added how to use "Add/Remove Windows Components" to uninstall/reinstall

User avatar
Mrs Peel
The Dominatrix Recoded
Posts: 1344
Joined: Tue Jan 17, 2006 2:02 am
Location: Aotearoa
Contact:

Post by Mrs Peel » Fri Jul 20, 2007 10:38 am

Cool bananas :)

That UpdateInis trick contributed by Mitsuko has been an awesome addition to the knowledge base, so we can finally do a proper clean install. YAYYY!

Good on you for all the hard work you are doing to keep this updated and get all these new inf ideas added to the collection as we discover them :)

rootfile
Posts: 66
Joined: Mon Jul 03, 2006 11:46 am

RE: if anybody knows the DLL that has these icons

Post by rootfile » Fri Jul 20, 2007 2:12 pm

@ricktendo64 "if anybody knows ..."

MOREICONS.DLL are the XP versions of the old Windows v3.1 icons.

Shell32.dll contains most of the modern Windows XP system icons. But shell32.dll behaves differently from most icon libraries. For instance, in the addon I made for SIW, the information icon on shell32.dll is actually 144 when you open it up with an icon editor. But I had to use shell32.dll,221 because shell32.dll doesn't call the icons in the same sequence as they are displayed in icon editors for some reason. Also note, Xpize and other shell tweaking apps often change icons in the shell32.dll library.

User avatar
ricktendo64
Posts: 3213
Joined: Mon May 22, 2006 12:27 am
Location: Honduras

Post by ricktendo64 » Fri Jul 20, 2007 2:26 pm

I know when you are using IconIndex the number shown is useless, you have to start counting from 00 and painstakinly count one by one and that is the number you use for IconIndex. I just don't know what DLL file to look in to start counting.
I think you can use other EXE and DLL files as Icons for "Add/Rem Components" here is an example how

Code: Select all

IconIndex    = *, ..\xpsp1res.dll, 200
BTW gonna update the INF Uninstall to show how to use RunPostSetupCommands and advpack.dll to delete Directories even if they have files in them

Code: Select all

RunPostSetupCommands=Dir.Delete

[Dir.Delete]
rundll32.exe advpack.dll,DelNodeRunDLL32 %16422%\%DIR_PATH%
EDIT: You can also create SubDirs/Parent to put your addons in so as not to clutter up Add/Rem Components creating a Parent= with a name like Ricks AddOns and in that you can add the sub directories of your addons example Sidebar, DiscCopy etc... but you are going to have to look in ACCESSOR.IN_ and figure it out for yourselvs, the tutorial would be too long then

rootfile
Posts: 66
Joined: Mon Jul 03, 2006 11:46 am

Post by rootfile » Fri Jul 20, 2007 2:58 pm

ricktendo64, you're right: most of the icon libararies, including moreicons.dll count sequentially, starting with zero. But my experience is that shell32.dll--which contains most of the windows icons, like help, information, folders, drives and the like--doesn't behave that way, perhaps because it has so many icons. I use an old program called Desktop Architect to find the proper icons numbers in shell32.dll.

User avatar
code65536
Posts: 735
Joined: Wed Mar 14, 2007 2:58 pm
Location: .us
Contact:

Post by code65536 » Sat Jul 21, 2007 6:41 pm

ricktendo64 wrote:[Dir.Delete]
rundll32.exe advpack.dll,DelNodeRunDLL32 %16422%\%DIR_PATH%[/code]
A few details you left out:

1/ This will not delete files/dirs that are in use (e.g., if you're uninstalling a shell extension that's still loaded in explorer.exe and want to delete both the file and its containing directory). (And unfortunately, there isn't a good way to do that without calling up an external app that calls MoveFileEx; setting the registry entries in the INF for a pending file rename/delete risks clobbering existing pending ops)

2/ There are flags that you can optionally use. For example,

Code: Select all

rundll32 advpack.dll,DelNodeRunDLL32 PathName,4
From Microsoft's comments in advpub:

Code: Select all

1  // delete the directory only if it's empty
2  // don't delete any sub-dirs; delete only the files
4  // don't delete the dir itself
8  // delete UNC [network] paths
Sum up the numbers you want and place them after a comma following the name. Not all the flags are all that useful except for maybe 4--if you want to kill *.* inside a directory without also clobbering the directory, or 1 if you want to kill the directory, but not if there are custom files that users have put in it (assuming you've deleted the files that you put in via DelFiles).

3/ Can also be used to delete files, though DelFiles should be used instead for that.

User avatar
ricktendo64
Posts: 3213
Joined: Mon May 22, 2006 12:27 am
Location: Honduras

Post by ricktendo64 » Sat Jul 21, 2007 10:34 pm

Nice... Thanks for the flags, very good info.

Post Reply