Indigo Rose Software
  #1  
Old 06-14-2005
csd214 csd214 is offline
Forum Member
 
Join Date: Oct 2001
Location: Norway
Posts: 939
Bonus to SUF70 Installations

VP20 is not restricted to SUF70 installations; naturally. Could you think of a "bonus" to SUF70 installation offering automatically change of %ProductVer%, adding new folders and files to the uninstall list (and removing legacy files)?

I know that the XML actions are included in VP20 and consequently the designer is capable of modifying the Uninstall Configuration File. Maybe you have a generic script (with parameters 'Uninstall files folder' and 'Configuration filename')?
  #2  
Old 06-14-2005
Brett's Avatar
Brett Brett is offline
Indigo Rose Staff Member
 
Join Date: Jan 2000
Posts: 2,001
I did this exact thing a while back. Here is the code I used. I put it in On Preload. It adds all patched files to the uninstall's XML file.

Code:
Debug.ShowWindow();

g_strUninstallXMLFile = "";
g_strUninstallXMLFile = SessionVar.Expand("%AppFolder%");
g_strUninstallXMLFile = String.TrimRight(g_strUninstallXMLFile,"\\");
g_strUninstallXMLFile = g_strUninstallXMLFile.."\\Uninstall\\Uninstall.xml";

Debug.Print("Uninstall file: "..g_strUninstallXMLFile.."\r\n");

g_tblFoldersAdded = {};

if(not File.DoesExist(g_strUninstallXMLFile))then
	-- No point in defining the g_OnFileProcessed function
	Debug.Print("ERROR: File does not exist\r\n");
	Application.ExitScript();
end

function AddFoldertoXML(strFullFilename)
	Debug.Print("AddFoldertoXML: "..strFullFilename.."\r\n");
	local tblParts = String.SplitPath(strFullFilename);
	if(not tblParts)then return false; end
	local strFolderPath = tblParts.Drive..tblParts.Folder;
	strFolderPath = String.TrimRight(strFolderPath,"\\");
	Debug.Print("AddFoldertoXML: strFolderPath:"..strFolderPath.."\r\n");
	local bFound = false;
	for i,Folder in g_tblFoldersAdded do
		if(not bFound)then
			if(String.CompareNoCase(Folder,strFolderPath) == 0)then
				bFound = true;
			end
		end
	end
	
	if not bFound then
		Debug.Print("AddFoldertoXML: folder not found\r\n");
		local nNumitems = Table.Count(g_tblFoldersAdded);
		g_tblFoldersAdded[nNumitems+1] = strFolderPath;
		
		local nCount = XML.Count("SUF70UninstallData/UninstallFolders","FolderPath");
		
		local nNewElementPos = nCount + 1;
		
		-- We have the XML loaded...
		XML.SetValue("SUF70UninstallData/UninstallFolders/FolderPath:"..nNewElementPos,strFolderPath);
		local nError = Application.GetLastError();		
		Debug.Print("XML.SetValue result: "..nError.." - ".._tblErrorMessages[nError].."\r\n");
		
		return true;
	end
	
	return false;
end

-- Add new files and backup files to the uninstaller for the product:
function g_OnFileProcessed (ResultCode,Filename,BackupFilename)
	Debug.Print("OnFileProcessed file: "..ResultCode..", "..Filename..", "..BackupFilename.."\r\n");

	local bChangesMade = false;

	XML.Load(g_strUninstallXMLFile);
	local nError = Application.GetLastError();
	
	Debug.Print("XML Load result: "..nError.." - ".._tblErrorMessages[nError].."\r\n");
	
	if(nError ~= 0)then
		return;
	end
	
	if(ResultCode == 2)then
		-- New file added
		local nFileCount = XML.Count("SUF70UninstallData/UninstallFiles","File");
		
		local nError = Application.GetLastError();
		Debug.Print("XML Count result: "..nError.." - ".._tblErrorMessages[nError].."\r\n");
		Debug.Print("XML Count: "..nFileCount.."\r\n");
		
		local nNewElementPos = nFileCount + 1;
		
		-- We have the XML loaded...
		XML.SetValue("SUF70UninstallData/UninstallFiles/File:"..nNewElementPos.."/Filename",Filename);
		local nError = Application.GetLastError();
		
		Debug.Print("XML.SetValue result: "..nError.." - ".._tblErrorMessages[nError].."\r\n");
		
		AddFoldertoXML(Filename);
		
		bChangesMade = true;
	else
		if(File.DoesExist(BackupFilename))then
			local nFileCount = XML.Count("SUF70UninstallData/UninstallFiles","File");
			local nError = Application.GetLastError();
			Debug.Print("XML Count result: "..nError.." - ".._tblErrorMessages[nError].."\r\n");
			Debug.Print("XML Count: "..nFileCount.."\r\n");
			local nNewElementPos = nFileCount + 1;
			
			-- We have the XML loaded...
			XML.SetValue("SUF70UninstallData/UninstallFiles/File:"..nNewElementPos.."/Filename",BackupFilename);
			local nError = Application.GetLastError();
			
			Debug.Print("XML.SetValue result: "..nError.." - ".._tblErrorMessages[nError].."\r\n");
			
			AddFoldertoXML(BackupFilename);
			
			bChangesMade = true;
		end
	end
	
	-- Now save the file out
	if(bChangesMade)then
		XML.Save(g_strUninstallXMLFile);
	end
