Jump to content

jwseek

Active Members
  • Posts

    28
  • Joined

  • Last visited

Profile Information

  • Location
    Bozeman, MT

jwseek's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. The only reason I wanted that was if you were parsing some type of file that had entries like:Number1 = 15 Or 123test = Alpha4 The full information is lost if you only parse for letters or numbers.
  2. Quite pretty, but I don't know regexp that well. Can you explain how those work?
  3. I had read line 19 and I suppose maybe I shouldn't be doing this, but the idea was to not have to run ComboFix every time I wanted to install the Recovery Console on a machine and to also avoid a rather large download to install it or finding a CD. Anyway, I "copied" what sUBs did because I wanted to understand how s/he did what s/he did. At that point, I can write my own (or recreate rather than copy) Recovery Console installer. I'm certainly not going to use a program like this until I completely understand what it does. That's why I was asking. And if I could just ask sUBs directly, I'd do that instead.
  4. So I couldn't find any scripts like this in the forum, so I figured posting it would be useful... So the following two functions are - hopefully - well commented, but they take a string and, in one case, pull all the numbers out into a " "-delineated string (for easy parsing). In the other case, we pull all the "words" (strings of concurrent letters) from the input string into a " "-delineated string. I'm not sure exactly how effective these functions are, but they haven't failed me in my uses yet, so... StringStripAlpha: Creates " " split string with numbers from input string... #cs --------------------- pull one character at a time from the string... if it's a digit [0-9], start adding every character from that digit on until the character to add is not a digit. Then add a space at the end. This essentially makes the following string: error action="1" item="C:\Documents and Settings\LocalService\Local Settings\Application Data\Microsoft\Windows\UsrClass.dat" code="32" time="2009-07-21T21:22:17" /> into: 1 32 2009 07 21 21 22 17 #ce --------------------- Func stringStripAlpha($alphNumString) $tempString = "" $numberString = "" For $i = 1 To StringLen($alphNumString) $tempString = StringMid($alphNumString, $i, 1) If StringIsDigit($tempString) Then #cs --------------------- we need to add each digit onto the actual number as it appears in the string so the final string has each number listed individually. this do loop adds those extra digits if they're there also, some lines can have a entry like number3="4" or 3number="4". We don't want the three there to be considered a number, so we'll skip it if the characters directly proceeding or following the number are letters (alpha characters) #ce ---------------------- Do If (Not StringIsAlpha(StringMid($alphNumString, $i - 1, 1))) And (Not StringIsAlpha(StringMid($alphNumString, $i + 1, 1))) Then $numberString &= $tempString $i += 1 $tempString = StringMid($alphNumString, $i, 1) Until Not StringIsDigit($tempString) $numberString &= " " EndIf Next $numberString = StringReplace($numberString, " ", " ") ;remove the trailing space Return StringTrimRight($numberString, 1) EndFunc StringMakeAlpha: pulls all the "words" from the input string #cs --------------------- Very similar to stringStripAlpha except we're dumping everything but each individual word in the string, i.e. error action="1" item="C:\Documents and Settings\LocalService\Local Settings\Application Data\Microsoft\Windows\UsrClass.dat" code="32" time="2009-07-21T21:22:17" /> becomes: error action item C Documents and Settings LocalService Local Settings Application Data Microsoft Windows UsrClass dat code time Note: Numbers that end the string (i.e. number3 or test100) will be attached to the word Numbers that start a string currently do not get attached #ce --------------------- Func stringMakeAlpha($alphNumString) $tempString = "" $alphaString = "" For $i = 1 To StringLen($alphNumString) $tempString = StringMid($alphNumString, $i, 1) If StringIsAlpha($tempString) Then Do $alphaString &= $tempString $i += 1 $tempString = StringMid($alphNumString, $i, 1) Until Not StringIsAlpha($tempString) If StringIsDigit($tempString) Then Do $alphaString &= $tempString $i += 1 $tempString = StringMid($alphNumString, $i, 1) Until Not StringIsDigit($tempString) EndIf $alphaString &= " " EndIf Next Return StringTrimRight($alphaString, 1) EndFunc So are these useful? Are the loops too slow? I can't recall how to test 0() levels on loops but this does iterate through the string only once, so it can't be that slow...
  5. Well, it's been almost a week and nobody's replied to this. I guess I won't be getting any help on this one. Oh well. Thanks anyway.
  6. So I am attempting to create a simple script (minimal GUI interaction, just does it and move on) that will install the Windows Recovery Console on a Windows XP computer. I'm basing my script on the Recovery Console installer built into Combofix. Now the script that sUBs wrote (in rather confusing batch files with lots of random "sed", "grep", and other much more UNIX-y commands) downloads the Windows XP Floppy Boot Disks to accomplish the task of installing the recovery console. He extracts the files from the floppy images, adds a few other files from Windows, and does some magic with boot.ini to make it usable. Here's sUBs recovery console install code: @IF NOT EXIST InstallRC DEL /A/F %0 IF NOT EXIST XP.mac ( REM NIRCMD.COM INFOBOX "Will only install the Recovery Console for Windows XP" "" NIRCMD LOOP 2 80 BEEP 3000 200 NIRCMD.COM INFOBOX "%LINE51%" "" GOTO AbortRC ) :: NIRCMD infobox "Boot Partition cannot be enumerated correctly" "" && GOTO AbortRC IF NOT DEFINED BootDir NIRCMD infobox "%LINE52%" "" && GOTO AbortRC GREP -Eisq "^default( =|=)" %BootDir%Boot.ini ||( REM CALL NIRCMD.COM INFOBOX "%%BootDir%%Boot.ini is not correctly formated" "" NIRCMD LOOP 2 80 BEEP 3000 200 CALL NIRCMD.COM INFOBOX "%Line53%" "" GOTO AbortRC ) IF EXIST %BootDir%cmdcons\bootsect.dat GREP -isq "CMDCONS\\BOOTSECT.DAT" %BootDir%Boot.ini &&( IF EXIST Rboot.dat GOTO :EOF NIRCMD LOOP 2 80 BEEP 3000 200 NIRCMD.COM INFOBOX "%Line54%" "" GOTO AbortRC REM NIRCMD.COM INFOBOX "This machine already has the Recovery Console installed.~n~nAborting operations" "" ) SED -r "s/^.*(.:\\.*)$/\1/;s/\x22//" InstallRC >RC00 FOR /F "TOKENS=*" %%G IN ( RC00 ) DO @IF EXIST "%%G" ( REM NIRCMD INFOBOX "Please click 'YES' in the End User License Agreement (EULA) dialog that follows ..." "Installing the Recovery Console" ECHO.%%~NXG>CF-RC.txt NIRCMD INFOBOX "%Line55%" "" "%%G" /c /t:"%CD%\RC" ) ELSE IF EXIST "%%~SG" ( ECHO.%%~NXG>CF-RC.txt NIRCMD INFOBOX "%Line55%" "" "%%~SG" /c /t:"%CD%\RC" ) ELSE ( REM CALL NIRCMD.COM INFOBOX "Installation file - %%~G - cannot be found" CALL NIRCMD.COM INFOBOX "%Line56%" "" GOTO AbortRC ) DEL /A/F/Q RC0? N_\* IF NOT EXIST "%cd%\RC\cdboot1.img" ( REM NIRCMD.COM INFOBOX "You didn't select YES~n~nInstallation is aborted" "" NIRCMD.COM INFOBOX "%Line57%" "" GOTO AbortRC ) IF EXIST %BootDir%cmdcons ( IF EXIST f_system SWXCACLS %BootDir%cmdcons /RESET /Q RD /S/Q %BootDir%cmdcons )>N_\%random% 2>&1 MD %BootDir%cmdcons >N_\%random% 2>&1 EXTRACT.cfexe -ox RC\cdboot?.img %BootDir%cmdcons >N_\%random% 2>&1 COPY /Y /B %system%\autochk.exe %BootDir%cmdcons >N_\%random% 2>&1 COPY /Y /B %system%\autofmt.exe %BootDir%cmdcons >N_\%random% 2>&1 EXPAND.exe -r %BootDir%cmdcons\txtsetup.si_ >N_\%random% 2>&1 COPY /Y /B %BootDir%cmdcons\setupldr.bin %BootDir%cmldr >N_\%random% 2>&1 dd if=\\.\%bootdir:~,2% of=%BootDir%cmdcons\bootsect.dat bs=512 count=1 >N_\%random% 2>&1 IF EXIST f_system Type BootSect.dll >>%BootDir%cmdcons\bootsect.dat IF NOT EXIST f_system GSAR -o -sNTLDR:x20:x20 -rCMLDR:x20:x20 %BootDir%cmdcons\bootsect.dat >N_\%random% 2>&1 REGT /a /s MountedDevices.reg "HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices" @>%BootDir%cmdcons\migrate.inf ( ECHO.[Version] ECHO.Signature = "$Windows NT$" ECHO. ECHO.[Addreg] ) SED "1,3d" MountedDevices.reg |( SED -r "s/\\\\/\\/g;:a;/\\$/N; s/\\\n //; ta" | sed "/hex:5c/I!d; s/=hex:5c,/,0x00030001,\\\n /;/^\x22/s/./HKLM,\x22SYSTEM\\MountedDevices\x22,&/" |( SED -r "/^ /s/[^\\ ]{72}/&\\\n /g" ))>>%BootDir%cmdcons\migrate.inf @>%BootDir%cmdcons\winnt.sif ( ECHO.[data] ECHO.msdosinitiated="1" ECHO.floppyless="1" ECHO.CmdCons="1" ECHO.LocalSourceOnCD="1" ECHO.AutoPartition="0" ECHO.UseSignatures="yes" ECHO.InstallDir="%systemroot:~2%" ECHO.EulaComplete="1" ECHO.winntupgrade="no" ECHO.win9xupgrade="no" ECHO.[regionalsettings] SWREG QUERY "hklm\system\currentcontrolset\control\nls\locale" /v "(default)" | sed "/.* /!d;s///;s/.*/Language=&/" ECHO.LanguageGroup=1 ECHO.[setupparams] ECHO.DynamicUpdatesWorkingDir=%systemroot%\setupupd ECHO.[unattended] ECHO.unused=unused ECHO.[userdata] ECHO.productid="" ECHO.productkey="" ECHO.[OobeProxy] ECHO.Enable=1 ECHO.Flags=1 ECHO.Autodiscovery_Flag=4 ) DEL /A/F %BootDir%cmdcons\txtsetup.si_ MountedDevices.reg >N_\%random% 2>&1 PEV -rtf %BootDir%cmdcons\VGA.SY_ >N_\%random% 2>&1 ||( REM CALL START NIRCMD.COM INFOBOX "Contents of %%BootDir%%cmdcons are not in order.~n~nPlease disable your security programs before trying again" "" CALL START NIRCMD.COM INFOBOX "%Line58%" "" RD /S/Q %BootDir%cmdcons GOTO AbortRC )>N_\%random% 2>&1 IF EXIST %BootDir%Boot.bak DEL /A/F %BootDir%Boot.bak >N_\%random% 2>&1 ATTRIB -H -R -S -A %BootDir%Boot.ini COPY /Y %BootDir%Boot.ini %BootDir%Boot.bak >N_\%random% 2>&1 SET "bootsect=\n%BootDir%\CMDCONS\\BOOTSECT.DAT=\x22Microsoft Windows Recovery Console\x22 \/cmdcons" SED G %BootDir%Boot.bak | SED -r "/cmdcons\\bootsect.dat|^$/Id; s/^\s*//; s/\s*$//" >BootIni00 SED "/^timeout=/Is/=.*/=2/; s/^\[operating systems\]$/&%bootsect%/I" BootIni00 >%BootDir%Boot.ini DEL /A/F BootIni00 >N_\%random% 2>&1 ATTRIB +H +S +A +R %BootDir%Boot.ini SET bootsect= TYPE myNul.dat >RcRdy TYPE %BootDir%Boot.ini >>CF-RC.txt @ATTRIB +H +S +A +R %BootDir%cmdcons /S /D @IF EXIST f_system SWXCACLS %BootDir%cmdcons /DE:;A732/I /Q TYPE myNul.dat >AbortC :: NIRCMD.COM QBOXCOMTOP "The Recovery Console was successfully installed.~n~nClick 'Yes' to continue scanning for malware~n~nClick 'No' to exit" "What's next ?" RETURNVAL 1 || GOTO :EOF NIRCMD.COM QBOXCOMTOP "%Line59%" "" FILLDELETE AbortC IF NOT EXIST AbortC GOTO :EOF IF EXIST Gateway FOR /F %%G IN ( gateway ) DO ROUTE ADD 0.0.0.0 MASK 0.0.0.0 %%G COPY /Y CF-RC.txt \ >N_\%random% 2>&1 START Notepad.exe \CF-RC.txt @GOTO :EOF :AbortRC :: NIRCMD.COM QBOXCOMTOP "Click 'Yes' to continue scanning for malware~n~nClick 'No' to exit" "What's next ?" RETURNVAL 1 && ECHO.>AbortC @ECHO.>AbortC NIRCMD.COM QBOXCOMTOP "%Line60%" "" FILLDELETE AbortC IF NOT EXIST AbortC GOTO :EOF @GOTO :EOFNow there are a few things in there that don't make any sense, but most of them have to do with other portions of his program. As an example, here is my (similar) program: #include <Process.au3> Dim $destinationDrive = StringLeft(@WindowsDir, 2) Dim $destinationDir = $destinationDrive & "\cmdcons" DirCreate($destinationDir) DirCopy(".\files", $destinationDir, 1) FileCopy($destinationDir & "\setupldr.bin", $destinationDrive & "\cmldr", 1) _RunDOS("dd.exe if=\\.\" & $destinationDrive & " of=" & $destinationDir & "\bootsect.dat bs=512 count=1") ;_RunDOS("type.exe BootSect.dll >>" & $destinationDir & "\bootsect.dat") ;_RunDOS("GSAR.exe -o -sNTLDR:x20:x20 -rCMLDR:x20:x20 " & $destinationDir & "\bootsect.dat") IniWrite($destinationDir & "\migrate.inf", "Version", "Signature", "$Windows NT$") ;write all data from HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices to migrate.inf section [Addreg] ;write winnt.sif file IniWrite($destinationDir & "\winnt.sif", "data", "msdosinitiated", "1") IniWrite($destinationDir & "\winnt.sif", "data", "floppyless", "1") IniWrite($destinationDir & "\winnt.sif", "data", "CmdCons", "1") IniWrite($destinationDir & "\winnt.sif", "data", "LocalSourceOnCD", "1") IniWrite($destinationDir & "\winnt.sif", "data", "AutoPartition", "0") IniWrite($destinationDir & "\winnt.sif", "data", "UseSignatures", "yes") IniWrite($destinationDir & "\winnt.sif", "data", "InstallDir", $destinationDrive) IniWrite($destinationDir & "\winnt.sif", "data", "EulaComplete", "1") IniWrite($destinationDir & "\winnt.sif", "data", "winntupgrade", "no") IniWrite($destinationDir & "\winnt.sif", "data", "win9xupgrade", "no") IniWrite($destinationDir & "\winnt.sif", "regionalsettings", RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\Locale\", "(Default)")) IniWrite($destinationDir & "\winnt.sif", "regionalsettings", "LanguageGroup", "1") IniWrite($destinationDir & "\winnt.sif", "setupparams", "DynamicUpdatesWorkingDir", @WindowsDir & "\setupupd") IniWrite($destinationDir & "\winnt.sif", "unattended", "unused", "unused") IniWrite($destinationDir & "\winnt.sif", "userdata", "productid", "") IniWrite($destinationDir & "\winnt.sif", "userdata", "productkey", "") IniWrite($destinationDir & "\winnt.sif", "OobeProxy", "Enable", "1") IniWrite($destinationDir & "\winnt.sif", "OobeProxy", "Flags", "1") IniWrite($destinationDir & "\winnt.sif", "OobeProxy", "Autodiscovery_Flag", "4") FileSetAttrib($destinationDir & "\boot.ini", "-HRSA") IniWrite($destinationDrive & "\boot.ini", "boot loader", "timeout", 3) IniWrite($destinationDrive & "\boot.ini", "operating systems", "C:\CMDCONS\BOOTSECT.DAT", '"Microsoft Windows Recovery Console" /cmdcons') RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Setup\RecoveryConsole\", "SecurityLevel", "REG_DWORD", 00000001) RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Setup\RecoveryConsole\", "SetCommand", "REG_DWORD", 00000001) FileSetAttrib($destinationDir & "\boot.ini", "+HRSA") _RunDOS("attrib +H +R +S " & $destinationDir & " /S /D")(Obviously, sUBs should consider writing his stuff in AutoIT, it's much clearer.) Anyway, I extracted all the files and added them to the ".\files" directory beforehand, so I didn't need to download and extract things every time I ran the program. I think I have most of the code copied over properly (with a few small modifications). There are two things in sUBs code that confuse me: 1) REGT /a /s MountedDevices.reg "HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices"Here he enumerates every key in the HKLM\SYSTEM\MountedDevices folder and then outputs them to an .ini file in a manner similar to this: [Version] Signature = "$Windows NT$" [Addreg] HKLM,"SYSTEM\MountedDevices",,0x00000010 HKLM,"SYSTEM\MountedDevices","\??\Volume{865af030-acd9-11dd-a9eb-806d6172696f}",0x00030001,\ 5c,00,3f,00,3f,00,5c,00,46,00,44,00,43,00,23,00,47,00,45,00,4e,00,45,00,52,\ 00,49,00,43,00,5f,00,46,00,4c,00,4f,00,50,00,50,00,59,00,5f,00,44,00,52,00,\ 49,00,56,00,45,00,23,00,35,00,26,00,33,00,34,00,39,00,32,00,33,00,34,00,30,\ 00,31,00,26,00,30,00,26,00,30,00,23,00,7b,00,35,00,33,00,66,00,35,00,36,00,\ 33,00,30,00,64,00,2d,00,62,00,36,00,62,00,66,00,2d,00,31,00,31,00,64,00,30,\ 00,2d,00,39,00,34,00,66,00,32,00,2d,00,30,00,30,00,61,00,30,00,63,00,39,00,\ 31,00,65,00,66,00,62,00,38,00,62,00,7d,00 HKLM,"SYSTEM\MountedDevices","\??\Volume{865af031-acd9-11dd-a9eb-806d6172696f}",0x00030001,\ 5c,00,3f,00,3f,00,5c,00,49,00,44,00,45,00,23,00,43,00,64,00,52,00,6f,00,6d,\ 00,56,00,42,00,4f,00,58,00,5f,00,43,00,44,00,2d,00,52,00,4f,00,4d,00,5f,00,\ 5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,\ 00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,\ 5f,00,5f,00,5f,00,31,00,2e,00,30,00,5f,00,5f,00,5f,00,5f,00,5f,00,23,00,34,\ 00,32,00,35,00,36,00,32,00,64,00,33,00,32,00,33,00,31,00,33,00,30,00,33,00,\ 30,00,33,00,37,00,33,00,33,00,33,00,30,00,33,00,36,00,33,00,37,00,32,00,30,\ 00,32,00,30,00,32,00,30,00,32,00,30,00,32,00,30,00,32,00,30,00,32,00,30,00,\ 32,00,30,00,23,00,7b,00,35,00,33,00,66,00,35,00,36,00,33,00,30,00,64,00,2d,\ 00,62,00,36,00,62,00,66,00,2d,00,31,00,31,00,64,00,30,00,2d,00,39,00,34,00,\ 66,00,32,00,2d,00,30,00,30,00,61,00,30,00,63,00,39,00,31,00,65,00,66,00,62,\ 00,38,00,62,00,7d,00I think this shouldn't be too hard to reproduce in AutoIT, but I can't really wrap my head around how. 2) IF EXIST f_system Type BootSect.dll >>%BootDir%cmdcons\bootsect.dat IF NOT EXIST f_system GSAR -o -sNTLDR:x20:x20 -rCMLDR:x20:x20 %BootDir%cmdcons\bootsect.dat >N_\%random% 2>&1These two lines don't really make any sense to me. You can see I reproduced them in my code, but I'm wary of using them until I know that they'll actually do something useful. So...can anyone help me with my weird problems? If there's more information needed (or you just want to know what some of the obscure code that I didn't talk about does) please let me know. Thanks.
  7. But then I'd have to parse the arguments that I add to the end of every install procedure to make them non-interactive. This is also pretty easy, and there's less string manipulation. Although, I wish I would have noticed that sooner...
  8. So there are moments in my life where I find myself extremely embarrassed. This is one of those moments. I mentioned the msiexec process about 5 times in this thread, and I just realized that to properly execute .msi files, one has to execute them like this: msiexec /i filename.msi Pretty silly thing to forget, but there it is... The corrected code: #Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=favicon.ico #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Description=Script to install all needed software on new computers #AutoIt3Wrapper_Res_Fileversion=0.3.0.7 #AutoIt3Wrapper_Res_FileVersion_AutoIncrement=y #AutoIt3Wrapper_Res_SaveSource=y #AutoIt3Wrapper_Res_Language=1033 #AutoIt3Wrapper_res_requestedExecutionLevel=requireAdministrator #AutoIt3Wrapper_Run_Tidy=y #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #Region Include Statements #include <GUIConstants.au3> #EndRegion Include Statements #Region Variable Declarations $programTitle = "AutoInstaller" $iniFile = "autoinstaller.ini" $iniSections = IniRead($iniFile, "Global", "IniSections", "3") $serverName = "\\" & IniRead($iniFile, "Global", "ServerName", "") $installFolder = $serverName & "\" & IniRead($iniFile, "Global", "InstallFolder", "install") $patchesFolder = $serverName & "\" & IniRead($iniFile, "Global", "PatchesFolder", "patches") $installDrive = IniRead($iniFile, "Global", "InstallDrive", "Z:") $patchesDrive = IniRead($iniFile, "Global", "patchesDrive", "Y:") $patchesSetup = IniReadSection($iniFile, "Patches") $installSetup = IniReadSection($iniFile, "Installs") $copyLocation = "D:\BIN" $BaseX = 20 $BaseY = 15 $CurX = 0 $CurY = 0 Dim $driveMapErrors[6] $driveMapErrors[0] = "Undefined or Other" $driveMapErrors[1] = "Access to the remote share was denied" $driveMapErrors[2] = "The device is already assigned" $driveMapErrors[3] = "Invalid device name" $driveMapErrors[4] = "Invalid remote share" $driveMapErrors[5] = "Invalid password" #EndRegion Variable Declarations Opt("TrayIconHide", 1) $hGUI = GUICreate($programTitle, 280, 210) Opt("GUICoordMode", 1) #Region Drop-Down Menu $fileMenu = GUICtrlCreateMenu("&File") $iniLoadMenuItem = GUICtrlCreateMenuItem("&Load Ini File", $fileMenu) $exitProgramMenuItem = GUICtrlCreateMenuItem("E&xit", $fileMenu) $helpMenu = GUICtrlCreateMenu("&Help") $aboutMenuItem = GUICtrlCreateMenuItem("About...", $helpMenu) #EndRegion Drop-Down Menu #Region Create GUI $CurX = $BaseX $CurY = $BaseY $computerTypeHomeRadio = GUICtrlCreateRadio("Home System", $CurX, $CurY) $CurY += 25 $computerTypeWorkRadio = GUICtrlCreateRadio("Business System", $CurX, $CurY) $CurY += 35 GUICtrlCreateLabel("Destination for BIN directory:", $CurX, $CurY) $CurY += 20 $copyLocationInput = GUICtrlCreateInput($copyLocation, $CurX, $CurY, 150) $CurX += 160 $browseCopyLocation = GUICtrlCreateButton("Browse...", $CurX, $CurY - 3) $CurX = $BaseX $CurY += 45 $executeButton = GUICtrlCreateButton("Install Software", $CurX, $CurY) $CurX += 135 $exitButton = GUICtrlCreateButton("Exit Program", $CurX, $CurY) #EndRegion Create GUI GUISetState() GUICtrlSetState($computerTypeHomeRadio, $GUI_DISABLE) GUICtrlSetState($computerTypeWorkRadio, $GUI_DISABLE) ; Run the GUI until the dialog is closed Do $msg = GUIGetMsg() Switch $msg Case $aboutMenuItem MsgBox(0, "", "Version: " & FileGetVersion("AutoInstaller.exe")) Case $exitProgramMenuItem $msg = $GUI_EVENT_CLOSE Case $exitButton $msg = $GUI_EVENT_CLOSE Case $iniLoadMenuItem $iniFile = FileOpenDialog("Select config file", @ScriptDir, "INI files (*.ini)", 1) If $iniFile Then LoadINIFile() EndIf Case $browseCopyLocation $copyLocation = browseFolder() If StringCompare($copyLocation, "") <> 0 Then GUICtrlSetData($copyLocationInput, $copyLocation) Else $copyLocation = GUICtrlRead($copyLocationInput) EndIf Case $executeButton modCallingWindow("AutoInstaller.exe", @SW_MINIMIZE) ProgressOn("Installing patches and software...", "Mapping Network Drives...") $temp = MapDrives() If $temp = 1 Then ProgressSet(10, "", "Installing Windows patches...") For $i = 1 To $patchesSetup[0][0] ;MsgBox(0, "", $patchesFolder & '\' & $patchesSetup[$i][1] & @LF & $patchesSetup[$i][0]) ProgressSet($i, "Installing " & $patchesSetup[$i][0]) If StringInStr($patchesSetup[$i][1], "msi", 2) = 0 Then $PID = Run($patchesFolder & '\' & $patchesSetup[$i][1], $patchesFolder) Else $PID = Run("msiexec /i " & $patchesFolder & '\' & $patchesSetup[$i][1], $patchesFolder) EndIf ProcessWaitClose($PID) Next ProgressSet(33, "Copying install folder to " & $copyLocation) ;MsgBox(0, "", "Copy from " & $installFolder & " to " & $copyLocation) DirCopy($installFolder, $copyLocation, 1) ProgressSet(66, "Installing Software...") For $i = 1 To $installSetup[0][0] ;MsgBox(0, "", $installFolder & '\' & $installSetup[$i][1] & @LF & $installSetup[$i][0]) ProgressSet(66 + $i, "Installing " & $installSetup[$i][0]) If StringInStr($installSetup[$i][1], "msi", 2) = 0 Then $PID = Run($installFolder & '\' & $installSetup[$i][1], $installFolder) Else $PID = Run("msiexec /i " & $installFolder & "\" & $installSetup[$i][1], $installFolder) EndIf ProcessWaitClose($PID) Next ProgressSet(100, "Done", "Completed!") Sleep(3000) ProgressOff() modCallingWindow("AutoInstaller.exe", @SW_RESTORE) MsgBox(64, "Completed Installation", "Successfully completed installation and copying procedures...") Else MsgBox(48, "Failed Networking!", "Networking drives to install directories failed...") EndIf EndSwitch Until $msg = $GUI_EVENT_CLOSE DriveMapDel($installDrive) DriveMapDel($patchesDrive) GUIDelete() #Region General Functions Func browseFolder() Local $tempFolder = "" $tempFolder = FileSelectFolder("Select Location for BIN Directory:", "") Return $tempFolder EndFunc ;==>browseFolder Func LoadINIFile() ;determine whether the sections with in the ini file are correct for this particular ini load $iniSectionList = IniReadSectionNames($iniFile) If $iniSectionList[0] = $iniSections And $iniSectionList[1] = "Global" Then $loadINI = MsgBox(1, "Loading INI File...", "This will change all initialized data (including networking data)", 3) $serverName = "\\" & IniRead($iniFile, "Global", "ServerName", "") $installFolder = $serverName & "\" & IniRead($iniFile, "Global", "InstallFolder", "install") $patchesFolder = $serverName & "\" & IniRead($iniFile, "Global", "PatchesFolder", "patches") $installDrive = IniRead($iniFile, "Global", "InstallDrive", "Z:") $patchesDrive = IniRead($iniFile, "Global", "patchesDrive", "Y:") $patchesSetup = IniReadSection($iniFile, "Patches") $installSetup = IniReadSection($iniFile, "Installs") Else MsgBox(48, "Invalid Program INI File", "The file you selected does not contain the proper formatting for loading as an INI file") EndIf EndFunc ;==>LoadINIFile Func IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible Func modCallingWindow($title, $state) Local $activeWindowList = WinList() Local $windowNumber = 0 For $i = 1 To $activeWindowList[0][0] If $activeWindowList[$i][0] <> "" And IsVisible($activeWindowList[$i][1]) Then Local $windowTitle = StringTrimLeft($activeWindowList[$i][0], StringLen($activeWindowList[$i][0]) - StringLen($title)) If $windowTitle = $title Then $windowNumber = $i WinSetState($activeWindowList[$i][0], "", $state) EndIf EndIf Next EndFunc ;==>modCallingWindow #EndRegion General Functions #Region Networking Functions Func MapDrives() DriveMapDel($installDrive) DriveMapDel($patchesDrive) $res = DriveMapAdd($installDrive, $installFolder) If $res <> 1 Then SplashOff() MsgBox(16, "Drive Mapping", "Error mapping drive!" & @LF & "Error Code: " & $driveMapErrors[@error]) Return $res EndIf $res = DriveMapAdd($patchesDrive, $patchesFolder) If $res <> 1 Then SplashOff() MsgBox(16, "Drive Mapping", "Error mapping drive!" & @LF & "Error Code: " & $driveMapErrors[@error]) Return $res EndIf Return $res EndFunc ;==>MapDrives #EndRegion Networking Functions
  9. No...they're all there in the same path. I checked three times. The installs actually start, they just fail. Like I said, this may actually be an issue with msiexec and not AutoIt, but I was hoping somebody could help me narrow it down...
  10. First off, thanks to Authenticity for pointing out some bits I missed in the ini load function. I loaded the default ini at startup, and since I wasn't deviating from that behaviour (even though I might need to in the future), I didn't notice the mistakes. Unfortunately... So I want to reiterate that this problem is with the installation of programs through AutoIt. Installing these programs one at a time with these switches results in a successful install. Installing these programs with the following loops causes some of the programs to fail: For $i = 1 To $patchesSetup[0][0] ProgressSet($i, "Installing " & $patchesSetup[$i][0]) $PID = Run($patchesFolder & '\' & $patchesSetup[$i][1], $patchesFolder) ProcessWaitClose($PID) Next ProgressSet(33, "Copying install folder to " & $copyLocation) DirCopy($installFolder, $copyLocation, 1) ProgressSet(66, "Installing Software...") For $i = 1 To $installSetup[0][0] ProgressSet(33 + $i, "Installing " & $installSetup[$i][0]) $PID = Run($installFolder & '\' & $installSetup[$i][1], $installFolder) ProcessWaitClose($PID) Next When I'm using this ini file to define what should be installed: [Global] ServerName=server InstallFolder=install PatchesFolder=patches InstallDrive=V: PatchesDrive=Y: [Patches] .NET Framework 1.1=dotnetfx11.exe /q ;.NET Framework 1.1 Service Pack 1=Service Packs\dotnet11sp1.exe /q .NET Framework 3.5=dotnetfx35.exe /passive /norestart Visual C++ Redistributable 2005=vcredist_x86.exe /q Windows Media Player 11=wmp11-windowsxp-x86-enu.exe /q [Installs] 7zip=7zip.msi /passive Firefox=Freeware\Firefox.msi /passive Internet Explorer Flash Plugin=flash-ie.exe /S Mozilla Flash Plugin=flash-mozilla.exe /S Sun Java=java.exe /passive Adobe Acrobat Reader=Productivity\AdbeRdr.msi /passive For instance, the patches all seem to install with the exception of the .NET Framework 1.1 service pack. Then 7-zip, Firefox and Adobe all won't install. I assumed it was because some of the installs are spawning processes that lock access to msiexec, but I don't know. Also, bo8ster's recommendation sounds promising, but I don't entirely understand how to implement it.
  11. So I've been working on this script today to install a number of programs on a new Windows install. Basically, I'd like to be able to keep track of some files on a server and simply run this script to install all of them with no interaction. The catch is, I'm trying to avoid using the macro and interaction tools in auto-it. The reason behind that is it allows me to add programs to the script without rewriting it if I can find an unattended command line switch for them. I simply add them to an .ini file that the program reads and run through the array in that particular section with IniReadSection(). So the problem is, some of the programs don't run and install properly. I've tested each of the programs that I'm currently trying to install, and they all succeed individually but they won't install if run in the program... [Global] ServerName=server InstallFolder=install PatchesFolder=patches InstallDrive=V: PatchesDrive=Y: [Patches] .NET Framework 1.1=dotnetfx11.exe /q ;.NET Framework 1.1 Service Pack 1=Service Packs\dotnet11sp1.exe /q .NET Framework 3.5=dotnetfx35.exe /passive /norestart Visual C++ Redistributable 2005=vcredist_x86.exe /q Windows Media Player 11=wmp11-windowsxp-x86-enu.exe /q [Installs] 7zip=7zip.msi /passive Firefox=Freeware\Firefox.msi /passive Internet Explorer Flash Plugin=flash-ie.exe /S Mozilla Flash Plugin=flash-mozilla.exe /S Sun Java=java.exe /passive Adobe Acrobat Reader=Productivity\AdbeRdr.msi /passive ;HTMLSlideshow=HTMLSlideShowSetup.exe ;Synctoy=SyncToySetupPackage.exe ;TweakUI=TweakUiPowertoySetup.exe ;Image Resizer Powertoy=ImageResizerPowertoySetup.exe /S /v /qn ;Slideshow Powertoy=SlideshowPowertoySetup.exe /S /v /qn So am I doing something wrong? Is this an issue more with msiexec than with AutoIT? What would you guys do? AutoInstaller.au3
  12. Yeah...thanks. I've been messing around and it looks like my problem is mostly due to timing. If I wait a little while before trying anything fancy (like reading from the command line), I seem to get actual information. Also, don't worry about the code right now. All it does is list the physical drives on the computer. Edit: Ooo! If StringRight($read, 10) <> "DISKPART> " Then ExitLoop is actually backwards. I want to exit the read loop only when the last ten characters *are* "DISKPART> ", not when they're not. I guess it should be: If StringRight($read, 10) == "DISKPART> " Then ExitLoop
  13. yeah...the syntax error was the fault of bad copying from SciTE to my browser...Thanks, though. I can't close the stream right then because I need to read the output of the stream before I close it (and after trying it anyway, the results remain the same). I guess I'm still wondering why StdoutRead won't return a value...
  14. So, basically, DOS programs executed with the "Run" command seem to lock up when either of these commands are called. I'm only experimenting right now, naturally meaning that I'm rather close to the examples I saw, but I'm trying... $procDiskPart = Run(@ComSpec & " /c DiskPart.exe", "", @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD) While StringRight(StdoutRead($procDiskPart, -1, True), 10) <> "DISKPART> " Sleep(100) If Not(ProcessExists($procDiskPart)) Then $iChoice = MsgBox(5 + 64, "Disk Partitioner", "Disk Partitioner could not connect to the Disk Management services." & @CRLF & @CRLF & _ "Click Retry to try connecting again or choose Cancel to abort.") If $iChoice = 4 Then $procDiskPart = Run(@ComSpec" /c DiskPart.exe", "", @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD) Else $procDiskPart = 0 ExitLoop EndIf EndIf Wend If $procDiskPart <> 0 Then $read = StdoutRead($procDiskPart) StdinWrite($procDiskPart, "LIST DISK" & @CRLF) Else MsgBox(0,"","Did not load") EndIf $read = StdoutRead($procDiskPart) MsgBox(0,"",StringLen($read) & " " & $read & @LF & $procDiskPart) I know it never reaches the MsgBox command at the bottom of the code because I've never seen it. It just seems to sit at the load of the program from the run command... What am I doing wrong? Edit: the Run command is not failing (I get a process id with a MsgBox right after it). I suppose the While or something there after is causing the break... Edit 2: Aha! It was the while that was causing the lock-up. Now I suppose the new question is: Why doesn't stdoutRead pull anything when I call it? I get a blank string of length 0 every time... Please help...
  15. Yeah, but a pointer to a dword and a dword pointer are different things. One simply points to a memory location that happens to contain a dword while the other is allocated memory the size of a dword variable. I think. I could be completely wrong.
×
×
  • Create New...