PDA

View Full Version : VisualPatch.CheckFolderVersion fails


tigran
09-07-2007, 11:46 AM
Hi.

I can't make my patch work because VisualPatch.CheckFolderVersion fails on me.
The patch contains two versions (1.0 & 1.1) is was built by using a wizard.

I checked and rechecked the following:

- version 1.0 and its key file already installed on machine
- the registry key / value specified in patch to located installed version actually exist on target machine and point correctly to installed version executable (key file)
- compared MD5 values of key file for 1.0 in patch to MD5 of already installed version of executable to make sure they are the same

I still can't make it work because VisualPatch.CheckFolderVersion returns nil!

I even tried to supply hard coded application path to the function, to no avail.

The application is installed in C:\Program Files\MyCompany\MyProduct
I'm using the latest version of Visual Patch 3.0

Please help!

Lorne
09-07-2007, 12:33 PM
Can you post your script so we can see exactly what it does?

Does the patch succeed if you copy it into the application folder and run it from there?

tigran
09-07-2007, 01:26 PM
Below is the code for locating the application using registry/current folder.
The code correctly retrieves accurate path from registry and current folder; however, VisualPatch.CheckFolderVersion() fails in both places.

I copied the patch in the AppFolder and manually ran it.
Here is the script excerpt from OnStartup:

--------------------------------------------------------------
-- 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("%AppFolder%", _SourceFolder);
if g_InstalledVersion then
SessionVar.Set("%AppFolder%", _SourceFolder);
end
end

-- Location method: Registry key
-- Read a folder path from the Registry.
if not g_InstalledVersion then
local MainKey = HKEY_LOCAL_MACHINE;
local SubKey = SessionVar.Expand("Software\\MyCompany\\MyApp");
local ValueName = "Program Directory";
local FolderPath = Registry.GetValue(MainKey, SubKey, ValueName);
g_InstalledVersion = VisualPatch.CheckFolderVersion("%AppFolder%", FolderPath);
if g_InstalledVersion then
SessionVar.Set("%AppFolder%", FolderPath);
end
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("MyApp.exe");
local ProgramName = SessionVar.Expand("MyApp");
-- (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

Lorne
09-07-2007, 02:14 PM
What are the source and destination paths set to in the design environment for your key files in version 1.0 and 1.1?

tigran
09-07-2007, 02:24 PM
Lorne,

your question pointed me to the right direction which allowed me to fix the problem. When I specified the 1.1 version using a Wizard, it mirrored my source location and inserted a destination location as %AppFolder%\subfolder\MyApp.exe

This forced the patch to look for MyApp.exe in the subfolder instead of %AppFolder%

I changed the destination path of MyApp.exe to %AppFolder% and everything worked fine!

Thanks!