none
Remove Programs does not delete files RRS feed

  • Question

  • When I remove applications on Windows Mobile 6 that I have installed via a simple Smart Device CAB, the application is removed from the list of installed applications, but the files are left on the file system. For example, when I look in /Program Files/MyApp, I see all the files still there. I am removing the application via Start -> Settings -> System -> Remove Programs. Is this normal behavior? If so, what exactly is removed?


     

     

    Friday, January 23, 2009 7:55 PM

All replies

  •  One of the requirements for software that sports the "Made for Windows Mobile" certification is that the software is supposed to remove all of it's files when you uninstall it.  Based on that I would say the software to which you are referring is not conforming software and I can't really say what is normal for non-conforming software.

     

    From the "Designed for Windows Mobile Professional" guide (PDF).

    "When the user uninstalls, the application should clean up any data from files or the registry "

    You can find more information about logo requirements at the Mobile2Market site.

     

     


    Joel Ivory Johnson
    Twitter:J2iNET
    Friday, January 23, 2009 10:34 PM
  • The software in question is every application I create with Visual Studio 2008, deploy using a Smart Device CAB project, and remove with the Remove Programs control panel in Windows Mobile 6. Do I have any control over the removal of files using this method?

     

     


     

     

    Saturday, January 24, 2009 5:10 PM
  • You have control over it.  From the  "Designed for Windows Mobile Professional" guide that I mentioned in the previous response:

    When the user uninstalls, the application should clean up any data from file or the registry and leave as little behind as possible.  The application should use "Uninstall_Init()" and "Uninstall_Exit()" functionality to clean updata files and databases

     

    You need to make a Win32 DLL smart device project.  The DLL will export 4 functions.  These 4 functions will need to be listed in a module definition file for export. Here's an example module definition file.

    EXPORTS  
     
    Install_Init  
    Install_Exit  
    Uninstall_Init  
    Uninstall_Exit 

    Each one of those functions will be run before/after installation/deinstallation. You will want to write cleanup code in one of the uninstall functions.  Below is the code that I placed in my project that was removing registry keys from HKCU\Software\J2i.Net\MyColourPreferences from the registry.

     
    BOOL APIENTRY DllMain( HANDLE hModule,   
                           DWORD  ul_reason_for_call,   
                           LPVOID lpReserved  
                         )  
    {  
        switch (ul_reason_for_call)  
        {  
        case DLL_PROCESS_ATTACH:  
        case DLL_THREAD_ATTACH:  
        case DLL_THREAD_DETACH:  
        case DLL_PROCESS_DETACH:  
            break;  
        }  
        return TRUE;  
    }  
     
     
    void RemoveRegistryKeys();  
    ///////////////////////////////////////////////////////////////  
      codeINSTALL_INIT Install_Init  
    (  
        HWND hWndParent,  
        BOOL fFirstCall,  
        BOOL fPreviouslyInstalled,  
        LPCSTR pszInstallDir  
     )  
    {  
        MessageBeep(0);  
        return codeINSTALL_INIT_CONTINUE;  
    }  
    ///////////////////////////////////////////////////////////////  
     codeINSTALL_EXIT Install_Exit  
    (  
        HWND hWndParent,  
        LPCSTR pszInstallDir,  
        WORD    cFailedDirs,  
        WORD    cFailedRegKeys,  
        WORD    cFailedRegVals,  
        WORD    cFailedShortcuts  
     )  
    {  
     
        MessageBeep(0);  
        return codeINSTALL_EXIT_DONE;  
    }  
    ///////////////////////////////////////////////////////////////  
    codeUNINSTALL_INIT Uninstall_Init  
    (  
        HWND    hwndParent,  
        LPCSTR  pszInstallDir  
     )  
    {  
        MessageBeep(0);  
     
        return codeUNINSTALL_INIT_CONTINUE;  
    }  
    ///////////////////////////////////////////////////////////////  
      codeUNINSTALL_EXIT Uninstall_Exit  
    (  
        HWND    hwndParent  
     )  
    {  
        RemoveRegistryKeys();  
        MessageBeep(0);  
        return codeUNINSTALL_EXIT_DONE;  
    }  
     
     
     
    void RemoveRegistryKeys()  
    {  
          HKEY hCompanyKey = NULL;  
          HKEY hSoftwareKey = NULL;  
                
          TCHAR buffer[MAX_PATH];  
          DWORD bufferSize = MAX_PATH;  
          bool canEraseCompanyKey = false;  
          //Delete the application key  
          RegOpenKeyEx(HKEY_CURRENT_USER,L"Software", 0,0,&hSoftwareKey);  
          if(hSoftwareKey)  
          {  
              RegOpenKeyEx(hSoftwareKey, L"J2i.Net",0,0,&hCompanyKey);  
              if(hCompanyKey)  
              {  
                    RegDeleteKey(hCompanyKey, L"MyColourPreferences");  
                    canEraseCompanyKey = (ERROR_SUCCESS!=RegEnumKeyEx(hCompanyKey,0,buffer,&bufferSize,0,0,0,0));  
                    RegCloseKey(hCompanyKey);  
                    RegCloseKey(hCompanyKey);  
                    if(canEraseCompanyKey)  
                        RegDeleteKey(hSoftwareKey,L"J2i.Net");  
              }  
              if(hSoftwareKey)  
                  RegCloseKey(hSoftwareKey);  
          }  

     

    The DLL must be included in your cab installer.  There's a setting on the cab project called "CE Setup DLL" that should be set to point to the DLL in which you define your cleanup code.  Then whenever the cab is run or your program is uninstalled your code will run and perform cleanup.


    Joel Ivory Johnson
    Twitter:J2iNET
    Saturday, January 24, 2009 11:24 PM
  • Thank you. I have to admit that I am a bit surprised that I have to do so much work to have my application files removed when he user uses the Remove Programs control panel. 

     

    The other thing that is weird about my CAB "installer" is that, when I install it, regardless of whether I select "Internal Storage", it gets installed in the same location. Is that the expected behavior?
    Monday, January 26, 2009 9:40 PM
  • The only thing I could think of that would cause such behaviour is having a cab with paths hard coded into it. Beyond that I've got no clue what could be causing such behaviour.

     

     


    Joel Ivory Johnson
    Twitter:J2iNET
    Monday, January 26, 2009 9:43 PM
  • I just skimmed over the Packaging and Deployment chapter of Peter Foot's book and I don't see anything saying I need to write a custom action in order for my applications to be deleted upon an uninstall. I'm confused.

     

     

    Monday, January 26, 2009 10:11 PM
  • The custom action isn't for deleting your application.  The custom action is for handling other changes that your application may have done on the system.  While the installer can keep track of the files that are part of the application it does not track your applications behaviour to see what modifications it does to the registry or the file system.  This can be said of both the Windows Mobile installer and the Windows Desktop installer.

    I am assuming that the book to which you are referring is "Microsoft Mobile Development Handbook" by Wigley, Moth, and Foot.  Keep in mind that the bok is intended to give you enough information to pick-up and carry forward.  It's not an exhaustive volume of everything you will ever need to know about Windows Mobile development.  


    Joel Ivory Johnson
    Twitter:J2iNET
    Monday, January 26, 2009 11:03 PM
  • Heh. We are going in circles. My problem is that the files are not being deleted by the Remove Programs control panel. There is nothing special like registry settings involved.
    Tuesday, January 27, 2009 12:31 AM