Jump to content

FileInstall


Recommended Posts

Is there a way to use the FileInstall function or something similar with a variable so that i can create an executable that will

(do the opposite of extract) or extract a file specified by a user?

With the normal fileinstall fuction, the specific file has to be specified BEFORE the script is compiled.

Link to comment
Share on other sites

Is there a way to use the FileInstall function or something similar with a variable so that i can create an executable that will

(do the opposite of extract) or extract a file specified by a user?

With the normal fileinstall fuction, the specific file has to be specified BEFORE the script is compiled.

The SOURCE has to be specified with a literal string, but execution of the function and the DESTINATION can both be specified at run time. Consider this:
Switch MsgBox(32+3, "Install", "Click YES to install FileA, or NO to install FileB")
    Case 2; Cancel
        Exit
    Case 6; Yes
        FileInstall("C:\Install\Files\FileA", @SystemDir & "\FileTarget")
    Case 7; No
        FileInstall("C:\Install\Files\FileB", @SystemDir & "\FileTarget")
EndSwitch

For the file to be installed at Run time, it has to be compressed into the .exe at Compile time. So, how would you know which file(s) to compress and pack into your .exe if the user chose it? All the files you want packed in must be specified up front (at Compile time) with literal strings. But they don't all have to be installed, and the destination can be variable as shown above.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

The source file must be a string and not a variable

Shortly NO!

But there is a way around, if you are so fixed on it you may look into this:

ORIGINAL:

$file = FileOpenDialog('Open the image file', @ScriptDir, 'image (*.mp3;*.jpg;*.bmp;*gif;*.png;*.txt;*.au3;*.exe)', 1)
$file2 = FileSaveDialog('Save the file', @ScriptDir, 'script (*.au3)')
_CheckExt($file2, 'au3')
$var = InputBox('Name variable', 'Prompt the name variable used', '$pic')
_CheckCapital($var, '$')
$hfile = FileOpen($file, 16)
$hfile2 = FileOpen($file2, 2)
FileWrite($hfile2, $var&'="0x"' & @CRLF)
While 1
    $data = FileRead($hfile, 30)
    If @error Then ExitLoop
    FileWrite($hfile2, $var&'&="' & StringTrimLeft($data,2) & '"' & @CRLF)
WEnd
MsgBox(0, 'Done!!', 'Done by Fabry!!!')
Func _CheckExt(ByRef $s_file, $s_ext)
    If StringRight($s_file, StringLen($s_ext)) <> $s_ext Then $s_file &= '.' & $s_ext
EndFunc   ;==>_CheckExt
Func _CheckCapital(ByRef $s_file, $s_cap)
    If StringLeft($s_file, StringLen($s_cap)) <> $s_cap Then $s_file = $s_cap & $s_file
EndFunc   ;==>_CheckExtoÝ÷ Ù
Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
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...