Sign in to follow this  
Followers 0
ricky

Prevent to run in a zip

5 posts in this topic

Hello,

it's possible to prevent a script to run in a zip?

A stupid guy instead of unzip the exe, the guy execute it and the script crash.

It's possible to detect and if the exe is executed from a zip, I want to show an error message and stop it.

Thanks in advance for your help.

Share this post


Link to post
Share on other sites



i'am not sure about this but get the path from running process ?

Share this post


Link to post
Share on other sites

Ricky,

what prevents the script to run properly "from a zip"? Is it some missing files it needs that are also in the zip?

In that case you should check via FileExist() if the file is present in your @scriptDir  and only continue running if all files are present.

It's not possible to execute a program right out of a zip archive, windows is just simulating this by copying the file in some temp dir and running it from there.

That's also the reason why your FileExist() will fail if the user does it that way.

Share this post


Link to post
Share on other sites

Besides it being a really bad practice putting any files directly into C:, how high are chances that a file with the same name does actually exist in the directory if it's a custom script?

Even then, there's no guarantee the file doesn't also exist under C: for some reason.

It's always about paranoid you have to be in relation to how much you think the user can mess with your script.

If you seriously running the risk of having already existing filenames that are none of your files you can always do some checksum on it first.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

To expand upon the earlier answer by Radiance.

When you execute a file within a zip, Windows does a temporary relocation first (of that file only), before executing it. So in that scenario, all other dependencies (other files/folders) will not be relocated, so a simple FileExists test will be your solution.

Good coding practice, includes using FileExists at all points anyway. Never take a file or folder existence for granted. Be judicious though, as once code is running, you only need to test once during the life of the running script ... unless you cause something that makes a file location or existence (etc) change.

Edited by TheSaint
1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0