Can't get packed file path
In my application I want to know from where it was started. But seems no such info. I checked environment, no success.
For myself I use this patch.
diff --git a/UnpackerSharedProject/Unpacker Program.cs b/UnpackerSharedProject/Unpacker Program.cs
index a191a58..19bacdd 100644
--- a/UnpackerSharedProject/Unpacker Program.cs
+++ b/UnpackerSharedProject/Unpacker Program.cs
@@ -228,6 +228,9 @@ namespace Unpacker
WorkingDirectory = tempDir,
UseShellExecute = !stdoutRedirected // if stdout is redirected, then redirect i/o of the target app too
};
+
+ procInfo.EnvironmentVariables["APPACKER_EXE_PATH"] = selfExePath;
+
Process proc = Process.Start(procInfo);
// Wait until app exits to delete its files from temp directory
Hm, yes, there doesn't seem to be a way for the target application to get the location of the package file.
I'm not familiar with environment variables though. Does this:
procInfo.EnvironmentVariables["APPACKER_EXE_PATH"] = selfExePath;
create a permanent system variable (like PATH) that stays even after an application is closed or is it only accessible while an application is running?
I'd like not to create any footprint in the system if possible. If it's not a permanent system variable then i can just apply your patch.
I'm not familiar with C# and Window$. But docs says A string dictionary that provides environment variables that apply to this process and child processes.
I see! It seems that it's a temporary variable after all. There's a remark regarding UseShellExecute being required to be false, however, and it may be true for Appacker in some cases. I'll take a look what can be done.
Thanks!