jbs123 Posted August 14, 2007 Share Posted August 14, 2007 Hey all, I would have put this in the example scripts but I don't have permission to start a new topic for some reason. Anyways, I didn't do much work at all on this. (AutoIT3 noob) I wanted to give a big thanks to MHZ, ACalcut, and others for the wonderful work they have done to help me accomplish this task I have. So here is what I am trying to accomplish. The ability to search a folder for applications and automatically install them if they have a silent installer. Monitor all changes to the OS and reports changes to a MySQL db. I would run the script in start-up on a clean Virtual OS. (So when it boots, it starts everything off and at the end, shutsdown)So heres how I have almost accomplished this and if possible can you experts help me out and tell me what is wrong (besides the fact I don't know autoit ?1) Search a Remote Folder for an application that hasn't been installed. (Still working)2) Identity installer and if successful create initial snapshot. (I just need to merge MHZ,'s code and ACalcut's together somehow)3) DUmp registry and compare. ( I could do this with ACalcut script, I just need help in making it work at the same time the initial snapshot is going on.)4) Import results into a MySQL db. (I will post the code that I have, it inst working yet)5) Export results to the remote folder so when it searches on step one it will know if its installed or not.I have attached the .bat files (both are zipped up since I can't upload .bat) that I made that go with the installation monitor script (ACalcut's) and you can find Jacksum the java app I am using to scrape the hard drive and hash the files here http://www.jonelo.de/java/jacksum/. (I love this program) It does require java but is Java 1.3.1 or higher which XP has I think. (works with me) Also notice in the bat files you can change a ton of parameters.I also attached Jacksum's help file that I exported since I didn't find it I also attached the autoinstall script MHZ and I was working on. (Mostly MHZ)After I post this I will try to follow up with a post containing the scripts in the code window. Thanksbatfiles.zipautoInstall.au3installmonitor.au3 Link to comment Share on other sites More sharing options...
jbs123 Posted August 14, 2007 Author Share Posted August 14, 2007 (edited) Reserved right quick while I make a new post. ( Some of you are very quick at posting!)This is ACalcutt's File Change Search CODE;--------------------------------------------------------;AutoIt Version: 3.1.1.102 Beta;;Script Author: Andrew Calcutt;Script Date: 01/21/2006;Script Name: FileChangeSearch;Script Function:; 1. scan system partition to create a 'BEFORE' snapshot using DIR /s /b (Replaced with Jacksum); 2. scan sys partition again at a later date to create an 'AFTER' snapshot as above (after picking up new files); 3. Compare the differences between the two file lists and create a 'CHANGES' file.;--------------------------------------------------------#include <Array.au3>#include <GuiConstants.au3>#include <file.au3>#Include <process.au3>Dim $tempfile1 = "c:\list.txt"Dim $tempfile2 = "c:\listafter.txt"Dim $tempfile3 = "c:\FileChange_Results.txt"Dim $array1, $array2Dim $pos = 0Dim $line = 1;--------------------------------------------------------FileDelete($tempfile1);remove old files if they existFileDelete($tempfile2)FileDelete($tempfile3);--------------------------------------------------------SplashTextOn ( "Scanning", "Scanning Files", 200, 75)_RunDOS("c:\before.bat")SplashOff ()MsgBox(0, "", "Click OK when ready to scan again")SplashTextOn ( "Scanning", "Scanning Files", 200, 75)_RunDOS("c:\after.bat")SplashOff ()_FileReadToArray($tempfile1, $array1); create an array with tempfile1(each line contains a filename)_FileReadToArray($tempfile2, $array2); create an array with tempfile2;Comparing GUIGuiCreate("Comparing", 392, 239)$edit1 = GuiCtrlCreateEdit("", 10, 30, 370, 80, $WS_VSCROLL)$edit2 = GuiCtrlCreateEdit("", 10, 150, 370, 80, $WS_VSCROLL)$count1 = GuiCtrlCreateLabel("", 10, 10, 90, 20)GuiSetState();Comparing GUI EndFor $loop = 1 To $array2[0] GUICtrlSetData ( $edit2, $array2[$line]) GUICtrlSetData ( $count1, $line) GUICtrlSetData ( $edit1, "Scanning For Match" & @CRLF) If $array2[$line] <> $tempfile2 Then $pos2 = $pos $pos = _ArraySearch ($array1, $array2[$line], $pos2, $array1[0]) If @Error = 6 Or @Error = 4 Then FileWrite($tempfile3, $array2[$line] & @CRLF) If $pos = -1 Then GUICtrlSetData ( $edit1, "*** New File ***" & @CRLF) GUICtrlSetData ( $edit1, $array2[$line], 1) Sleep(1000) $pos = $pos2 Else GUICtrlSetData ( $edit1, "Match Found on Line: " & $pos & @CRLF, 1) GUICtrlSetData ( $edit1, $array1[$pos], 1) EndIf EndIf $line += 1NextThis is MHZ's Auto find installer type and install.CODE#NoTrayIcon; Identify Installer modification for auto installation method of use#region - Include files#include <file.au3>#endregion#region - CMDLINE paramtersIf Not $CMDLINE[0] Then MsgBox(0x40000, 'Usage Help', 'Pass a path to an installer by CLI or use drag and drap', 5) ;InetGet("URL", "filename"); Hint: AutoIt function for downloading files ExitEndIfGlobal Const $FILE_FULLPATH = $CMDLINE[1]Global Const $FILE_NAME = StringTrimLeft($FILE_FULLPATH, StringInStr($FILE_FULLPATH, '\', 0, -1))Global Const $FILE_TEXT = StringMid($FILE_NAME, 1, StringInStr($FILE_NAME, '.', 0, -1) -1)Global Const $FILE_EXT = StringMid($FILE_NAME, StringInStr($FILE_NAME, '.', 0, -1))Global Const $FILE_WORKINGDIR = _File_WorkingDir($FILE_FULLPATH)FileChangeDir($FILE_WORKINGDIR)#endregion#region - Script actions_NoMultiFiles()_FileType($FILE_FULLPATH, 'exe|msi');; Use True as 2nd parameter to test only; 2nd parameter is optional and is False if not specified; 3rd parameter is optional and 5000 ms default for splash window timeout_IdentifyInstaller(@ScriptDir & '\ErrorLog.log', True)#endregionExitFunc _IdentifyInstaller($logpath, $test = False, $time = 5000) Opt('MustDeclareVars', True) Local $output, $parameters, $window_on_top_attrib, $exitcode, $splashtext Local Const $TITLE_PEID = 'PEiD' Opt('WinWaitDelay', 50) ; Hide the PEiD window a bit better by getting rid of its on-top attribute $window_on_top_attrib = RegRead('HKCU\Software\PEiD', 'StayOnTop') RegWrite('HKCU\Software\PEiD', 'StayOnTop', 'REG_DWORD', 0) ; Run PeID to scan file. If Not FileExists(@ScriptDir & '\Files\PEiD.exe') Then DirCreate('files') _FileWriteLog($logpath, '"' & @ScriptDir & '\Files\PEID.exe" was not found') Exit 1 EndIf Run('"' & @ScriptDir & '\Files\PEiD.exe" -hard "' & $FILE_FULLPATH & '"') If WinWait($TITLE_PEID, '', 10) Then Sleep(1000) $output = ControlGetText($TITLE_PEID, '', 'Edit2') While $output = 'Scanning...' Or $output = '' Sleep(200) $output = ControlGetText($TITLE_PEID, '', 'Edit2') WEnd WinClose($TITLE_PEID) EndIf ; Identify the Installer Type Local Const $INSTALLER = '"' & $FILE_FULLPATH & '"' If StringInStr($output, 'Inno Setup') _ Or StringInStr($output, 'Inno SFX') _ Or StringInStr($output, 'Borland Delphi') Then ; Identified as Inno Setup $parameters = ' /SP- /SILENT' ElseIf StringInStr($output, 'Wise') Then ; Identified as Wise $parameters = ' /S' ElseIf StringInStr($output, 'Nullsoft') Then ; Identified as Nullsoft $parameters = ' /S' ElseIf StringInStr($output, 'InstallShield AFW') Then ; Identified as InstallShield AFW $parameters = ' /S /A /S /SMS' ElseIf StringInStr($output, 'InstallShield 2003') Then ; Identified as InstallShield 2003 $parameters = ' /V"/QN"' ElseIf StringInStr($output, 'RAR SFX') Then ; Identified as RAR SFX $parameters = ' /S' ElseIf StringInStr($output, 'ZIP SFX') Then ; Identified as ZIP SFX $parameters = ' /AUTOINSTALL' ElseIf StringInStr($output, 'WinZip') Then ; Identified as WinZip $parameters = ' /AUTOINSTALL' ElseIf StringRight($FILE_FULLPATH, 4) = '.msi' Then Opt('WinWaitDelay', 100) Run('msiexec /?') If WinWait('Windows Installer', 20) Then $content = ControlGetText('Windows Installer', '', 'RichEdit20W1') If $content = '' Then ; Using Vista $content = ControlGetText('Windows Installer', '', 'Edit1') EndIf WinClose('Windows Installer') Opt('WinWaitDelay', 250) If $content Then ; Identified as Windows Installer $parameters = ' /QN' EndIf EndIf EndIf If $parameters Then If $test Then ; Test Only $splashtext = 'Command selected for use:' & @CRLF & @CRLF & '"' & $FILE_FULLPATH & '" ' & $parameters SplashTextOn('Identify Installer', $splashtext, 800, 100, Default, 50, 32) Sleep($time) SplashOff() $exitcode = Random(0, 3, 1) If $exitcode Then _ScriptLog($exitcode, $FILE_FULLPATH, $parameters) EndIf Else ; Execute the installation and log non 0 exitcodes $exitcode = RunWait('"' & $FILE_FULLPATH & '" ' & $parameters) If $exitcode Then _ScriptLog($exitcode, $FILE_FULLPATH, $parameters) EndIf EndIf ElseIf $test Then ; Test Only $parameters = 'Failed to Identify' $splashtext = 'Command selected:' & @CRLF & @CRLF & '"' & $FILE_FULLPATH & '" ' & $parameters SplashTextOn('Identify Installer', $splashtext, 800, 100, Default, 50, 32) Sleep($time) SplashOff() _ScriptLog('-', $FILE_FULLPATH, $parameters) Else ; Failed to Identify the installer so log the failure _ScriptLog('-', $FILE_FULLPATH, 'Failed to Identify') EndIf If $window_on_top_attrib Then RegWrite('HKCU\Software\PEiD', 'StayOnTop', 'REG_DWORD', $window_on_top_attrib) EndIfEndFuncFunc _ScriptLog($exitcode, $fullpath, $parameters) _FileWriteLog(@ScriptDir & '\ErrorLog.log', 'Exitcode ' & $exitcode & ': "' & $FILE_FULLPATH & '"' & $parameters)EndFuncFunc _FileType($file, $type) ; Valids the file type selection used for incoming parameter Local $valid, $position _CheckIfFile($file) If $type = '' Then Return $array = StringSplit($type, '|') If Not @error Then For $i = 1 To $array[0] If StringRight($file, StringLen($array[$i])) = $array[$i] Then $valid = True ExitLoop EndIf Next If Not $valid Then $position = StringInStr($type, '|', Default, -1) $type = StringLeft($type, $position - 1) & ' or ' & StringRight($type, StringLen($type) - $position) EndIf ElseIf StringRight($file, StringLen($type)) = $type Then $valid = True EndIf If Not $valid Then _ScriptLog('-', $FILE_FULLPATH, ': Incorrect filetype selected : Supported types = ' & StringReplace($type, '|', ', ') & ' ');~ MsgBox(0x40030, Default, 'Incorrect filetype selected' & @CRLF & 'Supported types: ' & StringReplace($type, '|', ', ') & ' ') Exit 999 EndIfEndFuncFunc _CheckIfFile($parameter) ; Used to check that incoming parameter is a file If StringInStr(FileGetAttrib($parameter), 'D') Then MsgBox(0x40030, Default, 'This is a directory' & @CRLF & 'A file is required for processing') Exit 999 EndIfEndFuncFunc _NoMultiFiles() ; Notify and exit if multiple incoming parameters are passed If $CMDLINE[0] > 1 Then MsgBox(0x40030, Default, 'Multiple file selection is not allowed for this item', 5) Exit 999 EndIfEndFuncFunc _File_WorkingDir($parameter) If StringInStr(FileGetAttrib($parameter), 'D') Then Return $parameter Else Return StringLeft($parameter, StringInStr($parameter, '\', 0, -1)) EndIfEndFunc ; Required for CMDLINE useAs I am able to merge the files and add the other stuff I will update this post. If anyone see's anything they would like to add please do. Any pointer would be nice too. Edited August 14, 2007 by jbs123 Link to comment Share on other sites More sharing options...
xier Posted August 15, 2007 Share Posted August 15, 2007 (edited) I'm new to this forum but I have pretty extensive knowledge of software deployment. I have used AutoIT in conjunction with software deployments quite a bit. Because of the very fluid nature of the Windows OS (registry and such), I would suggest using either sysdiff or Ghosts utility to capture snapshots to executables then use AutoIT as a front end for the fun stuff. Edited August 15, 2007 by xier 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