Indigo Rose Software

Go Back   Indigo Rose Software Forums > Old Versions > Visual Patch 2.0

 
 
Thread Tools Display Modes
  #1  
Old 01-03-2007
wayneh wayneh is offline
Indigo Rose Customer
 
Join Date: Jan 2007
Posts: 10
Grin Let User locate Application Directory???

Hi -

I am evaluating Visual Patch 2.

Is it possible to let the User locate the install/patch directory?

I would like to follow this logic:

1) check the local dir first
2) if not found, check the registry
3) if not found prompt the user to locate the application directory.

Has anyone done something like this?
Can you supply either directions or code?

Thanks.
  #2  
Old 01-05-2007
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 wayneh View Post
Is it possible to let the User locate the install/patch directory?
Yes, definitely. In fact, Visual Patch allows you to completely modify its behaviour through Lua script, so you can make it follow any custom sequence you can think up.

Quote:
I would like to follow this logic:

1) check the local dir first
2) if not found, check the registry
3) if not found prompt the user to locate the application directory.
The first two can be implemented automatically when you start a new project using the project wizard. When you get to the Locate Installed Version step in the wizard, enable the "Current folder" and "Registry key" options. (Disable the "File search" option.) Follow the rest of the project wizard to set up your project however you'd like.

There are a couple different ways you could prompt the user for the application folder: using a Dialog.Input action, or using a Select Folder screen.

Dialog.Input
Using the Dialog.Input action is a bit easier, since you just insert the action in your On Startup script, at the end of the "-- Locate installed version" section (right after the Registry method). Something like this:

Code:
-- Location method: Ask the user
-- Prompt the user for a path
if not g_InstalledVersion then
	local FolderPath = Dialog.Input("Locate Software", SessionVar.Expand("Where is %ProductName% installed?"));
	if FolderPath ~= "CANCEL" then
		g_InstalledVersion = VisualPatch.CheckFolderVersion("%AppFolder%", FolderPath);
		if g_InstalledVersion then
			SessionVar.Set("%AppFolder%", FolderPath);
		end
	end
end
(You could easily modify that code to make it ask for the path in a loop until a recognized folder is provided or the user clicks cancel.)

You can use that dialog method with any interface style...Wizard, Dialog, even Silent if you want (although for silent patches you should really check for a command line argument instead).

Select Folder screen
If you're using a Wizard style install, you'll probably want to use a Select Folder screen. Start by adding the screen to your Before Patching screen list.

In the Select Folder screen, replace the existing On Next script with something like this:

Code:
-- These actions are performed when the Next button is clicked.

local SelectedFolder = SessionVar.Expand("%SelectedFolder%");
local FolderExists = Folder.DoesExist(SelectedFolder);

-- If the folder doesn't exist, ask the user if they want to select a different one
if not FolderExists then
	local Result = Dialog.Message(VisualPatch.GetLocalizedString("MSG_FOLDER_NOT_EXIST_TITLE"), VisualPatch.GetLocalizedString("ERR_FLD_FOLDER_DOES_NOT_EXIST"), MB_RETRYCANCEL, MB_ICONEXCLAMATION);
	
	if (Result == IDRETRY) then
		Application.ExitScript();
	else
		Screen.Next();
	end
end

-- check the provided folder to see if it contains key files
g_InstalledVersion = VisualPatch.CheckFolderVersion("%AppFolder%", SelectedFolder);

--------------------------------------------------------------
-- 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

--------------------------------------------------------------
-- Jump to appropriate screen
--------------------------------------------------------------

if g_InstalledVersion then
	if g_InstalledVersion == VisualPatch.GetTargetVersion() then
		-- The target version was found
		Screen.Jump("Software is Current");
	else
		-- An out-of-date version was found
		Screen.Jump("Ready to Patch");
	end
else
	-- No version was found
	Screen.Jump("Cannot Locate Software");
end
Then modify the On Startup script to display that screen if the first two location methods fail (and skip the rest of the On Startup script). To do that, insert something like this at the end of the "-- Locate installed version" section (right after the Registry method).

Code:
if not g_InstalledVersion then
	Screen.SetStartScreen("Select Folder");
	Application.ExitScript();
end
__________________
--[[ Indigo Rose Software Developer ]]
  #3  
Old 01-05-2007
wayneh wayneh is offline
Indigo Rose Customer
 
Join Date: Jan 2007
Posts: 10
Lorne -

Thanks - I figured out some of the code myself, but I really needed the Application.ExitScript() method.

Now, it works like a champ.
 

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
Setup Factory and VS 2005 vazir786 Setup Factory 7.0 Discussion 4 01-13-2006 09:47 PM
HOWTO: Distribute an AutoPlay Application with Setup Factory 6.0 Support AutoPlay Media Studio 4.0 Examples 0 10-25-2002 03:33 PM
HOWTO: Make an AutoPlay Application Expire Support AutoPlay Media Studio 4.0 Examples 0 10-09-2002 11:10 AM
HOWTO: Prompt the User for Confirmation Before Exiting Support AutoPlay Media Studio 4.0 Examples 0 10-03-2002 10:50 AM
INFO: How to Set the Default Application Directory Support Setup Factory 6.0 Knowledge Base 0 09-25-2002 01:02 PM


All times are GMT -6. The time now is 10:22 PM.


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