tAKTelapis Posted February 21, 2007 Share Posted February 21, 2007 Hey guys.. I need a way to create a new variable, with a different name.. kinda like what this script LOOKS like it should do: For $x = 1 to 2 $Var&$x = String("test") MsgBox(0, "a", $var1) Next Kinda odd.. the idea is to get a variable to change during a function... the entire script i am working on is on the basis of being able to read its way through an entire list of directories, and get names and directories for all of the files, then produce an auto IT script full of FileInstall statements to completely re-produce the filestructure.. basically, i have found that at least 70 % of applications i have WinWait and SEND based scripts to install, can have there directories copied + pasted and reg keys re-written and work 100% fine. rather than manually create an install script, i figured i would go the whole hog, attempt to produce a script that could create them for me... any feedback / suggestions or logic theories on this are welcome, but for now, this is the one hurdle that seems to be stopping my current train of thought. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 21, 2007 Moderators Share Posted February 21, 2007 2 things.1. Remember that you must use a literal string with FileInstall() for the source.2. You may want to look into arrays, they work well for this issue with far less confusion.In addition, you could look at Eval() and for the FileInstall() you may want to take a look at this: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 More sharing options...
tAKTelapis Posted February 21, 2007 Author Share Posted February 21, 2007 Hmm: 1. I had this in mind, And realised that the _FileListToArray() function doesnt do exactly what i need 2. the idea here is to create several arrays containing the info, hence, the $x.. initial idea was to create $folderarray and $folderarray2 and so on as many as needed, but have the script self produce them.. doesnt seem that will work And, as for the link, it sitll only enumerates the individual files.. i plan to be able to replicate an entire tree without having to do to much manually.. i am testing it on this.. (its a tree /f from a CMD) test │ text.txt │ ├───test1 │ text1.txt │ └───test2 text2.txt I can see a lot of flaws in this now that i have started looking into it.. going to have to leave the scripting pending some more logical thought.. though it is a tool that would be infineately handy. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 21, 2007 Moderators Share Posted February 21, 2007 Hmm:1. I had this in mind, And realised that the _FileListToArray() function doesnt do exactly what i need2. the idea here is to create several arrays containing the info, hence, the $x.. initial idea was to create $folderarray and $folderarray2 and so on as many as needed, but have the script self produce them.. doesnt seem that will workAnd, as for the link, it sitll only enumerates the individual files.. i plan to be able to replicate an entire tree without having to do to much manually..i am testing it on this.. (its a tree /f from a CMD)test│ text.txt│├───test1│ text1.txt│└───test2 text2.txtI can see a lot of flaws in this now that i have started looking into it.. going to have to leave the scripting pending some more logical thought.. though it is a tool that would be infineately handy.Guess I don't see how this can be done with how your explaining it ... considering (as I stated and the help file does) that the source must be a literal string. 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 More sharing options...
SadBunny Posted February 21, 2007 Share Posted February 21, 2007 (edited) I don't see why you would need this var creation thing... Do I understand correctly that your idea is conceptually as follows (semi-code): SEMICODE (obviously :)) -open ghostscript.au3 for output, put some basic code in it ; loop -Read complete path of next file from local filesystem until no files left -Write to .au3 file something like FileInstall("drive:\completepath.abc","drive:\completepath.abc",1) ; /loop -Put some finishing code in ghostscript.au3 -Auto-compile ghostscript.au3 (which you want to include all those files) to an .exe, so you can just run the .exe and watch all the files re-appear? If so, because that's what I understand so far, I do not see why you would need to do something difficult with variables anyway, maybe just a dummy var to store the current completepath within the loop or something. Or am I missing some of your intentions? BTW: If you compile a thusly generated script then you will create a HUMONGOUS executable that has the filesize of ALL captured files + some executable overhead (which would typically be negligable ). So either you need to think this over really well (or implement filtering rules to rule out certain filetpyes or filesizes or something), OR I am not getting your idea :-) /edit: spiced up the way this post looks Edited February 21, 2007 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Shevilie Posted February 21, 2007 Share Posted February 21, 2007 Well you can make another autoitstring to write it for you in scite ... Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
SadBunny Posted February 21, 2007 Share Posted February 21, 2007 Cool! Layered autographic self-generating scripts... Sounds really 007 Still I wonder wether I got his/hers intentions right... Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
tAKTelapis Posted February 22, 2007 Author Share Posted February 22, 2007 Yes, you got my intentions correct.. to wrap all files inside a directory into a single EXE file, with the intent of that exe file being ran by users if they wish to have that piece of software... kind of a cheapend version of a ghost AI package.. but much easier to create (NSIS does this only i dont know its code layout) by the way, found a MUCH easier way to get the directory listings.. dir /b /s >>c:\temp\filelist.txt will list the COMPLETE path to EVERY file all subfolders included and outputs each to the next line of the file specified.. i can run this from withing the autoIT script and use FileReadLine to read in each line, and then hav auto IT spurl it back out into a .au3 which it will then compile of course, i wll have a GUI that allows the user to set options, such as the directory to package up, the directory to unpack it all to, and script name etc etc.. Cant wait to get down to coding now that i have something as a "proof of concept" to my theorising on the applications function. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 22, 2007 Moderators Share Posted February 22, 2007 NSIS does this only i dont know its code layout)http://nsis.sourceforge.net/Development_Files 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 More sharing options...
tAKTelapis Posted February 22, 2007 Author Share Posted February 22, 2007 Hmm.. let me re-phrase that.. i understand most of autoIT, so it is a lot easier to just stick with what i know. Will get back to this thread with an "alpha" when i have done some coding. Link to comment Share on other sites More sharing options...
SadBunny Posted February 22, 2007 Share Posted February 22, 2007 Hmm.. let me re-phrase that..i understand most of autoIT, so it is a lot easier to just stick with what i know.Will get back to this thread with an "alpha" when i have done some coding.Good luck anyway! Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
tAKTelapis Posted February 22, 2007 Author Share Posted February 22, 2007 Here we go. Proof of concept script. Will ask you to browse to the directory you want. and leave a file called WrappedInstallFile.au3 in C:\TEMP\ Doesnt do any of the extra fancy bits yet, i just needed to get the basics down pat. Things i plan to do: - Doesnt currently have a file size limitation, it will litterally attempt to wrap up your entire C: drive if you let it.. so be careful. - a GUI allowing you to configure a few options - option in said gui to allow a GUI to be a part of the installer, letting the person running the script choose a destination dir' - Ability to include a Reg file to be ran. expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.2.0 Author: tAK Script Function: Automatically Create AutoIT v3 script containing FileInstall details for Entire directory Tree #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <file.au3> #include <Array.au3> Dim $a_FilesToInstall $au3ScriptFile = FileOpen("C:\TEMP\WrappedInstallFile.au3", 10) $BatFile = FileOpen("C:\TEMP\GetDir_Batfile.bat", 10) $Folder = FileSelectFolder("", "") $Drive = StringLeft($Folder, 2) FileWriteLine($BatFile, "@ECHO OFF") FileWriteLine($BatFile, "CD "&'"'&$Folder&'"') FileWriteLine($BatFile, $Drive) FileWriteLine($BatFile, "Dir /b /s >>C:\TEMP\FilesToInstall") FileWriteLine($BatFile, "exit") FileClose($BatFile) RunWait("C:\TEMP\GetDir_Batfile.bat", "", @SW_HIDE) FileDelete("C:\TEMP\GetDir_Batfile.bat") _FileReadToArray("C:\TEMP\FilesToInstall", $a_FilesToInstall) _ArrayDisplay($a_FilesToInstall, "a_FilesToInstall") FileDelete("C:\TEMP\FilesToInstall") $x = 1 For $x = 1 to $a_FilesToInstall[0] - 1 $IsNotAFolder = FileGetAttrib($a_FilesToInstall[$x]) If StringInStr("D", $IsNotAFolder, 0) >= 1 Then FileWriteLine($au3ScriptFile, 'DirCreate("'&$a_FilesToInstall[$x]&'")') ContinueLoop Else FileWriteLine($au3ScriptFile, 'FileInstall("'&$a_FilesToInstall[$x]&'", "'&$a_FilesToInstall[$x]&'", 1)') EndIf Next FileClose($au3ScriptFile) Exit Link to comment Share on other sites More sharing options...
SadBunny Posted February 22, 2007 Share Posted February 22, 2007 Two things:1) Why do you take the trouble of writing a whole batchfile when you can just Run() the dir command?2) The If StringInStr("D", $IsNotAFolder, 0) >= 1 Then can also be written as If StringInStr("D", $IsNotAFolder, 0) Then (just so you know...) Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
tAKTelapis Posted February 22, 2007 Author Share Posted February 22, 2007 1) Well, i couldnt quite get the string to run as a Run() or _RunDos() command, i will revist that later, i ended up creating a batch file that worked, and transporting it into the au3 script as a file to be generated. it worked at the time, and it still works now, though it is something that has to be fixed. 2) took me a minute to understand the logic behind what you said here, but it does make sense.. might consider correcting it. Link to comment Share on other sites More sharing options...
SadBunny Posted February 22, 2007 Share Posted February 22, 2007 (edited) 1) Well, i couldnt quite get the string to run as a Run() or _RunDos() command, i will revist that later, i ended up creating a batch file that worked, and transporting it into the au3 script as a file to be generated. it worked at the time, and it still works now, though it is something that has to be fixed.Doing it in a Run() is VERY easy, and saves you lots of work. I removed everything that had anything to do with batchfiles, including the unneccesary $drive, and put this in instead: ]Run(@ComSpec&" /c dir "&$Folder&" /B /S >>C:\TEMP\FilesToInstall", "", @SW_HIDE) ... saving you 10 lines of code, does EXACTLY the same (tested it) (/edit: $x = 1 went out, it is already properly defined by the For) (/edit 2: Changed Run into RunWait, error on my part, Run gives unreliable results ) (/edit 3: Changed the dir statement above to match what I put in the code, which does actually work, damn it must be late... Look who's talking about structure ) expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.2.0 Author: tAK Script Function: Automatically Create AutoIT v3 script containing FileInstall details for Entire directory Tree #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <file.au3> #include <Array.au3> Dim $a_FilesToInstall $au3ScriptFile = FileOpen("C:\TEMP\WrappedInstallFile.au3", 10) $Folder = FileSelectFolder("", "") RunWait(@ComSpec&" /c dir "&$Folder&" /B /S >>C:\TEMP\FilesToInstall", "", @SW_HIDE) _FileReadToArray("C:\TEMP\FilesToInstall", $a_FilesToInstall) _ArrayDisplay($a_FilesToInstall, "a_FilesToInstall") FileDelete("C:\TEMP\FilesToInstall") For $x = 1 to $a_FilesToInstall[0] - 1 $IsNotAFolder = FileGetAttrib($a_FilesToInstall[$x]) If StringInStr("D", $IsNotAFolder, 0) >= 1 Then FileWriteLine($au3ScriptFile, 'DirCreate("'&$a_FilesToInstall[$x]&'")') ContinueLoop Else FileWriteLine($au3ScriptFile, 'FileInstall("'&$a_FilesToInstall[$x]&'", "'&$a_FilesToInstall[$x]&'", 1)') EndIf Next FileClose($au3ScriptFile) Exit 2) took me a minute to understand the logic behind what you said here, but it does make sense.. might consider correcting it.Nice. You need to keep things as simple as possible; this makes code reading and debugging oh so very much easier in big scripts... Much of these unnecessary double checks both cost extra brain clock cycles and extra cpu clock cycles One more thing: you could even easily avoid having to create the FilesToInstall at all (using dummy files for lists when you can do it directly should be avoided for better style, I like to think), by just reading the standard output from the dir command right into the array, using StdoutRead. Just a suggestion Edited February 22, 2007 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Sundance Posted February 23, 2007 Share Posted February 23, 2007 Hiho, have a look at Altiris SVS. It can virtualize software packages. You can record a software package an then export it and import it to another pc if you want. greets Sundance PS: currently i'am writing some AutoIt UDF's for SVS to admin the virtualized software packages Link to comment Share on other sites More sharing options...
The Kandie Man Posted February 23, 2007 Share Posted February 23, 2007 I wrote a script that does this a while back:http://www.autoitscript.com/forum/index.ph...st&p=289208 "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
Reaper HGN Posted February 23, 2007 Share Posted February 23, 2007 I wrote a script that does this a while back:http://www.autoitscript.com/forum/index.ph...st&p=289208As far as I know, there is not really any concept of a Hash in Autoit. However, it seems like you could get close to what you want by using multi dimensional arrays. Basically a variable "test" "1" with a value can be defined in the structure of a 2 dimensional array. Am I missing the point of the question here? It seems like writing an entirely new file or bothering with writing out lines containing dynamic variable names is huge overkill. Link to comment Share on other sites More sharing options...
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