com.denova.JExpress.Installer
Class CustomUninstaller

java.lang.Object
  |
  +--com.denova.JExpress.Installer.CustomUninstaller
All Implemented Interfaces:
InstallPropertyNames, com.denova.JExpress.JExpressConstants, WindowsConstants

public class CustomUninstaller
extends java.lang.Object
implements com.denova.JExpress.JExpressConstants, WindowsConstants, InstallPropertyNames

Add commands to the uninstaller to remove files and directories that your custom installer classes or your app adds that you want removed when your app is deleted.

Author:
DeNova Copyright © 1997-2008 DeNova All rights reserved worldwide. Last modified: 15 Apr 2008

Field Summary
 
Fields inherited from interface com.denova.JExpress.JExpressConstants
AdvancedEdition, AppDirVariable, AppNameVariable, AutoRunInfFilename, BasedirPlaceHolder, BasePathArgument, BatchFileExtension, BuildDirArgumentNew, BuildDirArgumentOld, BuildPackage, ClassFileExtension, Classpath, ConfigDirectory, ControlUrlPatchableString, CopyFileCommand, Copyright, CopyrightSuffix, CreatedFilename, CrossPlatformExecName, CrossPlatformName, CurrentProjectFilename, CustomClassesCommand, CustomInstallClassesDir, CustomLoaderPrefix, CustomLookAndFeel, CustomUninstallClassesDir, CustomUninstallDir, CustomUpdateClassesDir, DefaultBrowser, DefaultJpegInstallerImage, DefaultJpegUpdaterImage, DefaultLookAndFeel, DefaultOptionsFilename, DefaultProjectFilename, DefaultTempDirectory, DefaultThemePack, DefaultUninstallerIcon, DefaultUpdaterIcon, DefaultUseTooltips, DelDirIfEmptyCommand, DelFileCommand, DelManifestCommand, DelTreeCommand, EditionEnds, EditionStarts, ExampleProject, ExitIconName, ExitLabel, ExtraParametersFlag, FilesList, GzipFileExtension, GzipListFilename, HtmlFileExtension, InstallerDirectory, InstallerMainClass, InstallerPackage, InstallersSubdir, InstallerUrlPatchableString, InstallOptionsFilename, JarFileExtension, JarFileSuffix, JavaAppArguments, JavaAppExecutable, JavaAppProgramName, JavaAppPropertiesAltDir, JavaAppPropertiesFilename, JavaAppStandardArguments, JavaAppStartDir, JavaDirectory, JavaHomeVariable, JExpressAdvancedApp, JExpressApp, JExpressCustomClassName, JExpressInstallerClassName, JExpressJpegLogoFilename, JExpressUninstallerClassName, JExpressUpdaterClassName, JExpressWizardApp, KdePngIconExtension, KdeXpmIconExtension, KeystoreDbFilename, LoaderDirectory, LoaderIsInPackage, LoaderPackage, LoaderPrefixControl, LocalBuildProperty, MacInstallerCommandFilename, MacOsXIconExtension, MetalLookAndFeel, ModernThemePack, NativeInstallerLog, NativeLookAndFeel, NativePropertiesFilename, NativeStartDirFilename, OverwriteFileCommand, PlatformOptionsFilename, PlatformsDirectory, PlatformsParentDir, PlatformVariable, ProgFilesDirVariable, ProjectFileSuffix, ProjectsSubdir, PropertiesFlag, RawLoaderFilename, RecentJexProjects, RegistrationFilename, RenFileCommand, SearchEverywhereForJvm, SearchIconName, SearchNowhereForJvm, SearchPathForJvm, SelectedNativePlatformsNoJvm, SelectedNativePlatformsWithJvm, SilentInstallFlag, SingleFileGroup, SkinLFPackage, SkinPLAF, StandaloneDirectory, StandalonePureJavaPrefix, StandardJvmExtraParameters, StandardUserClasspath, StartWinAppFilename, SystemChangesFilename, TellUserHowToStart, TempDirectory, ThemePackArgument, ThemePackFilename, TitleCommand, UninstallerDirectory, UninstallerPackage, UninstallerSubdir, UninstallInstructions, UpdateManifestDirectory, UpdateManifestFilename, UpdateMenuPrefix, UpdaterDirectory, UpdaterPackage, UpdateScriptName, UpdatesDirectory, UserHomeVariable, UserInstallerDirectory, UserInterface, UserJExpressDirectory, UserUpdatePropertiesFilename, VersionArgument, VersionFilename, VersionVariable, WebDirectory, WebPagesDirectory, WindowsDirectory, WindowsDirVariable, WindowsIconExtension, WizardEdition, ZipFileExtension, ZipSkipPatchableString
 
Fields inherited from interface com.denova.runtime.WindowsConstants
AddRegistryEntry, AllUsers, AppendRegistryEntry, BinaryType, CurrentUser, DeleteRegistryEntry, DesktopSpecFilename, DirectoryResultsFilename, DWordType, EnumKeyRegistryEntry, EnumValueRegistryEntry, EnvOutputFilename, ExistsRegistryEntry, FreeDiskSpaceResultsFilename, InvokerFilename, MenuSpecFilename, NtResultsFilename, PathOutputFilename, PrependRegistryEntry, QueryRegistryEntry, RegistryResultsFilename, RegistrySpecFilename, ReplaceRegistryEntry, ShortnameFilename, StringType, WindowsAddDesktop, WindowsAddProgramsMenu, WindowsAddStartupMenu, WindowsAppDataCommand, WindowsCmdLogFilename, WindowsCommandsFilename, WindowsDelDesktop, WindowsDelProgramsMenu, WindowsDelStartupMenu, WindowsDesktopCommand, WindowsDesktopDirCommand, WindowsDirCommand, WindowsEnvVariableCommand, WindowsFreeDiskSpaceCommand, WindowsMenusDirCommand, WindowsNtCommand, WindowsPathCommand, WindowsPathShortenerCommand, WindowsProgramManagerDirCommand, WindowsProgramsMenuCommand, WindowsRegistryEditorCommand, WindowsStartupMenuCommand, WindowsStartupMenusDirCommand
 
Fields inherited from interface com.denova.JExpress.Installer.InstallPropertyNames
AdminMenus, ApplicationDirectory, ApplicationDirectoryTarget, Author, AutoupdateEveryStartup, AutoupdateNever, AutoupdateOnDemand, BasePath, CheckGuiRunningCommand, ConfigureWinRegistry, ControlUrl, CreatedMenuDirs, CustomAfterDirectoryWizardPanelClass, CustomAfterFilesInstalledWizardPanelClass, CustomAfterInstallWizardPanelClass, CustomAfterLicenseWizardPanelClass, CustomAfterMenusWizardPanelClass, CustomAfterMultipleInstallsWizardPanelClass, CustomAfterReadMeWizardPanelClass, CustomAfterWelcomeWizardPanelClass, CustomBeforeInstallWizardPanelClass, DefaultApplicationDirectory, DesktopShortcuts, DownloadUrl, ExtraParameters, FileGroupsFolders, FileGroupsTypes, InstallButtonsPosition, InstallerDefaultLanguage, InstallerExecutable, InstallerExtraFiles, InstallImageFilename, InstallImagePosition, InstallJvmParameters, InstallLicenseFilename, InstallPasswordDigest, InstallReadmeFilename, InstallSuccessful, InstallType, InstallUserClasspath, IsServlet, JvmClasspathSwitch, JvmCommandName, JvmExtraParameters, JvmHomeDir, JvmMaxVersion, JvmMinVersion, JvmName, JvmRequiredVersion, JvmSelfExtractor, JvmVersion, LoaderClasspath, LoaderJavaCommand, MainClassname, MenuArguments, MenuAssociatedInstallType, MenuCommandLineArguments, MenuExecutableFile, MenuIconName, MenuLongName, MenusAttributeName, MenuShortName, MenuUseJavaCommandPrefix, MenuUseJavaConsole, MenuUseSwing, MultipleComponents, MultipleFileGroups, MultipleInstallTypes, NativeJvmHomeDir, NativeJvmInstalled, NativeJvmInstalledInTemp, NextInstallTypes, OldApplicationDirectory, PackageCopyright, PackageCreated, PackageName, PackageVersion, PredefinedJvmInstallDir, RelativeFileMap, SafePackageName, SearchForJvm, SelectedInstallTypes, SilentConfigFilename, SilentInstall, SingleInstallType, StartDirectory, StartGuiCommand, StartupScripts, Submenu, SystemSecurityPolicyFilename, TextFileExtensions, TotalBytesNeeded, UninstallerArgs, UninstallerPathname, UnzipExecutable, UserSecurityPolicyFilename, WebSite
 
