Jump to content
Sign in to follow this  
Fraser

Copy a file that is included in the EXE.

Recommended Posts

Fraser

Hello,

I have been writing an app for work for the past 3 months and I would like to include the install files in the exe.

I have several different functions both for Windows 7 and Windows XP installs with Remote and Local installs for both calling the same install files but putting them in different places!

I have had a look at the Fileinstall function, however it would appear that this function will add the file to the exe more than once if the function is used more than once (as below).

If @OSVersion = "Win_7" Then
FileInstall("..Install FilesProgFilesTESTTEST.DLL", "C:Program Files x86TESTTESTTEST.DLL", 1)
EndIf

If @OSVersion = "Win_XP" Then
FileInstall("..Install FilesProgFilesTESTTEST.DLL", "C:Program FilesTESTTESTTEST.DLL", 1)
EndIf

I noticed that there is also a function in Autoit3wrapper which will add a file, however I’m not too sure how to the call the file when it needs to be copied.

Below is how I have the test script set out:

#region
#AutoIt3Wrapper_Res_File_Add="..Install FilesProgFilesTESTTEST.DLL", File, DW2UK
#endregion

#include <IE.au3>
#include <File.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <ProgressConstants.au3>

DirCreate ("C:Program Files x86TESTTEST")

FileCopy("DW2UK", "C:Program Files x86TESTTESTTEST.DLL", 1)

Any help will be much appreciated.

P.S. Sorry if this is in the wrong place or if someone else has already posted something similar!

Kind Regards,

Fraser

Edited by Fraser

Share this post


Link to post
Share on other sites
abberration

If you don't want a double copy of the file embedded within your exe, you could just fileinstall to @tempdir and then use the if @osversion = "Win_7" then... else if @osversion = "Win_XP" then... to call directly from the single @tempdir location.


RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites
Melba23

Fraser,

Welcome to the AutoIt forum. ;)

it would appear that this function will add the file to the exe more than once if the function is used more than once

And of course it does - as it has no idea which of those 2 conditions will be met at run-time. :)

abberration has the right idea - only I would FileInstall the DLL to @tempdir in all cases and then FileMove it to the correct location depending on the OS: :)

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 Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Fraser

Hello Both,

Why didn't I think of that?

Posted Image

Thank you for both of your speedy replies, I will do as suggested!

Kind Regards,

Fraser

Share this post


Link to post
Share on other sites
Fraser

Hello again,

Just thought i would mention how i'm going to due it!

Due to the way the computers are configured at work (badly), I have created a new function and added the Fileinstall function to it, i'm then going to call it from another function (along the line of below).

#include <IE.au3>
#include <File.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <ProgressConstants.au3>

Global $font = "Arial"

Install_sel()

Func Install_sel()
    $Install_sel_GUI = GUICreate ("Install", 300, 130)

    Opt("GUICoordMode", 3)

    GUISetFont(11, 1000, 0, $font)

    $Ok = GUICtrlCreateButton("OK", 10, 10, 135)
    $exit = GUICtrlCreateButton("EXIT", 50, 40, 200)

    GUISetState(@SW_SHOW)

     While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Ok
                GUIDelete($Install_sel_GUI)
                Install()
                ExitLoop
            Case $msg = $exit
                ExitLoop
        EndSelect
    WEnd
EndFunc

Func Install()

IF @OSVersion = "WIN_7" Then
$Prog_ver = "Program Files (x86)"
ElseIf @OSVersion = "WIN_XP" Then
$Prog_ver = "Program Files"
EndIf

MsgBox(0, "Installing", "Installing")

DirCreate ("C:"& $Prog_ver $ "TESTTEST")
Sleep(2000)

FileInstall("..Install FilesProgFilesTESTTEST1.DLL", "C:" & $Prog_ver & "TESTTESTTEST1.DLL", 1)
FileInstall("..Install FilesProgFilesTESTTEST2.DLL", "C:" & $Prog_ver & "TESTTESTTEST2.DLL", 1)
FileInstall("..Install FilesProgFilesTESTTEST3.properties", "C:" & $Prog_ver & "TESTTESTTEST3.properties", 1)

MsgBox(0, "Installed", "Installed")

EndFunc

Again thank you for taking the time to reply!

Kind Regards,

Fraser

Edited by Fraser

Share this post


Link to post
Share on other sites
Melba23

Fraser,

Glad we could help. ;)

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 Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  

×