cancel
Showing results for 
Search instead for 
Did you mean: 

Uninstall Add On

Former Member
0 Kudos

Hey All,

I am trying to figure out how to get my setup.exe program to call another exe file located in this folder uninst\unins000.exe. It is created directly under my add on folder. Does Business One pass any command arguments to the setup.exe file when it calls it during the uninstall process?

Any ideas how I could figure this location out?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Curtis,

You can get the commandline passed by SAP Business One. The following is an example.

///////////////////////////////////////////////////////////////////////////////
//                                                                           
//  FUNCTION:   OnFirstUIBefore                                            
//                                                                           
//  EVENT:      FirstUIBefore event is sent when installation is run for the first
//              time on given machine. In the handler installation usually displays
//              UI allowing end user to specify installation parameters. After this
//              function returns, ComponentTransferData is called to perform file
//              transfer.
//                                                                           
///////////////////////////////////////////////////////////////////////////////
function OnFirstUIBefore()
    NUMBER nResult;
    STRING szTitle, szMsg;
    LIST list, listStartCopy;
    string  szvImage, szsideLogo;  
begin	                                   
    szvImage = SUPPORTDIR ^ "BG2.bmp";    
    szsideLogo = SUPPORTDIR ^ "SideLogo.bmp";
    gbUninstall = FALSE;
         
   	if (CMDLINE = "uninstall") then
		MessageBox("You have uninstalled the Addon before!", INFORMATION);
		abort;
	endif;
	
	if (CMDLINE != "") then
	    list = ListCreate (STRINGLIST);
	    if StrGetTokens (list, CMDLINE, "|") = 0 then
			ListGetFirstString(list, INSTALLDIR);
	    	ListGetNextString(list, gszDLL); 
	    else
       		MessageBox("Command line parameter is incorrect!", INFORMATION);
       		abort;
		endif;
	else
			MessageBox("The Addon Installer need to run in SAP Business One!",INFORMATION);
			abort;
	endif;     

Dlg_SdWelcome:  
    szTitle = "";
    szMsg = "";      
    DialogSetInfo(DLG_INFO_ALTIMAGE, szsideLogo, TRUE);
    nResult = SdWelcome( szTitle, szMsg );
    if (nResult = BACK) goto Dlg_SdWelcome;
    
Dlg_SdStartCopy:   
    szTitle = "";
    szMsg   = "";  
    DialogSetInfo(DLG_INFO_ALTIMAGE, szvImage, TRUE);
    listStartCopy = ListCreate( STRINGLIST );
    ListAddString (listStartCopy, "Installation Directory", AFTER);
    ListAddString (listStartCopy, INSTALLDIR, AFTER);

    nResult = SdStartCopy( szTitle, szMsg, listStartCopy );	
    ListDestroy(listStartCopy);
    if (nResult = BACK) goto Dlg_SdWelcome;
                            
    // setup default status
    SetStatusWindow(0, "");
    Enable(STATUSEX);
    StatusUpdate(ON, 100);
                                     
    UNINSTALLKEY = @PRODUCT_NAME;   
    return 0;
end;

And, if you want to call another exe to uninstall your addon, you need to do that in function OnMaintUIBefore().

But remember, call <b>EndUninstall</b> at the end, otherwise, B1 does not know whether your addon has been uninstalled or not.

Hope this helps,

Nick He

Former Member
0 Kudos

Thanks for the posting Nick.

I am a bit confused. IN your post you mentioned a OnMaintUIBefore() function but I do not see that anywhere in your code. My setup.exe does not seem to receive any command line parameters from Business One during the uninstall process.

How would business one know where my setup.exe is installed?

If I can figure out that then I can simply call my uninstall.exe file from the setup.exe and everything should be fine.

simone_pastorin
Participant
0 Kudos

It's in .ard file generation that you tell which .exe is the unistaller and which parameters it needs to receive.

Former Member
0 Kudos

Look at SARI table of SBOCommon. You can find there information about uninstallation .exe and parameters

Former Member
0 Kudos

Thanks Jose,

I have looked in that table and I cannot find anything related to the uninstall other then the parameters that I pass during my registration file create step.

Can anyone tell me how they implement an uninstall? My installer program has a setup.exe for the installer but the uninstaller is a different file.