Robin Posted February 18, 2009 Posted February 18, 2009 Is there a way to add files to Autoit before compiling it? ie, let's say i need to overwrite/copy files to a directory...Instead of telling Autoit to find the files and copy it to lets say X directory, I want it to copy files ( that's already enbedded in Autoit ) to a certain directory...What i'm trying to say is, i know in Winrar a person can create a sort off "stand alone" archive with embedded files within... thx guys
bogQ Posted February 18, 2009 Posted February 18, 2009 from help file FileInstall -------------------------------------------------------------------------------- Include and install a file with the compiled script. FileInstall ( "source", "dest" [, flag] ) TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
Robin Posted February 18, 2009 Author Posted February 18, 2009 from help file FileInstall -------------------------------------------------------------------------------- Include and install a file with the compiled script. FileInstall ( "source", "dest" [, flag] )Thanks bogQ...will check it out
Robin Posted February 19, 2009 Author Posted February 19, 2009 (edited) Mmm..Something wrong here i think. I've added this to my Autoit script ---->FileInstall("C:\NTDETECT.COM", "D:\NTDETECT.COM")<--- ...but i get this error ----> "Input file is UTF8 encoded with BOM, Au3Check does not support UNICODE and will be skipped." What i'm basicly trying to do is compile a utility to fix NTLDR-errors ( one of them though ) Here is my script : FileInstall("C:\NTDETECT.COM", "D:\NTDETECT.COM") $VAL1 = ":\" $RETVAL = MsgBox(4, "Fix NTLDR", "Fix NTLDR-Error?") If $RETVAL = 6 Then $VALUE = InputBox("Drive", "Please Enter Root Drive...ie C or D or E", "", " M1") If $VALUE = @error = 0 Then MsgBox(0, "Fix NTLDR", "Aborted...") Else FileCopy("NTDETECT.COM", $VALUE & $VAL1, 1) FileCopy("ntldr", $VALUE & $VAL1, 1) MsgBox(0, "Done!", "Ntdetect.com and ntldr copied to root!") EndIf Else MsgBox(0, "Fix NTLDR", "Aborted...") EndIf Where the hell am i making the balls-up...Its the first time im using "fileinstall" Edited February 19, 2009 by Robin
Moderators Melba23 Posted February 19, 2009 Moderators Posted February 19, 2009 Robin,Some help on the FileInstall function part.Your code at the moment loads NTDETECT.COM from your C:\ root folder when compiled and then, as soon as the .exe is run, installs it to the D:\ root folder. Your later FileCopy("NTDETECT.COM", ....) will only work if you have a copy of NTDETECT.COM in the current folder - which may not be the D:\ root folder. The same is true for ntldr - where is that to be found? Because you are assuming it to be in the current folder at the moment.What you want to do is to get both of them into the root folder as given by the user. So you want to use FileInstall later in your script, along these lines:If MsgBox(4, "Fix NTLDR", "Fix NTLDR-Error?") = 6 Then $Root = InputBox("Drive", "Please Enter Root Drive...ie C or D or E", "", " M1") If @error <> 0 Or FileExists($Root & ":\") = 0 Then MsgBox(0, "Fix NTLDR", "Aborted...") Else FileInstall("C:\NTDETECT.COM", $Root & ":\NTDETECT.COM", 1) <<<<< Installs directly to the user specified root FileCopy("ntldr", $Root & ":\", 1) <<<<< Make sure you specify where ntldr is to be found MsgBox(0, "Done!", "Ntdetect.com and ntldr copied to root!") EndIf Else MsgBox(0, "Fix NTLDR", "Aborted...") EndIfThis way you install NTDETECT.COM directly to the root drive as set by the user. Remember that the "source" must be a literal string (so AutoIt knows where to find it at compile time) but the "dest" can be a variable - as it is here. I have also added a FileExists test to make sure that the user has entered a valid drive - little point in proceeding if there is nowhere to copy to! You might want to add some additional errorchecking to make sure the FileInstall and FileCopy have worked correctly before announcing success. :-)Cannot help with the Au3Check error, sorry.M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Robin Posted February 19, 2009 Author Posted February 19, 2009 Robin, Some help on the FileInstall function part. Your code at the moment loads NTDETECT.COM from your C:\ root folder when compiled and then, as soon as the .exe is run, installs it to the D:\ root folder. Your later FileCopy("NTDETECT.COM", ....) will only work if you have a copy of NTDETECT.COM in the current folder - which may not be the D:\ root folder. The same is true for ntldr - where is that to be found? Because you are assuming it to be in the current folder at the moment. What you want to do is to get both of them into the root folder as given by the user. So you want to use FileInstall later in your script, along these lines:If MsgBox(4, "Fix NTLDR", "Fix NTLDR-Error?") = 6 Then $Root = InputBox("Drive", "Please Enter Root Drive...ie C or D or E", "", " M1") If @error <> 0 Or FileExists($Root & ":\") = 0 Then MsgBox(0, "Fix NTLDR", "Aborted...") Else FileInstall("C:\NTDETECT.COM", $Root & ":\NTDETECT.COM", 1) <<<<< Installs directly to the user specified root FileCopy("ntldr", $Root & ":\", 1) <<<<< Make sure you specify where ntldr is to be found MsgBox(0, "Done!", "Ntdetect.com and ntldr copied to root!") EndIf Else MsgBox(0, "Fix NTLDR", "Aborted...") EndIf This way you install NTDETECT.COM directly to the root drive as set by the user. Remember that the "source" must be a literal string (so AutoIt knows where to find it at compile time) but the "dest" can be a variable - as it is here. I have also added a FileExists test to make sure that the user has entered a valid drive - little point in proceeding if there is nowhere to copy to! You might want to add some additional errorchecking to make sure the FileInstall and FileCopy have worked correctly before announcing success. :-) Cannot help with the Au3Check error, sorry. M23100% correct...At the moment i have my ntldr and ntdetect in the same folder as my script file...Ive tested it and it works 100% ( the person just have to enter which drive they want to copy it to..ie lets say i add this to my BartPE disk ). My prob is adding the 2 files(ntldr and ntdetect) WITHIN the compiled script...( i've never worked with or used "Fileinstall" before ). I usely just used Winrar by adding the 2 files including my compiled script and then just ran it from a TEMP directory... Does this "Fileinstall ADD these 2 files to the script, or are they still stand-alone files? (sorry for this stupid question, just trying to get my facts right) :-)
Moderators Melba23 Posted February 19, 2009 Moderators Posted February 19, 2009 Robin,The only really stupid questions are the ones you never ask!Now I understand a bit better, I see you need 2 FileInstall lines - for both NTDETECT.COM and ntldr. FileInstall stores a copy of the file to install inside the compiled .exe and then installs it into the folder you ask it to. So there is only the ONE compiled .exe file - the other files are hidden inside until the code asks for them to be installed. That is why I put the FileInstall call after the user had defined his root drive.So you need to have:Else FileInstall("NTDETECT.COM", $Root & ":\NTDETECT.COM", 1) FileInstall("ntldr", $Root & ":\ntdlr", 1) MsgBox(0, "Done!", "Ntdetect.com and ntldr copied to root!") EndIfFileInstall will find the 2 files in same folder as the script (as you have stated), add them to the .exe at compile time, and then install them into the user's root drive when the .exe is run. To reinforce the point - you do NOT need to do anything else with the standalone files - copies are stored within the compiled AutoIt .exe thanks to FileInstall. All you have to get onto the other machine is the Autoit .exe itself.Is that clear? Ask again if not.M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Robin Posted February 20, 2009 Author Posted February 20, 2009 (edited) Robin, The only really stupid questions are the ones you never ask! Now I understand a bit better, I see you need 2 FileInstall lines - for both NTDETECT.COM and ntldr. FileInstall stores a copy of the file to install inside the compiled .exe and then installs it into the folder you ask it to. So there is only the ONE compiled .exe file - the other files are hidden inside until the code asks for them to be installed. That is why I put the FileInstall call after the user had defined his root drive. So you need to have:Else FileInstall("NTDETECT.COM", $Root & ":\NTDETECT.COM", 1) FileInstall("ntldr", $Root & ":\ntdlr", 1) MsgBox(0, "Done!", "Ntdetect.com and ntldr copied to root!") EndIf FileInstall will find the 2 files in same folder as the script (as you have stated), add them to the .exe at compile time, and then install them into the user's root drive when the .exe is run. To reinforce the point - you do NOT need to do anything else with the standalone files - copies are stored within the compiled AutoIt .exe thanks to FileInstall. All you have to get onto the other machine is the Autoit .exe itself. Is that clear? Ask again if not. M23Eish man, youre my HERO!..Ive tried it and it works. Basicly ive just chamged my "filecopy" to "Fileinstall" and WHALLA! Thx Melba23...That's exactly what i wanted to know PS: Ive erased the first line (in my script) as it was totaly wrong...lol Edited February 20, 2009 by Robin
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now