Jump to content

How to use FileInstall()


koresho
 Share

Recommended Posts

I would love to throw a few files into my main executable for distribution, I just can't seem to figure how to use FileInstall().

I have about 600MB worth of programs that need to be included with my script for it to work properly. Right now I have the script on the root, and the programs in @ScriptDir & "\Tools\" and they are handled by executing a self-extracting RAR archive. However if I could bundle it all in the script using FileInstall() and then call the files out that would be awesome.

If that is too much data, I have a couple little batch files I would like to include in the script at least. Any suggestions, maybe a step by step on how to do it? I read the help file but I must be dumb; I can't get it to work.

Thanks in advance.

Link to comment
Share on other sites

I would love to throw a few files into my main executable for distribution, I just can't seem to figure how to use FileInstall().

I have about 600MB worth of programs that need to be included with my script for it to work properly. Right now I have the script on the root, and the programs in @ScriptDir & "\Tools\" and they are handled by executing a self-extracting RAR archive. However if I could bundle it all in the script using FileInstall() and then call the files out that would be awesome.

If that is too much data, I have a couple little batch files I would like to include in the script at least. Any suggestions, maybe a step by step on how to do it? I read the help file but I must be dumb; I can't get it to work.

Thanks in advance.

FileInstall("C:\original\file\location\on\hard\drive\written\out\completely.exe", @scriptdir & "\bin\completely.exe",1)

The first parameter has to be completly written out. NO VARIABLES. NO MACROS.

The second parameter can contain macros or variables.

The third parameter is opitonal.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

I've been working with this one as well, and the problem that I ran into is that you need to create the directory before trying to install anything.

failing Example:

CODE

