PDA

View Full Version : Not able to remove path for old version


Stein Inge
09-08-2008, 02:51 PM
My setup:
- Setup Factory v8.1.1004.0
- Vista Ultimate

Many of my users have an older version of our program. During installation, I have to remove some of the old shortcuts and replace it with the new.

1) Desktop
Before install of the new versjon the user have one icon called "Embla Familie og Slekt v2007". After install the user have 2 icons called "Embla Familie og Slekt v8".

Why do I get 2 icons on the desktop?

In the "On Post Install" window, I have the following code;

-- remove the old desktop ikon for v2007

-- Delete user based shortcut
Shell.DeleteShortcut(SessionVar.Expand("%DesktopFolder%"), "Embla Familie og Slekt v2007");
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 v2007");
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

What have I done wrong here?

2) Program list
Before install the user have one icon called "Embla Familie og Slekt v2007" with 4 sub icons. After install the user still have the v2007 icon and the new v8 icon.

How can I get rid of the old v2007 icon + the sub icons?

In the "On Post Install" window, I have the following code;

-- Delete user based shortcut
Shell.DeleteShortcut(SessionVar.Expand("%StartProgramsFolder%"), "Embla Familie og Slekt v2007");
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 v2007");
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


How can I get rid of the old v2007 icon + the sub icons? What have I done wrong here?

3) Quickstart icons
Before install the user have one icon called "Embla Familie og Slekt v2007". After install the user still have the v2007 icon and the new v8 icon.

I have no code to remove this shortcut icon.

How can I get rid of the old v2007 icon?

Best regards
Stein Inge

Mark
09-09-2008, 09:10 AM
Hi Stein Inge,

My first question for you is: Does this work properly on other operating systems? e.g. Windows XP.

I ask this because I am able to create and delete shortcuts using the following code on Windows XP:


-- Create Shortcut
Shell.CreateShortcut(Shell.GetFolder(SHF_DESKTOP)
, "Embla Familie og Slekt v2007"
, "C:\\My Prog\\MyExe.exe"
, ""
, ""
, ""
, 0
, SW_SHOWNORMAL
, nil
, "");

-- Delete Shortcut
Shell.DeleteShortcut(Shell.GetFolder(SHF_DESKTOP)
, "Embla Familie og Slekt v2007");


So I don't think it's a problem with the actions themselves. My guess would be that the issue has to do with the user profiles and the UAC on Vista.

If the shortcuts are created in the user's profile, and if your installation requires elevation then the desktop folder is now the administrators desktop folder and not the user's desktop folder.

If you want a debug test you can use the following code to see if the shortcut exists and what path you are actually looking for it at:


strFilePath = Shell.GetFolder(SHF_DESKTOP)
strFilePath = strFilePath.."\\Embla Familie og Slekt v2007.lnk"
if (File.DoesExist(strFilePath)) then
Dialog.Message("Exists", "The file exists: "..strFilePath)
else
Dialog.Message("Does Not Exist", "The file does not exist: "..strFilePath)
end


If it is the case where you are dealing with per user shortcuts and the administrator I would suggest trying to use the launch user variables:


%LaunchUserDesktopFolder%
%LaunchUserStartProgramsFolder%
%LaunchUserApplicationDataFolder%


In order to populate these variables you must check the "Collect launch user information" checkbox on the Build Settings | Setup File Tab. (Another wonderful version 8.0 feature).

You can access the Quick Launch folder using the following code (although in your case you may want to use the %LaunchUserApplicationDataFolder% variable on Vista):


strQuickLaunch = SessionVar.Expand("%ApplicationDataFolder%")
strQuickLaunch = strQuickLaunch.."\\Microsoft\\Internet Explorer\\Quick Launch"


All of this aside the easiest way to remove shortcuts created by a previously installed version is to uninstall the previous version before installing the new version.

I hope this helps.