Jump to content

FileInstall to copy directory


Go to solution Solved by orbs,

Recommended Posts

Posted

Hi Experts,

I'm new born to AutoIT so forgive me if it is too simple,

I was creating a simple GUI using AutoIT to excute a bat file. Basically this is how it works

I have few setupfiles, reg keys and ini files in a folder ( also has sub folders ) , 3 bat files each with different switches to perform certain task.

I'm trying to create a .exe file which should contain the complete folder ( and its subfolder ) . Exe should include the "Source" folder and copy it to "temp" folder when i run the exe.

I tried fileinstall but unfortunately it copies only one file and not the folder ( if i'm not wrong ). Tried filecopy, Dircopy but these commands dont embed files to exe.

Please assist.

  • Solution
Posted

hello and welcome to AutoIt and the forum,

this is how i did it: using 7zip (freeware and open source) i distribute a group of auxiliary files with my script.

in the script folder, i put files 7z.exe & 7z.dll

i put all auxiliary files in a subfolder named AuxFiles

before compile, i create a 7zip archive, like this: (DOS command)

7z.exe a AuxFiles.7z AuxFiles*

and this is the part of the script:

; declare variables
Global $sTempPath=@TempDir&'\MyScript_files\'
Global $sTempPath_program=$sTempPath&'program\'
; embed/extract the 7zip program files and the archive to be extracted
DirCreate($sTempPath)
FileInstall('AuxFiles.7z',$sTempPath,1)
FileInstall('7z.exe',$sTempPath,1)
FileInstall('7z.dll',$sTempPath,1)
; extract the archive
DirCreate($sTempPath_program)
RunWait($sTempPath&'7z.exe x AuxFiles.7z -o"'&$sTempPath_program&'" -aoa',$sTempPath,@SW_HIDE)

for better performance you can eliminate the 7z.exe and use the 7z.dll directly, use the 7zip UDF here:

'?do=embed' frameborder='0' data-embedContent>>

also there is a pure AutoIt archiving instead of 7zip, here:

'?do=embed' frameborder='0' data-embedContent>>

try it out, let us know if you need further guidance.

Signature - my forum contributions:

  Reveal hidden contents

 

  • Moderators
Posted

Beli,

You can only FileInstall individual files into an existing folder, so I would first create a suitable tree within the "temp" folder with DirCreate before Fileinstalling each of the files that you wish copy into the relevant folders. A bit more code for you to write, but this approach has worked for me in the past. :)

M23.

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

Yeah, just about to mention this too.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Thanks to One and all, to be frank I dint even know about AutoIT scripting. Recently i tried to create a simple GUI front end for help  desk guys, when I googled it led me directly to AutoIT.

This completely changed the way I look at scripts now. 

Also, I was not expecting these many response in such a short time, thank you everyone... You guys Rock.

Regarding the script, 7z.exe does a great job, easy way to copy folder. However is there a way to use something built-in windows component to create Zip (I know Universalist shared the link for that, but it was way to complicated for beginner like me)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...