Guide Index Quick Links

The DelFiles Directive

Created on March 10, 2023

  1. Reusing an Existing Copy Section
  2. New Sections for File Deletion

With existing knowledge of writing INF files on hand, this next directive, DelFiles, should be much simpler to grasp. There's a lot less parameters to it, so in this page, we'll also cover creating a second entry point for the same INF we've been working with.

Reusing an Existing Copy Section

In the existing file, we'll create a new section called Uninstall. This section will be used for deleting anything we have added using the DefaultInstall section. Because the CopyFiles and DelFiles directives use a very similar syntax, it is possible to reuse a CopyFiles section for deleting files, and vice versa.


You won't have to add anything else from there, or even change the flags for that matter. DelFiles uses only one flag set at 1, which is used for queueing a file for deletion on the next restart in case said file is in use by the operating system or another program.

This may conflict with the same flag used in CopyFiles for warning the user if they skip a file, but its effect should be minor if both CopyFiles and DelFiles share a section. You can determine if the flag is set simply by checking if the flag parameter has an odd number.

Before executing this INF's section, it would be worth creating a shortcut to be able to do so easily. For Windows 95's 16-bit setup engine, create a new shortcut which executes the following command:

rundll.exe setupx.dll,InstallHinfSection Uninstall 132 C:\WINDOWS\Desktop\test.inf

Windows NT uses SETUPAPI.DLL, a 32-bit setup engine, which does not have the various 16-bit constraints in place like an 8.3 character filename limit. This setup engine can also be used in Windows 9x; the DLL is most often supplied by Internet Explorer. Using this DLL, the command would instead be:

rundll32.exe setupapi.dll,InstallHinfSection Uninstall 132 C:\WINDOWS\Desktop\test.inf

Uninstall would be the name of the section you are calling, 132 is used for the reboot flag parameter, and C:\WINDOWS\Desktop\test.inf is the path to your INF you're using. It seems that RUNDLL.EXE is insistent on you specifying an absolute path to the INF, as I didn't get a relative path to work. Oh well.

The reboot flag used here will prompt the user to restart the computer if some files the INF is trying to manage are in use. 128, the eighth bit, is added to this parameter to indicate this is a user-supplied INF file; it has been reported that INFs without this bit set may cause undesired results related to rebooting.

Give the shortcut a name, such as Uninstall. You can then execute the shortcut by double clicking it. Both files should disappear. While we could stop here, I want to exercise this directive a bit further by creating two new sections specifically for file deletion.

New Sections for File Deletion

DefaultDestDir	= 10
Files.Copy	= 10,NEWDEST\FILES
First.Del	= 10,NEWDEST\FILES
Second.Del	= 10,NEWDEST\FILES




Let's break it down: first, two new lines have been added to the DestinationDirs section. They point to the same path; for all non-default destinations, you have to define every section's destination explicitly.

In the Uninstall section we defined, directives can contain one or more sections separated by commas. Below that are two sections specifically for deleting our files. If you do not want all files that were copied over to be deleted when something is to be uninstalled, it's important to maintain multiple lists of files.

Reinstate the files, then with the modifications to the INF in place, execute the uninstallation. If the files in the destination are gone again after having been recopied, you're all set here.

Here is the complete INF file so far:


1 = "Source Files",,0,FILES

test.txt	= 1
other.txt	= 1

DefaultDestDir	= 10
Files.Copy	= 10,NEWDEST\FILES
First.Del	= 10,NEWDEST\FILES
Second.Del	= 10,NEWDEST\FILES






Don't forget to end your INF with a bit of whitespace.


flatrute - March 17, 2023 at 10:29 AM

There are a few specification documents on the compression algorithm which in theory would let me be able to build a replacement that scales better on modern systems but I am so busy in college at the time I am typing this...

1 comment on this page

Sort: Ascending | Descending

Leave a Comment

Name: (required)

Website: (optional)

Maximum comment length is 1000 characters.
First time? Read the guidelines

Enter the text shown in the image: