Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Uninstall with a password


4 replies to this topic

kmurphy99

kmurphy99
  • Members
  • 3 posts

Posted 12 August 2001 - 20:43

I have a program that I had previously written a custom uninstaller for.  This uninstaller would prompt a user for a password before it would uninstall, as it was intended to be controlled by system admins and the like, not the general population.

I got tired of making changes to my program whenever a filename changed or whatever....  So....

I want to switch to using UninstallShield to accomplish my uninstallation.  I need it to pop open a dialog box prompting for a password to be entered before it runs.  If the password is wrong, it needs to abort the uninstall.

Anyone know how to do this?

Thanks!


kmurphy99

kmurphy99
  • Members
  • 3 posts

Posted 13 August 2001 - 04:36

What might also work for me is to have my program launch the UninstallShield program.  If this is easier, I'd greatly appreciate an answer!

Torgui

Torgui
  • Members
  • 27 posts

Posted 13 August 2001 - 06:57

Create a DLL with two exported functions:
LONG __declspec(dllexport) APIENTRY UninstInitialize(HWND hwndDlg, HANDLE hInstance, LONG lReserved)

and

LONG __declspec(dllexport) APIENTRY UninstUnInitialize(HWND hwndDlg, HANDLE hInstance, LONG lReserved)

Ask the uninstallation password in the first function. If the password is wrong, return -1 and the uninstallation will not continue. If the password is correct, return 0 and the uninstallation continues normally.
In the UninstUnInitialize function you can just return 0.

Then, define your uninstallation entry UninstallString as follows:
C:\WINNT\ISUN040B.EXE -f"C:\Program Files\Company\AppName\AppName.isu" -c"C:\Program Files\Company\AppName\DLLName.DLL""

So you have to add -c parameter pointing to the DLL you just created.

See more information from the IS5.x Getting Results Guide in the help section named "Call a custom DLL function from unInstallShield".



kmurphy99

kmurphy99
  • Members
  • 3 posts

Posted 13 August 2001 - 12:11

Sorry if I sound ignorant....  I'm brand new to this stuff...  What do I do with this section of code when created by the wizard?


///////////////////////////////////////////////////////////////////////////////
//                                                                           //
// Function: ProcessBeforeDataMove                                           //
//                                                                           //
//  Purpose: This function performs any necessary operations prior to the    //
//           actual data move operation.                                     //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////
function ProcessBeforeDataMove()
 STRING svLogFile;
 NUMBER nResult;
begin

 InstallationInfo( @COMPANY_NAME, @PRODUCT_NAME, @PRODUCT_VERSION, @PRODUCT_KEY );

 svLogFile = UNINST_LOGFILE_NAME;

 nResult = DeinstallStart( svDir, svLogFile, @UNINST_KEY, 0 );
 if (nResult < 0) then
     MessageBox( @ERROR_UNINSTSETUP, WARNING );
 endif;

 szAppPath = TARGETDIR; // TODO : if your application .exe is in a subdir of TARGETDIR then add subdir

 if ((bIs32BitSetup) && (bIsShellExplorer)) then
    RegDBSetItem( REGDB_APPPATH, szAppPath );
    RegDBSetItem( REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY );
    RegDBSetItem( REGDB_UNINSTALL_NAME, @UNINST_DISPLAY_NAME );
 endif;

 // TODO : update any items you want to process before moving the data
 //

 return 0;
end;

For my custom program to run, I did this in SetupRegistry():


  szKey     = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MyApp2";
  szName    = "DisplayName";
  szValue   = "My AppUninstaller";
  if (RegDBSetKeyValueEx(szKey, szName, REGDB_STRING, szValue, -1) < 0) then
     MessageBox("Unable to set application path key.", SEVERE);
  endif;

  szKey     = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MyApp 2";
  szName    = "UninstallString";
  szValue   = TARGETDIR ^ "MYUninstall.exe";
  if (RegDBSetKeyValueEx(szKey, szName, REGDB_STRING, szValue, -1) < 0) then
     MessageBox("Unable to set application path key.", SEVERE);
  endif;


then I commented out the 1st code block:


///////////////////////////////////////////////////////////////////////////////
//                                                                           //
// Function: ProcessBeforeDataMove                                           //
//                                                                           //
//  Purpose: This function performs any necessary operations prior to the    //
//           actual data move operation.                                     //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////
function ProcessBeforeDataMove()
   STRING svLogFile;
   NUMBER nResult;
begin

 InstallationInfo( @COMPANY_NAME, @PRODUCT_NAME, @PRODUCT_VERSION, @PRODUCT_KEY );

 svLogFile = UNINST_LOGFILE_NAME;

//  nResult = DeinstallStart( svDir, svLogFile, @UNINST_KEY, 0 );
//  if (nResult < 0) then
//      MessageBox( @ERROR_UNINSTSETUP, WARNING );
//  endif;

 szAppPath = TARGETDIR; // TODO : if your application .exe is in a subdir of TARGETDIR then add subdir

//  if ((bIs32BitSetup) && (bIsShellExplorer)) then
//      RegDBSetItem( REGDB_APPPATH, szAppPath );
//      RegDBSetItem( REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY );
//      RegDBSetItem( REGDB_UNINSTALL_NAME, @UNINST_DISPLAY_NAME );
//  endif;

 // TODO : update any items you want to process before moving the data
 //

 return 0;
end;


Since in your method I don't need my custom program to run, I'm wondering what I need.  Also, in the custom DLL, how does the UninstallShield script actually run?

Thanks a lot!