Appacker icon indicating copy to clipboard operation
Appacker copied to clipboard

Can't get packed file path

Open drizt opened this issue 3 years ago • 5 comments

In my application I want to know from where it was started. But seems no such info. I checked environment, no success.

drizt avatar Jul 20 '22 10:07 drizt

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

drizt avatar Jul 20 '22 12:07 drizt

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.

SerGreen avatar Jul 22 '22 10:07 SerGreen

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.

drizt avatar Jul 22 '22 17:07 drizt

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.

SerGreen avatar Jul 22 '22 17:07 SerGreen

Thanks!

drizt avatar Jul 22 '22 17:07 drizt