$return = FileInstall("C:\7za\7z.exe", "C:\7za\")

If $return = 0 Then

MsgBox(0, "file install error 1", "Unable to install 7z.exe")

Exit

EndIf

Successful Example

CODE

DirCreate("c:\7za")

$return = FileInstall("C:\7za\7z.exe", "C:\7za\")

If $return = 0 Then

MsgBox(0, "file install error 1", "Unable to install 7z.exe")

Exit

EndIf

Edited by Kerros

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Link to comment
Share on other sites

  • Moderators

Simple answer:

Yes, but I would have to program it for every damn file, i cant do it for folders or anything right?

http://www.autoitscript.com/forum/index.ph...c=34805&hl=

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Simple answer:

Yes, but I would have to program it for every damn file, i cant do it for folders or anything right?

Zip the files into a self extracting exe, fileinstall it and then run it to create the folder structure.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

  • 9 years later...

"Fileinstall " explanation can be tricky  this  was the clearest info so far, that page did it for me. 

 

fileInstall("C:\original\file\location\on\hard\drive\written\out\completely.exe", @scriptdir & "\bin\completely.exe",1)

once i had the basic working , i was able to use relative path. The key is to  use "dirCreate". i know it;s old however still relevant.

Global $sDestination='c:\Installers\EpsonJavaPosAdk\'
DirCreate($sDestination)

FileInstall(".\DataStorage\copyfile2.exe", $sDestination& "copyfile2.exe", 1);===> Modify this path copyfile2.exe


;~DataStorage is a folder within my script directory where the files i want to copy are located

 

Edited by antonioj84
error
Link to comment
Share on other sites

  • 1 year later...
#include <GUIConstantsEx.au3>
#include <File.au3>


Global $sMyComputerCLSID = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
Global $gsDirData = ""

Global $ghMain = GUICreate('FileInstall Dir', 800, 580)
Global $giOutPut = GUICtrlCreateEdit('', 10, 10, 780, 500)
GUICtrlCreateLabel('Extension:', 20, 518, 50, 20, 0x001)
Global $giExtension = GUICtrlCreateInput('*', 75, 515, 50, 20)
GUICtrlCreateLabel('Ruta de destino:', 130, 518, 90, 20, 0x001)
Global $giDestPath = GUICtrlCreateInput('@TempDir & "\"', 220, 515, 200, 20)
GUICtrlCreateLabel('Flag:', 425, 518, 30, 20, 0x001)
Global $giFlag = GUICtrlCreateCombo('', 455, 515, 40, 300)
GUICtrlSetData($giFlag, '0|1|', '1')
Global $giDirDrive = GUICtrlCreateCheckbox("Camino largo", 500, 515)
Global $giDirRecurse = GUICtrlCreateCheckbox("Dir Recurse", 500, 535)
GUICtrlSetState(-1, $GUI_CHECKED)
Global $giDirHierarchy = GUICtrlCreateCheckbox("Mantener jerarquía", 500, 555)
Global $giGetDir = GUICtrlCreateButton('Buscar carpeta', 110, 545, 150, 30)
Global $giCopyData = GUICtrlCreateButton('Copiar Datos', 320, 545, 150, 30)
GUISetState()
While 1
    Switch GUIGetMsg()
        Case - 3
            Exit
        Case $giGetDir
            $gsDirData = _GetDirData(GUICtrlRead($giExtension), (GUICtrlRead($giDirDrive) <> 1), _
                GUICtrlRead($giDestPath), GUICtrlRead($giFlag), GUICtrlRead($giDirRecurse), _
                GUICtrlRead($giDirHierarchy) = $GUI_CHECKED)
            If Not @error Then
                GUICtrlSetData($giOutPut, '')
                GUICtrlSetData($giOutPut, $gsDirData)
            EndIf
        Case $giCopyData
            ClipPut(GUICtrlRead($giOutPut))
    EndSwitch
WEnd

Func _GetDirData($sExt, $bExcludeLongName, $sDestPath, $nFlag, $nRecursive, $bHierarchy)

    Local $sDir = FileSelectFolder("Select a Directory to FileInstall", $sMyComputerCLSID)
    If @error Then
        Return SetError(1, @extended, "")
    EndIf

    $nRecursive = ($nRecursive = $GUI_CHECKED) ? 1 : 0
    Local $aFiles = _FileListToArrayRec($sDir, "*." & $sExt, 1, $nRecursive, 0, 2)
    If Not IsArray($aFiles) Then
        Return SetError(2, @extended, "")
    EndIf

    Local $sTDrive, $sTDir, $sTFName, $sTExt
    Local $sHold = ""
    _GetExistStr($sDestPath, $sHold)

    Local $sFinstall = ""
    Local $sTmpDest = ""
    Local $sHoldStr = ""

    If $bHierarchy Then
        ; main folder searching
        _PathSplit($sDir, $sTDrive, $sTDir, $sTFName, $sTExt)
        If StringRight(StringRegExpReplace($sDestPath, "[\\/]+\z", ""), _
            StringLen($sTFName)) <> $sTFName Then
            $sTmpDest = StringRegExpReplace($sDestPath, _
                "(\&\s*(?:\x27|\x22)[\\/]+(?:\x27|\x22))", "") & ' & "\' & $sTFName & '\"'
            If Not StringInStr($sHoldStr, $sTDir & @LF) Then
                $sHoldStr &= $sTDir & @LF
                _GetExistStr($sTmpDest, $sHold)
            EndIf
        EndIf
    EndIf

    Local Static $sScrDir = StringRegExpReplace(@ScriptDir, "\\+\z", "")
    For $i = 1 To UBound($aFiles) - 1
        $sTmpDest = $sDestPath

        _PathSplit($aFiles[$i], $sTDrive, $sTDir, $sTFName, $sTExt)

        If $bExcludeLongName Then
            If $sScrDir = StringRegExpReplace($sTDrive & $sTDir, "\\+\z", "") Then
                $aFiles[$i] = $sTFName & $sTExt
            EndIf
        EndIf

        If $bHierarchy Then
            $sTmpDest = StringRegExpReplace($sTmpDest, _
                "(\&\s*(?:\x27|\x22)[\\/]+(?:\x27|\x22))", "") & ' & "' & $sTDir & '"'
            If Not StringInStr($sHoldStr, $sTDir & @LF) Then
                $sHoldStr &= $sTDir & @LF
                _GetExistStr($sTmpDest, $sHold)
            EndIf
        EndIf

        $sFinstall &= "FileInstall(""" & $aFiles[$i] & '", ' & $sTmpDest & ", " & $nFlag & ")" & @CRLF
    Next

    $sHold &= $sFinstall
    $sHold = StringTrimRight($sHold, 2)
    Return $sHold
EndFunc

Func _GetExistStr($sDestPath, ByRef $sOutData)
    $sOutData &= 'If Not FileExists(' & $sDestPath & ') Then' & @CRLF
    $sOutData &= '    Do' & @CRLF
    $sOutData &= '        DirCreate(' & $sDestPath & ')' & @CRLF
    $sOutData &= '    Until FileExists(' & $sDestPath & ')' & @CRLF
    $sOutData &= 'EndIf' & @CRLF
EndFunc

File Install - s04.au3

Edited by Melba23
Added code tags
Link to comment
Share on other sites

  • Moderators

sebastiian,

Is there a question in there somewhere?

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:

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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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