Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 11 of 11
  1. #1
    Join Date
    Nov 2006
    Location
    Norway
    Posts
    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

  2. #2
    Join Date
    May 2000
    Location
    Indigo Rose Software
    Posts
    2,149
    You can use the same action for both requests Shell.DeleteShortcut()

    Adam Kapilik

  3. #3
    Join Date
    Nov 2006
    Location
    Norway
    Posts
    52
    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

  4. #4
    Join Date
    May 2000
    Location
    Indigo Rose Software
    Posts
    2,149
    Try something like this:

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

  5. #5
    Join Date
    Nov 2006
    Location
    Norway
    Posts
    52
    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 Images

  6. #6
    Join Date
    Nov 2006
    Location
    Norway
    Posts
    52
    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 at 11:12 AM.

  7. #7
    Join Date
    Apr 2001
    Location
    Haverhill, Suffolk, UK
    Posts
    360
    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

  8. #8
    Join Date
    Nov 2006
    Location
    Norway
    Posts
    52
    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

  9. #9
    Join Date
    Apr 2001
    Location
    Haverhill, Suffolk, UK
    Posts
    360
    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

  10. #10
    Join Date
    Nov 2006
    Location
    Norway
    Posts
    52
    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 Images

  11. #11
    Join Date
    Apr 2001
    Location
    Haverhill, Suffolk, UK
    Posts
    360
    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

Similar Threads

  1. Shortcuts Desktop, Check Box Screen
    By spidermanxp in forum Setup Factory 7.0
    Replies: 1
    Last Post: 07-13-2006, 03:20 PM
  2. uninstall doesn't remove start menu shortcuts
    By gnznroses in forum Setup Factory 6.0
    Replies: 3
    Last Post: 10-14-2005, 03:33 PM
  3. Desktop shortcuts on Windows server 2003
    By tmluke in forum Setup Factory 6.0
    Replies: 3
    Last Post: 04-05-2005, 11:25 AM
  4. Make a desktop folder & put shortcuts in it
    By Dane Lamb in forum Setup Factory 6.0
    Replies: 2
    Last Post: 05-26-2003, 10:31 AM
  5. Shortcuts on desktop
    By Mwerner in forum Setup Factory 5.0
    Replies: 5
    Last Post: 01-22-2001, 04:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts