DeleteDir Example

InstallShield 2015 ยป InstallScript Language Reference

Note: To call this function in a Basic MSI setup, you must first create a custom action for the entry-point function, execute the custom action in a sequence or as the result of a dialog's control event, and then build the release.



* InstallShield Example Script


* Demonstrates the DeleteDir function.


* First, CreateDir is called to create a directory.  Then,

* DeleteDir is called to delete it.




#define EXAMPLE_DIR "C:\\Newdir"


// Include Ifx.h for built-in InstallScript function prototypes.

#include "Ifx.h"


export prototype ExFn_DeleteDir(HWND);


function ExFn_DeleteDir(hMSI)



    // Create a directory.

    if (CreateDir (EXAMPLE_DIR) != 0) then

        // Report the error; then terminate.

        MessageBox ("Unable to create directory.", SEVERE);



        // Report success.

        MessageBox (EXAMPLE_DIR + " was created.", INFORMATION);


        // Delete the directory.  If the directory is not

        // empty, it is not deleted.

        if (DeleteDir (EXAMPLE_DIR, ONLYDIR) = 0) then

            // Report success.

            MessageBox (EXAMPLE_DIR + " was deleted.", INFORMATION);


            MessageBox ("Unable to delete directory.", SEVERE);