PDA

View Full Version : Single executable .exe


Stephen G.
10-26-2008, 06:13 PM
Is there a way to get the location of the temp folder the .exe (single file executable) is running from? I need the actual path to the folder it was extracted to at runtime.

Thanks.

RizlaUK
10-26-2008, 06:15 PM
use the variable _SourceFolder, this will point to the temp app folder

Stephen G.
10-26-2008, 06:27 PM
Ha, Ha.... I was so deep into my code, my brain is fried. I couldn't even remember the simplest thing like _SourceFolder. Time to take a break.

Thanks R.

Bags
10-26-2008, 08:31 PM
_SourceFolder is the way to do that yes.

Also, to get the path of a single executable (Web/Email Executable) you'd have to use _CommandLineArgs to achieve that.

The path is always the last table entry in _CommandLineArgs. So something like:

local path = _CommandLineArgs[Table.Count(_CommandLineArgs)];


Would net you the main package path, and _SourceFolder would net you the path to where autorun.exe was extracted and ran from, which is a temp folder as you mention.

Just thought I'd toss that up for anyone wondering about that.

Centauri Soldier
10-27-2008, 08:47 AM
Been trying to figure out how to do that forever and ended up just adding workarounds...but no more. Thanks much for sharing, this will make my life a whole lot easier.

Hey, I have a question too. Is there any way to call relative paths? For example:

sHigherFolder = "..\\".._SourceFolder;

Ideally, this would reference the folder directly above the Source Folder.

RizlaUK
10-27-2008, 10:17 AM
Ideally, this would reference the folder directly above the Source Folder.


here, use this function
function GetParentFolder(strPath)
local sRet=""
if Folder.DoesExist(strPath) then
local sBase=String.Mid(strPath, String.ReverseFind(strPath, "\\") + 1, -1);
local sParent = String.Replace(strPath, "\\"..sBase, "", false);
sRet=sParent
end
return sRet
end


-- Test
Dialog.Message("Test", "Base Folder \r\n".._SourceFolder);
Dialog.Message("Test", "Parent Folder \r\n"..GetParentFolder(_SourceFolder));

Centauri Soldier
10-27-2008, 10:32 AM
Thanks buddy! Works like a charm.:yes