end
  #3  
Old 06-14-2005
csd214 csd214 is offline
Forum Member
 
Join Date: Oct 2001
Location: Norway
Posts: 939
Thanks for the script; for sure, it gave me some ideas.

Allow me to ask, when do you call g_OnFileProcessed(). What values are passed as arguments? Especially I wonder about the ResultCode argument.

Apparently there are some "secrets" (to me) in VP20. I don't want to hardcode new files and folders. Obviously VP20 itself knows what files are successfully patched/backed up.
  #4  
Old 06-14-2005
Lorne's Avatar
Lorne Lorne is offline
Indigo Rose Staff Member
 
Join Date: Feb 2001
Location: Indigo Rose Software
Posts: 2,588
Quote:
Originally Posted by csd214
Allow me to ask, when do you call g_OnFileProcessed(). What values are passed as arguments? Especially I wonder about the ResultCode argument.
Look up g_OnFileProcessed in the help file. (Typing it into the index is probably the quickest way...)
__________________
--[[ Indigo Rose Software Developer ]]
  #5  
Old 06-15-2005
csd214 csd214 is offline
Forum Member
 
Join Date: Oct 2001
Location: Norway
Posts: 939
Thanks, Lorne. I indeed searched the help file; all three tabs. I didn't think of using g_OnFileProcessed as the keyword, because the function is not part of _Global_Functions.lua. I searched for 'result code' (but not 'ResultCode'), got 25 topics, wherein 'Hidden Functions' is found. To all nosy readers, this is exiting: "The following "hidden functions" are available in Visual Patch 2.0: g_OnFileProcessed"

IMHO, the function is a must (personally I'm very focused on a COMPLETE uninstall procedure. (The secret function is needed whatever installer you use).

Quote the help file:
Tip: If you use Setup Factory to build your software installer, you can use actions to add new files to the uninstall control file so they will be removed along with the original files when the user uninstalls your software via the control panel.
It should be to great help if this tip referred to 'Hidden functions' (but the tip is part of the User Guide).

Anyway, the function and Brett's script is a GREAT bonus. It works like a Lamborghini (my car dream). I preferred to check for the uninstall configuration file at an early stage (On Startup), eventually displaying a message like this:

Warning To successfully perform the patch, the %ProductName% configuration file has to be found. We recommend cancelling the execution and contact %CompanyName%.
(Click OK to continue anyway)


In Brett's script (While Patching.On Preload) I replaced the Debug statements with VisualPatch.WriteToLogFile(LogMsg). From SUF70 I have learned to love the write to log feature!

To update the %ProductVer% I added a generic code snippet in On Post Patch (there might be other session variables you want to update too).

If you are interested, my global start-up function and my On Post Patch script can be found in the attached text file.

During a few days I have been devoted to Visual Patch 2.
Attached Files
File Type: txt Uninstall_Update_1.txt (3.8 KB, 12 views)
  #6  
Old 06-16-2005
csd214 csd214 is offline
Forum Member
 
Join Date: Oct 2001
Location: Norway
Posts: 939
Of course, the Warning message should NOT be displayed if the software isn't installed at all. One solution is to modify the suggested global function.

Code:
local sMainFile = "<AppDependentFileName>"		-- a key file

-- -------------------------------------------------- End of App Dependent Paragraph

-- The WARNING message should NOT be displayed if the %ProductName% isn't found at all...
if not File.DoesExist(SessionVar.Expand("%AppFolder%".."\\"..sMainFile)) then
	return;		-- VP is going to display the screen 'Cannot Locate Software'
end
Tip The design-time constants #OLDESTVERSION# and #NEWESTVERSION# are very handy for the 'Cannot Locate Software' screen.
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SUF70 Plug Ins (PopUp Menu) csd214 Setup Factory 7.0 Discussion 1 01-10-2005 12:50 PM
Special Pricing Upgrade Deadline & bonus CD... sferguson AutoPlay Media Studio 5.0 1 11-13-2003 04:13 PM
Limiting the "Number" of Installations garhop Setup Factory 6.0 3 01-31-2002 07:29 PM
Multiple RunTime Installations?? JXBURNS Setup Factory 6.0 3 12-21-2001 09:53 AM


All times are GMT -6. The time now is 02:49 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software