Uninstall pass-through
Previous Top Next

Using -uninstall pass-through to perform additional cleanup steps

By processing the -uninstall command line yourself, your program can perform additional uninstall cleanup elements before Thinstall performs the final uninstall.

The user can request your program uninstall itself in one of 3 ways:
1. Control panel Add/Remove Programs: The registry contains a key that instructs the control panel to run your EXE with the command line parameter "-uninstall"
2. StartMenu Uninstall shortcut: The Start Menu shortcut contains a link to your EXE with the command line parameter "-uninstall".
3. The command line. The user can manually request uninstall by running your program from the command with the parameter "-uninstall".

In all three cases your EXE is executed with the "-uninstall" parameter. Normally Thinstall will check to see if this parameter is present before running your program. If it is, it invokes the uninstall procedures and does not run your program. If your program needs to clean up additional items, for example remove registry keys or delete specific files, you can instruct Thinstall to ignore this command line parameter.
This option can be set using the dialog box located at Link -> Install Options -> Uninstall:
clip0184

When this option is set, Thinstall will not process the "-uninstall" command line parameter. Instead, your program is loaded and run normally. You should detect this command line argument manually, for example in C++:

void main(int argc, char **argv)
{
if (argc==2 && strcmp(argv[1], "-uninstall")
{
// make sure user really wants to uninstall, and this was not an accidental selection
if (MessageBox(0, "Are you sure you want to uninstall?", "Uninstalling Ubersoftware", MB_YESNO)== IDNO)
ExitProcess(0); // if accidental uninstall, quit without setting environment variable


// do additional uninstall steps you need to do

do_additional_uninstall_stuff();

// tell Thinstall to complete uninstall when progam quits by setting this environment variable

SetEnvironmentVariable("TS_UNINSTALL", "1");
ExitProcess(0);
}

// normal_program execution here....
}


Once you detect the "-uninstall" command line parameter you should do 4 things:
1. Ask the user if they really want to uninstall. They might have selected the uninstall icon by accident! If the answer is no, exit the program immediately. For example:
2. If the answer is yes, cleanup whatever you need to cleanup
3. Set the Environment variable "TS_UNINSTALL" to "1". This instructs Thinstall to finish the uninstall process when your program quits.
4. Call ExitProcess or exit your program through the means available in your programming language.

After your program quits, Thinstall will check for TS_UNINSTALL. If it is set, it will perform the following actions:
1. Delete StartMenu and Desktop shortcuts it created during install
2. Delete files it extracted during install
3. Delete cache and temporary files it created
4. Remote uninstall information from the registry
5. Delete the main Thinstall EXE
6. Delete directories it created during install