Patch stating software current when it's not.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • ReconADA
    Forum Member
    • Mar 2007
    • 13

    Patch stating software current when it's not.

    I'm trying to keep this simple and I'm using VP 2.0 to patch version 1.1 to version 1.1.1 of my software. The patch is returning that the current version is already installed when it's clearly not. The installed version is 1.1 on the system but the patch is saying that version 1.1.1 is installed.

    What am I doing wrong?

    Here's the code I have:
    Code:
    --------------------------------------------------------------
    -- Check for administrative privileges
    --------------------------------------------------------------
    
    -- Make sure that the user has administrative privileges on the system.
    -- (g_IsUserAdmin is defined in _Global_Functions.lua)
    if not g_IsUserAdmin() then
    	if not _SilentPatch then
    		local Title = SessionVar.Expand("%WindowTitle%");
    		local Message = SessionVar.Expand(VisualPatch.GetLocalizedString("MSG_SYSREQ_ADMIN"));
    		local DlgResult = Dialog.Message(Title, Message, MB_OKCANCEL, MB_ICONEXCLAMATION);
    		if DlgResult == IDCANCEL then
    			Application.Exit(EXIT_REASON_USER_NOT_ADMIN);
    		end
    	else
    		-- Since it is a silent patch, fail
    		Application.Exit(EXIT_REASON_USER_NOT_ADMIN);
    	end
    end
    
    --------------------------------------------------------------
    -- Locate installed version
    --------------------------------------------------------------
    
    -- Define a global variable that will indicate the name
    -- of the installed version on the user's system. A nil value
    -- indicates that an installed version has not been found.
    g_InstalledVersion = nil;
    
    -- Location method: Current folder
    -- Check whether the software is installed in the folder
    -- that the patch was run from.
    if not g_InstalledVersion then
    	g_InstalledVersion = VisualPatch.CheckFolderVersion("%ProgramFilesFolder%\\%CompanyName%\\%ProductName%", _SourceFolder);
    	if g_InstalledVersion then
    		SessionVar.Set("%AppFolder%", _SourceFolder);
    	end
    end
    Dialog.Message("%AppFolder% contains:", SessionVar.Expand("%AppFolder%"));
    -- Location method: Registry key
    -- Read a folder path from the Registry.
    -- Remove the following block comment to enable this script
    --[[
    if not g_InstalledVersion then
    	local MainKey = HKEY_CURRENT_USER;
    	local SubKey = SessionVar.Expand("Software\\%CompanyName%\\%ProductName%");
    	local ValueName = "InstallFolder";
    	local FolderPath = Registry.GetValue(MainKey, SubKey, ValueName);
    	g_InstalledVersion = VisualPatch.CheckFolderVersion("%AppFolder%", FolderPath);
    	if g_InstalledVersion then
    		SessionVar.Set("%AppFolder%", FolderPath);
    	end
    end
    ]]
    
    -- Location method: File search
    -- Search the user's system for a file that is known to
    -- exist in the software's application folder.
    -- Remove the following block comment to enable this script
    --[[
    if not g_InstalledVersion then
    	local TargetFileName = "Award Quick.exe";
    	local tbFolders = {};
    	tbFolders[1] = SessionVar.Expand("%ProgramFilesFolder%\\Army Counseling Online\\Award Quick");
    --	tbFolders[2] = SessionVar.Expand("%ProgramFilesFolder%\\%CompanyName%");
    --	tbFolders[3] = SessionVar.Expand("%ProgramFilesFolder%\\%CompanyName%\\%ProductName%");
    	-- Insert other folders here...
    
    	local CheckFixedDrives = true;
    	local CheckNetworkDrives = false;
    
    	-- (g_FindApplicationOnSystem is defined in _Global_Functions.lua)
    	g_InstalledVersion = g_FindApplicationOnSystem("%AppFolder%", TargetFileName, tbFolders, CheckFixedDrives, CheckNetworkDrives);
    end
    ]]
    
    --------------------------------------------------------------
    -- Ensure that installed software is not running
    --------------------------------------------------------------
    
    -- If we located an out-of-date version, make sure the installed
    -- software is not running.
    if g_InstalledVersion then
    	local Filename = SessionVar.Expand("Award Quick.exe");
    	local ProgramName = SessionVar.Expand("Award Quick");
    	-- (g_EnsureProgramIsClosed is defined in _Global_Functions.lua)
    	local ProgramIsClosed = g_EnsureProgramIsClosed(Filename, ProgramName);
    	if not ProgramIsClosed then
    		Application.Exit(EXIT_REASON_PROGRAM_IS_OPEN);
    	end
    end
    
    --------------------------------------------------------------
    -- Set session variables
    --------------------------------------------------------------
    
    -- Set session variables that will be used in the log file
    -- and in the user interface.
    if g_InstalledVersion then
    	SessionVar.Set("%InstalledVersion%", g_InstalledVersion);
    	SessionVar.Set("%TargetVersion%", VisualPatch.GetTargetVersion());
    end
    
    --------------------------------------------------------------
    -- Log result
    --------------------------------------------------------------
    
    -- Make a log file entry with the result.
    if g_InstalledVersion then
    	local LogMsg = SessionVar.Expand("Success\tLocated installed version %InstalledVersion%: %AppFolder%\r\n");
    	VisualPatch.WriteToLogFile(LogMsg);
    else
    	local LogMsg = SessionVar.Expand("Error\tCould not locate software on system\r\n");
    	VisualPatch.WriteToLogFile(LogMsg);
    end
    
    --------------------------------------------------------------
    -- Select start screen
    --------------------------------------------------------------
    
    -- Decide which "Before Patching" screen to show.
    if g_InstalledVersion then
    	if g_InstalledVersion == VisualPatch.GetTargetVersion() then
    		-- The target version was found
    		Screen.SetStartScreen("Software is Current");
    	else
    		-- An out-of-date version was found
    		Screen.SetStartScreen("Ready to Patch");
    	end
    else
    	-- No version was found
    	Screen.SetStartScreen("Cannot Locate Software");
    end
    Here is the log txt:
    [11/27/2007 08:44:47] Success Patch started: C:\Program Files\Army Counseling Online\Award Quick\AQpatch.exe
    [11/27/2007 08:44:47] Notice Patch engine version: 2.0.4.0
    [11/27/2007 08:44:47] Notice Product: Award Quick
    [11/27/2007 08:44:47] Success Language set: Primary = 9, Secondary = 1
    [11/27/2007 08:44:47] Success Include script: _Global_Functions.lua
    [11/27/2007 08:44:47] Notice Start project event: Global Functions
    [11/27/2007 08:44:47] Success Run project event: Global Functions
    [11/27/2007 08:44:47] Notice Start project event: On Startup
    [11/27/2007 08:44:54] Success Located installed version 1.1.1: C:\Program Files\Army Counseling Online\Award Quick
    [11/27/2007 08:44:54] Success Run project event: On Startup
    [11/27/2007 08:44:54] Success Display screen: Software is Current
    [11/27/2007 08:44:58] Success Delete image file: C:\Users\Steve\AppData\Local\Temp\_ir_vp2_temp_0\I RIMG1.JPG
    [11/27/2007 08:44:58] Success Delete image file: C:\Users\Steve\AppData\Local\Temp\_ir_vp2_temp_0\I RIMG2.JPG
    [11/27/2007 08:44:58] Success Delete image file: C:\Users\Steve\AppData\Local\Temp\_ir_vp2_temp_0\I RIMG3.JPG
    [11/27/2007 08:44:58] Notice Exit patch process (Return code: 1240)
  • ReconADA
    Forum Member
    • Mar 2007
    • 13

    #2
    %AppFolder% is where?

    I've noticed the default VisualPatch.CheckFolderVersion as provided by the wizard to locate and assign the %AppFolder% variable but it doesn't work. It's showing results for %AppFolder% as %AppFolder%. Any thoughts?

    Code:
    -- Define a global variable that will indicate the name
    -- of the installed version on the user's system. A nil value
    -- indicates that an installed version has not been found.
    g_InstalledVersion = nil;
    
    -- Location method: Current folder
    -- Check whether the software is installed in the folder
    -- that the patch was run from.
    if not g_InstalledVersion then
        g_InstalledVersion = VisualPatch.CheckFolderVersion("%AppFolder%", _SourceFolder);
        if g_InstalledVersion then
            SessionVar.Set("%AppFolder%", _SourceFolder);
        end
    end

    Comment

    • Lorne
      Indigo Rose Staff Member
      • Feb 2001
      • 2729

      #3
      Originally posted by ReconADA View Post
      I've noticed the default VisualPatch.CheckFolderVersion as provided by the wizard to locate and assign the %AppFolder% variable but it doesn't work. It's showing results for %AppFolder% as %AppFolder%. Any thoughts?
      Hmmm. By "showing results for" you mean that %AppFolder% expands to "%AppFolder%," correct?

      This line in your code stands out a bit:

      Code:
      -- Location method: Current folder
      -- Check whether the software is installed in the folder
      -- that the patch was run from.
      if not g_InstalledVersion then
      	[b][COLOR="DarkRed"]g_InstalledVersion = VisualPatch.CheckFolderVersion("%ProgramFilesFolder%\\%CompanyName%\\%ProductName%", _SourceFolder);[/COLOR][/b]
      	if g_InstalledVersion then
      		SessionVar.Set("%AppFolder%", _SourceFolder);
      	end
      end
      Do all of the key files in your project have "%ProgramFilesFolder%\\%CompanyName%\\%ProductName %" in their destination paths? It could be that your destination paths are incorrect, or your version identification depends on one or more key files that have a different path.

      (See the help topic for the CheckFolderVersion action.)

      What destination paths do your key files have?

      Do your key files contain different data between those two versions, so the patch can tell them apart by their MD5 values?

      Another thing to check is the order your version tabs are listed in your project. (The newest version is assumed to be the one on the far right.)

      BTW, it doesn't hurt to verify the key files you have on your build system and on the target system. Use a tool like fsum to check the MD5 values. (You would be surprised how often people are mistaken when they're certain which version is installed. It isn't that hard to lose your place a bit when testing patches.)
      --[[ Indigo Rose Software Developer ]]

      Comment

      Working...
      X