Constructor Summary
CustomUninstaller()
          CustomUninstaller lets you customize the uninstaller for your app.
 
Method Summary
 boolean addSubkeyEntry(java.lang.String keyName, java.lang.String subKeyName, java.lang.String subKeyData)
          Adds the subKeyName and its data to the registry if and only if it doesn't already exist.
 boolean append(java.lang.String applicationDirectory)
          Append the commands to the uninstaller command file(s).
 boolean copyFileCommand(java.lang.String fromFilename, java.lang.String toFilename)
          Copy file, if the toFilename does not already exist.
 boolean deleteDirIfEmpty(java.lang.String directoryName)
          Delete the directory if it's empty.
 boolean deleteDirTree(java.lang.String directoryName)
          Delete all the files in directory tree, including the directoryName
 boolean deleteFile(java.lang.String filename)
          Delete the file.
 boolean deleteManifest(java.lang.String applicationDirectory)
          Delete all the files in the manifest.
 boolean deleteSubkeyEntry(java.lang.String keyName, java.lang.String subKeyName)
          Delete subKeyName from registry.
 boolean deleteWindowsDesktopIcon(java.lang.String submenu, java.lang.String itemName, java.lang.String user)
          Delete icon from the desktop on Windows.
 boolean deleteWindowsMenuItem(java.lang.String submenu, java.lang.String itemName, java.lang.String user)
          Delete menu item from Start | Programs on Windows.
 boolean overwriteFileCommand(java.lang.String fromFilename, java.lang.String toFilename)
          Copy the fromFilename to the toFilename, even if the toFilename existed.
 boolean prepend(java.lang.String applicationDirectory)
          Add the commands to the beginning of the uninstaller command file(s).
 boolean renameFile(java.lang.String fromFilename, java.lang.String toFilename)
          Rename file, if the toFilename does not already exist.
 boolean replaceDataEntry(java.lang.String keyName, java.lang.String subKeyName, java.lang.String subKeyData)
          Replaces the data for the subKeyName.
 boolean runThirdPartyApp(java.lang.String exec, java.lang.String[] args)
          Run a third party program.
 boolean save(java.lang.String applicationDirectory, java.lang.String productName)
          Save the commands for the uninstaller command file(s).
 boolean setCustomClasses(java.lang.String classes)
          Set the custom classes to run before uninstalling.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomUninstaller

public CustomUninstaller()
CustomUninstaller lets you customize the uninstaller for your app.

Method Detail

append

public boolean append(java.lang.String applicationDirectory)
Append the commands to the uninstaller command file(s). Clears all stored commands after appending the known commands.

Parameters:
applicationDirectory - directory where your app is installed.
Returns:
boolean true if successful appending commands to the uninstaller.

prepend

public boolean prepend(java.lang.String applicationDirectory)
Add the commands to the beginning of the uninstaller command file(s). Clears all stored commands after prepending the known commands.

Parameters:
applicationDirectory - directory where your app is installed.
Returns:
boolean true if successful prepending commands to the uninstaller.

save

public boolean save(java.lang.String applicationDirectory,
                    java.lang.String productName)
Save the commands for the uninstaller command file(s). Creates new uninstall command file(s) overwriting any existing file(s). Clears all stored commands after saving all known commands.

Parameters:
applicationDirectory - directory where your app is installed.
productName - name of product to be uninstalled.
Returns:
boolean true if successful saving commands to the uninstaller.

setCustomClasses

public boolean setCustomClasses(java.lang.String classes)
Set the custom classes to run before uninstalling. The customClasses replaces the existing list of classes. Pass an empty string to clear the custom classes.

Parameters:
classes - custom classnames, including package name, separated by a space.
Returns:
boolean true if successful.

deleteManifest

public boolean deleteManifest(java.lang.String applicationDirectory)
Delete all the files in the manifest.

Parameters:
applicationDirectory - directory where your app is installed.
Returns:
boolean true if successful.

deleteDirTree

public boolean deleteDirTree(java.lang.String directoryName)
Delete all the files in directory tree, including the directoryName

Parameters:
directoryName - name of the directory to start deleting files.
Returns:
boolean true if successful.

deleteDirIfEmpty

