Announcement

Collapse
No announcement yet.

Deleting folder from Start Menu -> Programs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Deleting folder from Start Menu -> Programs

    Upon Post Uninstall, what's the correct action needed to delete the shortcut from the Start Menu under Programs? The shortcut shows a folder with the name of my program - and underneath it, it just shows "(Empty)" after the uninstall is complete.

    I'd like to remove that shortcut altogether. I tried this:
    Code:
    result = Folder.DoesExist(SessionVar.Expand("%AppFolder%"));
    if(result == true) then
    	Folder.Delete(SessionVar.Expand("%AppFolder%"));
    end
    but it didn't seem to do anything.

    Please advise. Thank you!

  • #2
    The user's Start menu folder can be found with %StartFolder%, and the Start menu folder for All users can be retrieved with %StartFolderCommon%. You will use only one of them, depending if the shortcut was created in the user profile or for all users. This can be set in the Project Settings and in the Select Shortcut Folder screen. The name of the folder created for the shortcuts on the Start menu can be retrieved with %AppShortcutFolderName%.

    If your installer is leaving an empty folder behind, this means that you have an error in your setup. Most likely, you are creating custom items and not deleting them at the right time, so when the setup engine attempts to delete the folder which should be empty at that time, it fails because there is still something there. After you delete that item, the empty folder is left behind. Attempting to delete the folder yet again would be an attempt to hide the error, instead of correcting the issue.

    Ulrich

    Comment


    • #3
      After my uninstaller exits, I'm still left with two things in the %AppFolder%:
      1. the "Logs" folder generated (by nLog) when my program runs
      2. my config file which is copied there by Setup Factory as one of the "Archive" files

      I'd imagine the existence of those two items may stop the %AppFolder% folder itself - and hence the shortcut - from being deleted. Please advise what I may be doing incorrectly with those so I can fix it.

      Thank you!

      Comment


      • #4
        If the config file was placed there by the installer as part of the archive files, it should have been deleted during uninstall. You should check the uninstaller log file why this didn't happen, as the failure for whatever reason will be written there. Possible reasons are that the file wasn't deployed by the latest install - it was already there before running the setup, so it wasn't included in the list of files deployed and to be removed, instead it will be skipped. The other possibility is that the file was renamed so it no longer matches the expected name, or it was in use when the uninstaller attempted to delete it, etc.

        If you create additional files in a sub folder of AppFolder, you may need to use Folder.DeleteTree() to clean up the system as part of the On Pre Uninstall event script.

        Ulrich

        Comment


        • #5
          This is what I have in the Post Uninstall action:

          Code:
          result = Folder.DoesExist(SessionVar.Expand("%AppFolder%"));
          if(result == true) then
          	Folder.Delete(SessionVar.Expand("%AppFolder%"));  [B]--error 2303 ("Shortcut could not be deleted.")[/B]
          end
          I was thinking of changing it to this:

          Code:
          entireFolderPath = SessionVar.Expand("%AppFolder%");
          isEntireFolderPresent = Folder.DoesExist(entireFolderPath);
          if(isEntireFolderPresent == true) then
          	
          	logsFolderPath = SessionVar.Expand("%StartProgramsFolder%\\%AppShortcutFolderName%\\Logs");
          	isLogsFolderPresent = Folder.DoesExist(logsFolderPath);
          	if(isLogsFolderPresent == true) then
          		Folder.DeleteTree(logsFolderPath);
          	end
          	
          	configFilePath = SessionVar.Expand("%StartProgramsFolder%\\%AppShortcutFolderName%\\Config file");
          	isConfigFilePresent = File.DoesExist(configFilePath);
          	if(isConfigFilePresent == true) then
          		File.Delete(configFilePath);
          	end
          
          	Folder.DeleteTree(entireFolderPath);
          end
          I was thinking it would make sense to get rid of the Logs folder shortcut, then the Config file, then the entire AppFolder.

          Didn't work...

          Am I referring to these paths correctly? Where am I wrong?

          Thanks again...

          Comment


          • #6
            In the On Pre Uninstall, start the cleaning. First, remove the shortcut you created in the Start menu to the Logs sub folder. Then remove the Logs folder and its contents itself with Folder.DeleteTree(). You created these manually, so you need to remove them manually. Once this was done, the rest should be cleaned properly by the uninstaller.

            Ulrich

            Comment


            • #7
              In Pre-Uninstall, I now have this:
              Code:
              --delete the Logs shortcut from the Start Menu
              Shell.DeleteShortcut(SessionVar.Expand("%StartProgramsFolder%\\%AppShortcutFolderName%"), "Log Folder");
              
              --then delete the Logs folder itself
              logsFolderPath = SessionVar.Expand("%StartProgramsFolder%\\%AppShortcutFolderName%\\Logs");
              	isLogsFolderPresent = Folder.DoesExist(logsFolderPath);
              if(isLogsFolderPresent == true) then
              	Folder.DeleteTree(logsFolderPath);
              end
              After uninstallation is complete, in the Start Menu, I still see a folder with the name of the app. Underneath it, there's a shortcut to the Logs folder.

              In the actual file structure, I see that the Logs folder is still there (in Program Files / AppFolderName). Alongside it is the Config file that was copied there by Setup Factory as an "archive" file.

              Here's what the uninstall log says:
              [06/04/2015 09:18:48] Success Remove folder on reboot: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\EC Client

              [06/04/2015 09:18:48] Error Remove folder: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\EC Client (32)

              Please (further) advise.
              Thank you.

              Comment


              • #8
                Please post the project file and the log files.

                Ulrich

                Comment


                • #9
                  I am not comfortable posting these publicly to the website as it’s a project for a client. I will send you those two files via email instead and will check back on this forum for your reply.
                  Thank you very much for your help.

                  Comment


                  • #10
                    Your code doesn't perform the actions I recommended. I said
                    First, remove the shortcut you created in the Start menu to the Logs sub folder.
                    What you actually do is
                    Code:
                    Shell.DeleteShortcut(SessionVar.Expand("%StartProgramsFolder%\\%AppShortcutFolderName%"), "Log Folder");
                    This is an attempt to delete the entire shortcut folder, not the Logs sub folder, as I mentioned.

                    Then I said
                    remove the Logs folder and its contents itself with Folder.DeleteTree().
                    What you do is this:
                    Code:
                    Folder.DeleteTree(SessionVar.Expand("%StartProgramsFolder%\\%AppShortcutFolderName%\\Logs"));
                    The Logs folder is a child of %AppFolder%, so attempting to delete something in the Start menu won't work at all, as this isn't where the folder is located.

                    Please read carefully what I write, and attempt to follow the instructions.

                    Ulrich

                    Comment


                    • #11
                      I have been doing my best to read your replies carefully, understand the built-in session variables, and get acclimated in Lua.

                      My "Pre-Uninstall" action now reads like this:
                      Code:
                      --delete the Logs shortcut from the Start Menu
                      Shell.DeleteShortcut(SessionVar.Expand("%StartProgramsFolder%\\%AppShortcutFolderName%\\Logs"), "Logs");
                      
                      --then delete the Logs folder itself
                      logsFolderPath = SessionVar.Expand("%AppFolder%\\Logs");
                      	isLogsFolderPresent = Folder.DoesExist(logsFolderPath);
                      if(isLogsFolderPresent == true) then
                      	Folder.DeleteTree(logsFolderPath);
                      end
                      It still leaves the the "app folder" shortcut in the Start Menu. Also remaining directly underneath that is the "Logs" folder Start Menu shortcut. (The Logs folder itself is now successfully deleted.)

                      For clarity, this is how I created the Start Menu shortcut to the Logs folder:
                      Code:
                      Shell.CreateShortcut(SessionVar.Expand("%StartProgramsFolder%\\%AppShortcutFolderName%"), "Logs", SessionVar.Expand("%AppFolder%\\Logs"));
                      How specifically should I modify the above code to complete clear out the Start Menu shortcuts?

                      Thank you again,
                      Eliezer

                      Comment


                      • #12
                        The uninstallation log file shows that the %AppShortcutFolderName% in the Start menu is scheduled for deletion on the next reboot. After rebooting, is the folder really still there?

                        Ulrich

                        Comment


                        • #13
                          As a matter of fact, it does get deleted after reboot! (Oops...) Thank you.

                          Comment

                          Working...
                          X