How do I remove old desktop shortcuts?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Stein Inge
    Forum Member
    • Nov 2006
    • 52

    How do I remove old desktop shortcuts?

    Hi folks
    I need to remove a shotcut for the old version of my application as I install the new program.

    1) Desktop
    On the desktop there is one shortcut icon called “MyApp v1”. My new application called "MyApp v2" is installing into the same folder as v1 and is placing a new shortcut icon on the desktop. During installation, I have to remove the old shortcut "MyApp v1" from the desktop, but how do I do that?

    2) Start menu > AppFolder
    The same as above really, but in this case I need to remove the shortcut folder with the old name "MyApp v1" during the installation of "MyApp v2", but how do I do that?

    Best regards
    Stein Inge Haalad
  • Adam
    Indigo Rose Staff Member
    • May 2000
    • 2149

    #2
    You can use the same action for both requests Shell.DeleteShortcut()

    Adam Kapilik

    Comment

    • Stein Inge
      Forum Member
      • Nov 2006
      • 52

      #3
      Thanks Adam, very kind of you.

      So that should mean that I can use;

      Shell.DeleteShortcut(_DesktopFolder, "MyApp v1");
      ... to remove my old desktop icon. But I'm not sure how to remove the entry in Start -> All Programs -> MyApp v1? I can't find a subsitution for the _DesktopFolder.

      best regards
      Stein Inge Haaland

      Comment

      • Adam
        Indigo Rose Staff Member
        • May 2000
        • 2149

        #4
        Try something like this:

        Code:
        Shell.DeleteShortcut(Shell.GetFolder(SHF_STARTMENUPROGRAMS), "Shortcut to My File");
        Adam Kapilik

        Comment

        • Stein Inge
          Forum Member
          • Nov 2006
          • 52

          #5
          Thanks Adam, but I must be doing something fundamentally wrong.

          My code in the On Post Install looks like this;

          Code:
          Shell.DeleteShortcut(_DesktopFolder, "Embla Familie og Slekt v2006");
          Shell.DeleteShortcut(Shell.GetFolder(SHF_STARTMENUPROGRAMS), "Embla Familie og Slekt v2006");
          After the install of my new program "Embla Familie og Slekt v2007", both icons still show on the desktop and in the programs menu. See the picture. Any suggestions?

          Best regards
          Stein Inge Haaland
          Attached Files

          Comment

          • Stein Inge
            Forum Member
            • Nov 2006
            • 52

            #6
            Hi Adam or anyone else at IndigoRose

            Hope you will be able to give me some more feedback on this problem as I seems to be stuck, and I need to get this new version out the door asap.

            The old shortcut on the desktop (Embla Familie og Slekt v2006) are not removed after an install of the new v2007 where I have included the following line into the "On Post Install" panel;

            Code:
            Shell.DeleteShortcut(_DesktopFolder, "Embla Familie og Slekt v2006");
            But if I restart the system, the v2006 desktop shotcut is removed! Is there a bug in SF7 or is this a "feature" of Windows - or where do I go wrong in the coding?
            ---------

            For the meny in the Start -> All Programs -> Embla Familie og Slekt v2006, it was not removed after a system restart. The following code was entered into the "On Post Install" panel;

            Code:
            Shell.DeleteShortcut(Shell.GetFolder(SHF_STARTMENUPROGRAMS), "Embla Familie og Slekt v2006");
            -------
            Somehow I have to remove this old dektop shortcuts and menu, and I really hope SFv7 are able to do this for me?

            best regards
            Stein Inge Haaland
            Last edited by Stein Inge; 03-03-2007, 10:12 AM.

            Comment

            • JXBURNS
              Forum Member
              • Apr 2001
              • 363

              #7
              Stein,

              For desktop, you may want to try
              Code:
              -- Delete user based shortcut
              Shell.DeleteShortcut(SessionVar.Expand("%DesktopFolder%), "Embla Familie og Slekt v2006");
              
              -- Delete common (all users) based shortcut
              Shell.DeleteShortcut(SessionVar.Expand("%DesktopFolderCommon%), "Embla Familie og Slekt v2006");
              For program folders, try
              Code:
              -- Delete user based shortcut
              Shell.DeleteShortcut(SessionVar.Expand("%StartProgramsFolder%), "Embla Familie og Slekt v2006");
              
              -- Delete common (all users) based shortcut
              Shell.DeleteShortcut(SessionVar.Expand("%StartProgramsFolderCommon%), "Embla Familie og Slekt v2006");
              If all else fails make sure you are generating a log file with extended errors and use the Application.GetLastError functionality to see if the system is giving an error.

              Rgds John

              Comment

              • Stein Inge
                Forum Member
                • Nov 2006
                • 52

                #8
                Thanks John.

                It was very kind of you to try to help he out of this, but I can't see that it helped. The desktop icon are removed, but I still have to restart the system. The program folder is steady as a rock - not able to delete it, no even after a system restart.

                I do not have enough programming experiances to understand how to use the Application.GetLastError functionality to see if the system is giving an error.

                best regards
                Stein Inge Haaland

                Comment

                • JXBURNS
                  Forum Member
                  • Apr 2001
                  • 363

                  #9
                  Stein

                  Did you put all of the code in just in case as it is not clear from your messages where the original shortcuts were created? They could be at user or system level. If at the latter it is possible you do not have security permissions to delete the program files shortcut especially if you are not logged on as Administrator equivalent when you try.

                  To check this you need to use error trapping. Make sure you have set the system up to use a log file with extended errors in Settings -> Log Files

                  Then try pasting this code on the next line immediately after the deletion of the shortcut. Repeat the same code after each of the shortcut deletions. Run the setup and have a look at the logfile afterwards to see if any errors but the system should report them anyway due to the use of the Dialog.Message line. It will report the actual message, not the error number which may give a clue as to why not deleting.

                  Code:
                  Shell.DeleteShortcut code goes here
                  
                  nLastError = Application.GetLastError();
                  if(nLastError ~= 0)then
                    Dialog.Message("Error",_tblErrorMessages[nLastError]);
                    SetupData.WriteToLogFile("--> Error reported when deleting shortcut".."_tblErrorMessages[nLastError],true);
                  else
                    SetupData.WriteToLogFile("--> Deleted shortcut OK", true);
                  end
                  Rgds John

                  Comment

                  • Stein Inge
                    Forum Member
                    • Nov 2006
                    • 52

                    #10
                    Thanks John
                    You last entry made me think a bit as I always run my tests using remote desktop from my work-system to other test systems. When I worked right on one of the test systems, the desktop icon was removed after an install, but the old program folder is still there. So its 50% done

                    Let see what I now have in my "On Post Install"

                    Code:
                    -- Delete user based shortcut
                    Shell.DeleteShortcut(SessionVar.Expand("%DesktopFolder%"), "Embla Familie og Slekt v2006");
                    nLastError = Application.GetLastError();
                    if(nLastError ~= 0)then
                      Dialog.Message("Error",_tblErrorMessages[nLastError]);
                      SetupData.WriteToLogFile("Error reported when deleting shortcut".."_tblErrorMessages[nLastError]",true);
                    else
                      SetupData.WriteToLogFile("Deleted shortcut OK", true);
                    end
                    
                    --Delete common (all users) based shortcut
                    Shell.DeleteShortcut(SessionVar.Expand("%DesktopFolderCommon%"), "Embla Familie og Slekt v2006");
                    nLastError = Application.GetLastError();
                    if(nLastError ~= 0)then
                      Dialog.Message("Error",_tblErrorMessages[nLastError]);
                      SetupData.WriteToLogFile("Error reported when deleting shortcut".."_tblErrorMessages[nLastError]",true);
                    else
                      SetupData.WriteToLogFile("Deleted shortcut OK", true);
                    end
                    
                    -- Delete user based shortcut
                    Shell.DeleteShortcut(SessionVar.Expand("%StartProgramsFolder%"), "Embla Familie og Slekt v2006");
                    nLastError = Application.GetLastError();
                    if(nLastError ~= 0)then
                      Dialog.Message("Error",_tblErrorMessages[nLastError]);
                      SetupData.WriteToLogFile("Error reported when deleting program folder".."_tblErrorMessages[nLastError]",true);
                    else
                      SetupData.WriteToLogFile("Deleted program folder OK", true);
                    end
                    
                    
                    -- Delete common (all users) based shortcut
                    Shell.DeleteShortcut(SessionVar.Expand("%StartProgramsFolderCommon%"), "Embla Familie og Slekt v2006");
                    nLastError = Application.GetLastError();
                    if(nLastError ~= 0)then
                      Dialog.Message("Error",_tblErrorMessages[nLastError]);
                      SetupData.WriteToLogFile("Error reported when deleting program folder".."_tblErrorMessages[nLastError]",true);
                    else
                    SetupData.WriteToLogFile("Deleted program folder OK", true);
                    end
                    The On Post Install part of the logfile looks like this;
                    ----
                    [03/04/2007 09:33:29] Notice Start project event: On Post Install
                    [03/04/2007 09:33:30] Deleted shortcut OK
                    [03/04/2007 09:33:30] Deleted shortcut OK
                    [03/04/2007 09:33:30] Deleted program folder OK
                    [03/04/2007 09:33:30] Deleted program folder OK
                    [03/04/2007 09:33:30] Success Run project event: On Post Install
                    [03/04/2007 09:33:30] Success Display screen: Finished Install
                    [03/04/2007 09:36:20] Notice Start project event: On Shutdown
                    ----

                    Looks like that SF7 thinks that the program folder has been removed -but it's still there to haunt me. Any more suggestions to what I can do to make it go away?

                    best regards
                    Stein Inge Haaland
                    Attached Files

                    Comment

                    • JXBURNS
                      Forum Member
                      • Apr 2001
                      • 363

                      #11
                      This all looks OK to me unless others have any idea.

                      I wonder if the shortcut text is not matching exactly. So (for example) "Embla Familie og Slekt v2006" (in Program Files) may have an extra space in it which you are not noticing. I would certainly suggest go into the properties for the shortcut and copy/paste the text back to the SUF7 code just to make sure. I believe SUF7 will not necessarily report an error on something like that hence why the log file is showing it worked.

                      I would also suggest you make the shortcut text a variable either in Session Variables or within the code itself. That way if you decide to change the name of the shortcut later you only have to do it in one place and reduce the risk of making a mistake.

                      John

                      Comment

                      Working...
                      X