PDA

View Full Version : Loading Software when drive letter is not always static


willdav
01-24-2008, 05:08 PM
im building an AIO suite for work which contains the most frequent apps we install and lots of stand alone diagnostic tools and various others.

One page is called organizer which has a calender, a link to our phone extension database, a stand alone calculator for working out clock cards and finally and this is my problem - a password manager application that stores all of our passwords and door codes we use ..ect under one password, A wallet if you like. Here is an example below:

www.softpedia.com/get/Security/Password-Managers-Generators/My-Wallet.shtml

But, ive tried 3 different types of software which sits in the AutoPlay\\Docs directory, but each one seems to need a home directory if that is the right term in order to store its database. So for example "C:\Documents and Settings\username\My Documents" directory. I cant put it in AutoPlay\\Docs because to the application it is not valid. This is important as my AIO suite will be running off all our engineers portable usb hard drives. Which when hooked up to a pc that we are repairing, doesn't necessarily use the same drive letter because of network drive mappings. The network drives are specific to the department. So basically i need to figure out a way of storing the password database in the AutoPlay\\Docs directory, without the assigned drive letter being a problem.

If anyone is following me is there a feature in APMS that has a solution for this, or know of an alternative piece of software.

thank you :)

TimeSurfer
01-24-2008, 08:05 PM
if the autoplay application you made is in the same directory you could use _SourceFolder which grabs the full path to the directory where the application was ran from, as outlined in the AMS helpfile ;)

so if my app was in C:\Program Files\MyApp

and I put this piece of code in my on startup event for my app.

AppDir = _SourceFolder

it would set the variable AppDir to the full path of the directory where the app was ran from. which is C:\Program Files\MyApp

RizlaUK
01-25-2008, 05:56 AM
look at "_SourceDrive" as well

EDIT:

if you are publishing as web exe neither "_SourceFolder" or "_SourceDrive" will return the path to the usb drive and in fact will return the path or drive of the users system temp folder

if you are useing a web exe you will need to grab the "REAL" path at runtime, the below function will do that for you
function GetRealPath()
if _CommandLineArgs[1]
RealPath = String.Replace(_CommandLineArgs[Table.Count(_CommandLineArgs)], "SFXSOURCE:", "", true);
return RealPath
end
end

mremixer
01-26-2008, 07:07 PM
Quick couple of questions regarding Rizlauk's answer (showing my ignorance here!), specifically

if you are publishing as web exe neither "_SourceFolder" or "_SourceDrive" will return the path to the usb drive and in fact will return the path or drive of the users system temp folder

if you are useing a web exe you will need to grab the "REAL" path at runtime, the below function will do that for you
Code:

function GetRealPath()
if _CommandLineArgs[1]
RealPath = String.Replace(_CommandLineArgs[Table.Count(_CommandLineArgs)], "SFXSOURCE:", "", true);
return RealPath
end
end

A. If you use this doesn't it negate the others? For clarity: :lol By using the above method in all apps means they will always find the "REAL" path, no matter where they are run from i.e. My system, users system, USB, CD, DVD etc..

B. Where exactly in a code would I place it, Global, preload...? (I'm guessing Global!)

Appreciate the info guys, no rush, not expecting to make use of this kind of knowledge yet but purely for reference.

Sorry for the hijack willdav! :D

longedge
01-27-2008, 05:07 AM
Assuming your exe is in the root of a drive then something like this would work for you -

result = Drive.Enumerate();
for index in result do
found_it = File.DoesExist(result[index].."\\Sourcedrive.exe");
if found_it then
actual_drive = result[index]
else
actual_drive = "File not found in root of any drive."
end
end

- Sorry I'm answering a question I thought I saw rather than reading carefully and answering the real question :)

RizlaUK
01-27-2008, 05:09 AM
A. If you use this doesn't it negate the others? For clarity: By using the above method in all apps means they will always find the "REAL" path, no matter where they are run from i.e. My system, users system, USB, CD, DVD etc..

The way it works is:

Web EXE: the project files are packed in to a executable sfx when you build the project so no matter where the sfx is run from it will always unpack and run from the users temp folder, so _SourceFolder will always return the path to the users temp folder in this case

Publish To Folder: this just makes a copy of the project folder structure so in this case _SourceFolder will return the correct path, and the "GetRealPath()" function is not needed.


Here is a edit of the above function which will work in both cases (handy for testing a project that will be in web exe format)

Either way it will return the correct path to the root of the project
function GetRealPath()
if _CommandLineArgs[1] then
RealPath = String.Replace(_CommandLineArgs[Table.Count(_CommandLineArgs)], "SFXSOURCE:", "", true);
RealPathParts=String.SplitPath(RealPath)
return RealPathParts.Drive..RealPathParts.Folder
else
return _SourceFolder
end
end


Example
result = Dialog.Message("Notice", "The Real Path is:\r\n\r\n"..GetRealPath(), MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);