Run In zip folder (Windows)

Just starting out? Need help? Post your questions and find answers here.
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Run In zip folder (Windows)

Post by collectordave »

I have an application available to users as a .zip file.

This contains just a single .exe file.

One user has reported that after extracting the zip file the application runs but then disappears after he closes it.

My first thoughts are that he is running the application from within the .zip folder.

Is there anyway to prevent this or check it has been attempted?

Regards

CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Run In zip folder (Windows)

Post by netmaestro »

First thing your app should do is check for the presence of any accompanying files that get expanded with it. If they're not there, show a message and quit.
BERESHEIT
infratec
Always Here
Always Here
Posts: 6883
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Run In zip folder (Windows)

Post by infratec »

Maybe you can check ProgramFilename() against GetTemporaryDirectory()
If windos unzip a file on the fly, it stores it in the temp directory of the user.

Code: Select all

Debug GetTemporaryDirectory()
Debug GetPathPart(ProgramFilename())
Or simply: if the ProgramFilename() contains 'AppData\Local\Temp' than something is wrong.
BarryG
Addict
Addict
Posts: 3330
Joined: Thu Apr 18, 2019 8:17 am

Re: Run In zip folder (Windows)

Post by BarryG »

Different unzipping tools will extract the files into different directories. PeaZip, for example, extracts to the same folder as the zip file (not to the system temp folder), so checking for %TEMP% or %APPDATA% in the path is not going to be reliable.

Netmaestro's answer is the correct solution.
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: Run In zip folder (Windows)

Post by Marc56us »

It also depends on how they received the .zip: if it was attached to an email and they opened it directly, then it disappears when the email is closed.

Advise your users never to work in an archive or in an attachment, but always extract to a folder before use.

:wink:
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Run In zip folder (Windows)

Post by collectordave »

Tried these and the checking for a temp folder seems to work ok.

Maybe best to create a self extracting zip for windows?

Windows and anti virus do seem to moan if you download an EXE file though.

Regards CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
BarryG
Addict
Addict
Posts: 3330
Joined: Thu Apr 18, 2019 8:17 am

Re: Run In zip folder (Windows)

Post by BarryG »

collectordave wrote:Tried these and the checking for a temp folder seems to work ok.
Definitely not for PeaZip. Here's the path returned by PeaZip when running my exe inside it without extraction, when the zip file is on my desktop:

Code: Select all

C:\Users\<name>\Desktop\.ptmp505719\
You don't know which archiver the user will be running at any time, so checking for a temp path is not ideal, and prone to failure.
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Run In zip folder (Windows)

Post by collectordave »

Hi

Yes, just to be sure, I am writing a small install program to download individual files and put them where they belong.

Seems easiest.

CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Post Reply