Sign in to follow this  
Followers 0
ReconX

FileInstall & FileCopy Help

7 posts in this topic

I am using "FileInstall" & "FileCopy". Everytime I execute the script, it adds the "bgimage.jpg" to the place the script is located and the Temp Directory. Here is the code.

If Not FileExists(@ScriptDir & "\bgimage.jpg") Then FileInstall("C:\Users\Marc\Desktop\FixIt Script\Images\bgimage.jpg", @ScriptDir & "\", 1)
FileCopy(@ScriptDir & "\bgimage.jpg", @TempDir, 1)

I want it to only display in the Temp Directory instead of the source location of the script. Thanks in advanced. :)

Share this post


Link to post
Share on other sites



I want it to only display in the Temp Directory instead of the source location of the script. Thanks in advanced. :)

 

and why would this not work?

If Not FileExists(@TempDir & "\bgimage.jpg") Then FileInstall("C:\Users\Marc\Desktop\FixIt Script\Images\bgimage.jpg", @TempDir & "\", 1)

Share this post


Link to post
Share on other sites

I may have worded that wrong. LOL

After doing some research, I came to the conclusion, but I could be wrong, that using the "FileInstall" in this context:

If Not FileExists(@ScriptDir & "\bgimage.jpg") Then FileInstall("C:\Users\Marc\Desktop\FixIt Script\Images\bgimage.jpg", @ScriptDir & "\", 1)

would copy the file into the compiled script, that way having access to it on whatever computer I run the compiled EXE on.

And that using "FileCopy" in this context:

FileCopy(@ScriptDir & "\bgimage.jpg", @TempDir, 1)

would copy it out of the compiled EXE, to the Temp Directory so that the program could use it.

My problem is, that when you run the EXE, it copies the "bgimage.jpg" to the same directory of the EXE, the Desktop, and the Temp Directory. I only want the "bgimage.jpg" to appear in the Temp Directory.

Share this post


Link to post
Share on other sites

i believe you misunderstand FileInstall(). you do not need to FileInstall() into the script directory in order to have it available anywhere.

when you compile your script to exe, FileInstall() embeds your file into the exe - using only the 1st parameter.

when you run the exe, FileInstall() extracts the embedded file - using only the 2nd parameter.

and it is a bad practice to FileInstall() to the @ScriptDir because someone may launch the exe from a read-only directory, where FileInstall() cannot extract the file. @TempDir is always usable.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

i believe you misunderstand FileInstall(). you do not need to FileInstall() into the script directory in order to have it available anywhere.

when you compile your script to exe, FileInstall() embeds your file into the exe - using only the 1st parameter.

when you run the exe, FileInstall() extracts the embedded file - using only the 2nd parameter.

and it is a bad practice to FileInstall() to the @ScriptDir because someone may launch the exe from a read-only directory, where FileInstall() cannot extract the file. @TempDir is always usable.

 

Thanks, I understand it now. Basically, 

FileInstall("The location of the file that you want to add to the compile.", @TheDirTheExePutsTheFileToUse & "\SAME")

What is the best way that you would suggest to compile the file, such as a background, to the compiled script to avoid running into the Read-only problem?

Edited by ReconX

Share this post


Link to post
Share on other sites

What is the best way that you would suggest to compile the file, such as a background, to the compiled script to avoid running into the Read-only problem?

 

extract to one of the following:

@TempDir
@LocalAppDataDir

@TempDir may get cleaned-up every now and then, so @LocalAppDataDir is preferred. in any case, better create a subfolder.

Share this post


Link to post
Share on other sites

Thank you for all of your help. :)

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