PDA

View Full Version : set install path on network by finding unique file


Dane Lamb
02-14-2005, 11:55 AM
We normally apply our software update CDs through a client's PC on a Novell or Windows network system. Our software resides on the server. Our clients have several possible local drive mappings to their server. In SF5.0, I would use a file search variable and search in several priority search paths for a particular file (found under the folder that resides in the root of the install path) , then store that "drive and folder" variable as the 'install to' path. For instance, our path might be f:\apps\hms, or g:\hms, or g:\apps\hms. The file I look for resides in folder 'hms'. Could someone show me what the "On Startup" coding would look like?

Thanks.

Adam
02-15-2005, 01:52 PM
Something like this is a good start:


-- search for the file.
-- NOTE: Found will be nil if the file is not found
Found = File.Find("C:\\MyDir\\", "file.ext", true, false, nil, nil);

-- if a file was found
if Found ~= nil then

-- Break up the result path
FileParts = String.SplitPath(Found[1]);
-- put it back together without the filename since you want the folder that
-- the searched for file resides in.
FolderPath = FileParts.Drive.."\\"..FileParts.Folder;

-- Set the AppFolder to the folder that the file was found in
SessionVar.Set("%AppFolder%",FolderPath);
end



Adam Kapilik

csd214
02-15-2005, 02:54 PM
I had a similar task: To find the executable on a network drive (I had to look for two files in the same directory). A file search on a network drive might be time consuming.

I created (in SUF60) a search process with user interaction:

* Ask the user what network drive to search (network drives in a table)
* Ask the use what directory we should start with (might be the root)
* Perform a recursive search

When the result is found; store the directory in the Registry. Much easier next time!

(I'm going to convert that project to SUF70 later on.)

Dane Lamb
02-15-2005, 04:53 PM
Adam - our software resides on nearly 48 possible drive mappings (but only one mapping for a given customer-so only storing one result). What is the syntax that I could use so that I don't need to create a separate action (approx 48) to cover each path to check? (e.g., c:\apps\hms, c:\hms, d:\hms, d:\apps\hms, etc.)

Unfortunately, user intervention is what I am trying to avoid; many of our users are not terribly computer literate and not certain of their network mapping to our software, which will cause our updates to fail if they guess incorrectly.

Thanks!

Ted Sullivan
02-15-2005, 09:41 PM
The easiest and best route is to store your installation path in the registry or an .ini file during installation. The next time you need to get the info, you can simply read the registry key or .ini file and get your answer right away. Otherwise, you'll have to do a bunch of file searches. I can't think of any way out of it - other than just starting at the root of the drive in the first place. It'll take longer for the user, but it's faster for you...

Dane Lamb
02-16-2005, 08:53 AM
I could easily search several priority search paths in SF5.0 in one operation. Storing the path info in registry or ini is not an option; if stored in the registry, they may use a different workstation to apply subsequent installs; if stored in ini file, it has to be an ini file on the server and I still wouldn't be able to tell the installer a specific drive location to look at.

I am in the Trial stage of evaluating SF7.0. If there isn't a better coding solution, we will remain with SF5.0 for now.

csd214
02-16-2005, 09:22 AM
You certainly can "search several priority search paths in one operation" with SUF70 (if you want). Whatever search engine you are using, the operation might be time consuming on huge network drives. That's why I prefer to offer a partially user interactive search.

BTW, Dealing with a server installed application I recommend my customers to use the same workstation for installation/upgrades. (= use of Registry)

Brett
02-16-2005, 01:14 PM
I could easily search several priority search paths in SF5.0 in one operation. Storing the path info in registry or ini is not an option; if stored in the registry, they may use a different workstation to apply subsequent installs; if stored in ini file, it has to be an ini file on the server and I still wouldn't be able to tell the installer a specific drive location to look at.

I am in the Trial stage of evaluating SF7.0. If there isn't a better coding solution, we will remain with SF5.0 for now.

What about making a function like this:

function FindFolderOnDrives()
tblDrives = Drive.Enumerate();
if(tblDrives)then
for index, strDriveName in tblDrives do
if((Drive.GetType(strDriveName) == DRIVE_FIXED) or (Drive.GetType(strDriveName) == DRIVE_REMOTE))then
local strPath = strDriveName.."hms";
if(Folder.DoesExist(strPath))then
return strPath;
end
strPath = strDriveName.."apps\\hms";
if(Folder.DoesExist(strPath))then
return strPath;
end
end
end
end

return "";
end

Then you can call it and it will check all fixed and remote drives for certain paths. You can expand on the above to do much more as well, but it might provide a good starting point.

- Brett