public boolean deleteDirIfEmpty(java.lang.String directoryName)
Delete the directory if it's empty.

Parameters:
directoryName - name of the directory, including full path, to delete.
Returns:
boolean true if successful.

deleteFile

public boolean deleteFile(java.lang.String filename)
Delete the file.

Parameters:
filename - name of file, including full path, to delete.
Returns:
boolean true if successful.

renameFile

public boolean renameFile(java.lang.String fromFilename,
                          java.lang.String toFilename)
Rename file, if the toFilename does not already exist.

Parameters:
fromFilename - the original name of the file, including full path.
toFilename - the new name of the file, including full path.
Returns:
boolean true if successful.

copyFileCommand

public boolean copyFileCommand(java.lang.String fromFilename,
                               java.lang.String toFilename)
Copy file, if the toFilename does not already exist. The fromFilename still exists after the copy.

Parameters:
fromFilename - the original name of the file, including full path.
toFilename - the new name of the file, including full path.
Returns:
boolean true if successful.

overwriteFileCommand

public boolean overwriteFileCommand(java.lang.String fromFilename,
                                    java.lang.String toFilename)
Copy the fromFilename to the toFilename, even if the toFilename existed. The fromFilename is effectively renamed to the toFilename regardless if the toFilename exists or not.

Parameters:
fromFilename - the original name of the file, including full path.
toFilename - the new name of the file, including full path.
Returns:
boolean true if successful.

addSubkeyEntry

public boolean addSubkeyEntry(java.lang.String keyName,
                              java.lang.String subKeyName,
                              java.lang.String subKeyData)
Adds the subKeyName and its data to the registry if and only if it doesn't already exist. The keyName must already exist.

Parameters:
keyName - the key (e.g., HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows).
subKeyName - the last element of the key.
subKeyData - the string data, if any, for the subKeyName.
Returns:
true if successful.

replaceDataEntry

public boolean replaceDataEntry(java.lang.String keyName,
                                java.lang.String subKeyName,
                                java.lang.String subKeyData)
Replaces the data for the subKeyName. If subKeyName does not exist, then it adds the subKeyName and its associated subKeyData. The keyName must already exist.

Parameters:
keyName - the key (e.g., HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows).
subKeyName - the last element of the key.
subKeyData - the string data, if any, for the subKeyName.
Returns:
true if successful.

deleteSubkeyEntry

public boolean deleteSubkeyEntry(java.lang.String keyName,
                                 java.lang.String subKeyName)
Delete subKeyName from registry. The keyName must already exist.

Parameters:
keyName - the key (e.g., HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows).
subKeyName - the last element of the key.
Returns:
true if successful.

deleteWindowsMenuItem

public boolean deleteWindowsMenuItem(java.lang.String submenu,
                                     java.lang.String itemName,
                                     java.lang.String user)
Delete menu item from Start | Programs on Windows.

Parameters:
submenu - the submenu.
itemName - the menu item.
user - if currentUser, then delete menu from the HKEY_CURRENT_USER key; if allUsers, then try to delete from the HKEY_LOCAL_MACHINE key, but if that fails, then delete from the HKEY_CURRENT_USER key.
Returns:
true if successful.

deleteWindowsDesktopIcon

public boolean deleteWindowsDesktopIcon(java.lang.String submenu,
                                        java.lang.String itemName,
                                        java.lang.String user)
Delete icon from the desktop on Windows.

Parameters:
submenu - the submenu.
itemName - the menu item.
user - if currentUser, then delete menu from the HKEY_CURRENT_USER key; if allUsers, then try to delete from the HKEY_LOCAL_MACHINE key, but if that fails, then delete from the HKEY_CURRENT_USER key.
Returns:
true if successful.

runThirdPartyApp

public boolean runThirdPartyApp(java.lang.String exec,
                                java.lang.String[] args)
Run a third party program.

It's very important that you *not* pass the full command line, including arguments, as the first parameter. Also, the uninstaller can only run apps that have a fully qualified pathname for the exec and the args listed individually in a String[]. In other words, the first parameter must be the pathname for the program (e.g., C:\Program files\Java\bin\java.exe).

If the third party app is a part of the files that the installer installed, then be sure to call prepend() so your app is run before the standard part of the uninstaller runs.

Parameters:
exec - program name.
args - arguments.
Returns:
true if successful.