zhietyou Posted December 6, 2008 Share Posted December 6, 2008 is there any one who can help to do just like disit is a big help for a noob likethank you and more powergod speed Link to comment Share on other sites More sharing options...
Valuater Posted December 6, 2008 Share Posted December 6, 2008 We dont write code for you, we help you write and understand Autoit ... Start with something a little smaller 8) Link to comment Share on other sites More sharing options...
zhietyou Posted December 6, 2008 Author Share Posted December 6, 2008 (edited) tnx for the info Valuater i got this idea at other forum for Unattended Windows application install.. [autoit]Opt("RunErrorsFatal" , 0) Opt("ExpandEnvStrings", 1) ;test Dim $Ver = @OSVersion ;OS Version Dim $OS ;OS Version in more readable format Dim $InstallFile = @ScriptDir & "\config\" & $VER & ".ini" ;default install file Dim $LogFile = IniRead (@ScriptDir & "\config\config.ini", "config", "LogFilePath", @TempDir ) & _ "\kTool-" & @ComputerName & ".txt" Dim $Log = IniRead (@ScriptDir & "\config\config.ini", "config", "LogFile", "1" ) Dim $AvailableArray [1][1] ;array with all commands Dim $SelectedArray [1][1] ;array with commands to run Dim $Available ;list with all sections Dim $Selected ;list with selected sections Dim $DefaultProfile = "(none)" ;profile selected by default Dim $ProfilesList = "" ;list of all profiles Dim $SelectedProfile = "" ;currently selected profile Dim $Profile = "" ;profile to use in silent run Dim $Silent = 0 ;is it silent run? Dim $ForceGUI = 0 ;show GUI for non-standart file? Dim $Reboot = 1 ;reboot mode Dim $AutoLogon = 0 ;autologon selected? Dim $RebootCount = 0 ;number of reboots required Dim $Flag ;default flag for installation $Flag = @SW_SHOW If IniRead (@ScriptDir & "\config\config.ini", "config", "WindowMode" , "") = "Minimize" Then $Flag = @SW_MINIMIZE If IniRead (@ScriptDir & "\config\config.ini", "config", "WindowMode" , "") = "Maximize" Then $Flag = @SW_MAXIMIZE If IniRead (@ScriptDir & "\config\config.ini", "config", "WindowMode" , "") = "Hide" Then $Flag = @SW_HIDE If IniRead (@ScriptDir & "\config\config.ini", "config", "WindowMode" , "") = "Show" Then $Flag = @SW_SHOW Dim $Nonselectable = IniRead (@ScriptDir & "\config\config.ini", "config", "Nonselectable" , "") Dim $RebootTimer = IniRead (@ScriptDir & "\config\config.ini", "config", "RebootTimer" , "60") Dim $AdminWarning = IniRead (@ScriptDir & "\config\config.ini", "config", "AdminWarning" , "1") Dim $ProgressType = IniRead (@ScriptDir & "\config\config.ini", "config", "ProgressType" , "2") Dim $FontType = IniRead (@ScriptDir & "\config\config.ini", "config", "FontType" , "") Dim $Append = "" ;path to append to commands ;CHANGE 'Replace' 1/3***************A Dim $Replace = "" ;replace ini string Dim $ReplaceArray ;replace ini string splitted into marker & path into an array Dim $ReplaceMarker = "" ;marker to be replaced INSIDE commands Dim $ReplacePath = "" ;path to replace the marker INSIDE commands ;CHANGE 'Replace' 1/3 END************ ;CHANGE 'Title' 1/5*****************A Dim $GUITitle = "" ;GUI windows title (can be set to a value specified in the .ini file) Dim $ProgressTitle = "" ;Progress windows title (can be set to the same value but default is <>) ;CHANGE 'Title' 1/5 END************** ;CHANGE 'Title' 3/5*****************A Dim $RunningTitle = "" Dim $OverallProgress = "" Dim $SoftwareInstallation = "" ;CHANGE 'Title' 3/5 END************** Dim $Description ;description for Progress2 items Dim $Context ;context for Progress2 Dim $SoftwareToInstall = 0 Dim $Subcommands = 0 Dim $CurrentSubCommand = 0 ;;;;;;;;;;;;; ;MAIN commandline () ;CHANGE 'config' 1/1*****************A Dim $LogFilePath = IniRead ($InstallFile, "Config", "LogFilePath", "" ) If $LogFilePath <> "" Then $LogFile = $LogFilePath & "\kTool-" & @ComputerName & ".txt" $Log = IniRead ($InstallFile, "Config", "LogFile", $Log ) If IniRead ($InstallFile, "Config", "WindowMode" , "") = "Minimize" Then $Flag = @SW_MINIMIZE If IniRead ($InstallFile, "Config", "WindowMode" , "") = "Maximize" Then $Flag = @SW_MAXIMIZE If IniRead ($InstallFile, "Config", "WindowMode" , "") = "Hide" Then $Flag = @SW_HIDE If IniRead ($InstallFile, "Config", "WindowMode" , "") = "Show" Then $Flag = @SW_SHOW $Nonselectable = IniRead ($InstallFile, "Config", "Nonselectable" , $Nonselectable) $RebootTimer = IniRead ($InstallFile, "Config", "RebootTimer" , $RebootTimer) $AdminWarning = IniRead ($InstallFile, "Config", "AdminWarning" , $AdminWarning) $ProgressType = IniRead ($InstallFile, "Config", "ProgressType" , $ProgressType) ;CHANGE 'config' 1/1 END************** If $AdminWarning = 1 Then CheckAdmin() ;Line moved from before "commandline ()" above, for using the last value of the setting ReturnOSVersion() ;Line moved from before "GUI()" below, because we need $OS for the title in FileToArray() FileToArray ($AvailableArray, $InstallFile) If $Silent = 1 And $ForceGUI = 0 Then If $Profile <> "" Then $Selected = IniRead ($InstallFile, "Profiles", $Profile, "") Else $Selected = $Available EndIf Else GUI() GUIDelete() EndIf ReadSelection () Install() GUIDelete() If $Reboot > 1 Then Reboot ($RebootTimer) ;;;;;;;;;;;;; ;done Func ReturnOSVersion ();Get OS version to readable format Select Case $VER = "WIN_XP" $OS = "Windows XP" Case $VER = "WIN_2000" $OS = "Windows 2000" Case $VER = "WIN_98" $OS = "Windows 98" Case $VER = "WIN_ME" $OS = "Windows ME" Case $VER = "WIN_95" $OS = "Windows 95" Case $VER = "WIN_NT4" $OS = "Windows NT4" EndSelect EndFunc;ReturnOSVersion ;done Func CommandLine (); Read command line options For $i = 1 to UBound ($CmdLine) - 1 Select Case $CmdLine[$i] = "?" Or $CmdLine[$i] = "/?" Or $CmdLine[$i] = "help" Or $CmdLine[$i] = "/help" MsgBox(0, "Help", "/? - Displays this message" & @LF & _ "filename - Specify file to read instructions from (Silent mode)" & @LF & _ " You can create such files in GUI mode" & @LF & _ "/GUI Forces GUI mode" & @LF & _ "Profile Profile to use" & @LF & _ "reboot 0 - Disable restarting the computer" & @LF & _ " 1 - Enable restarting the computer (default)" & @LF & _ " 2 - Disable but restart when finished" & @LF & _ " 3 - Enable and restart when finished" & @LF & @LF & _ "Example:" & @LF & _ " kTool.exe c:\kTool.ini 2") Exit Case StringIsDigit ( $CmdLine[$i] ) Select Case $CmdLine[$i] = 0 $Reboot = 0 Case $CmdLine[$i] = 1 $Reboot = 1 Case $CmdLine[$i] = 2 $Reboot = 2 Case $CmdLine[$i] = 3 $Reboot = 3 EndSelect Case $CmdLine[$i] = "/GUI" $ForceGUI = 1 Case StringRight ( $CmdLine[$i], 4 ) = ".ini" $InstallFile = $CmdLine[$i] $Silent = 1 Case Else $Profile = $CmdLine[$i] EndSelect Next EndFunc ;CommandLine ;done Func Reboot ($tSeconds);Reboot computer ProgressOn("Restarting", IniRead (@ScriptDir & "\config\config.ini", "Language", "Restarting", "Restarting"), "", -1, -1, 16) For $i = $tSeconds To 0 Step - 1 Sleep(1000) ProgressSet( ( ($tSeconds - $i) * 100) / $tSeconds, $i & " seconds") Next Shutdown(6) EndFunc ;Reboot ;done Func CheckAdmin();Check if user has administrator rights If IsAdmin()=0 Then If MsgBox (4,"","Administrator rights required. Continue?") = 7 then Exit EndIf EndFunc ;CheckAdmin ;done Func FileToArray (ByRef $tArray, $tFile);Write all commands to array $i = 0 $ProfilesList = IniRead ($tFile, "Config", "Profiles" , "") $ProfilesList = $ProfilesList & "|All|(none)" $DefaultProfile = IniRead ($tFile, "Config", "DefaultProfile", "(none)") $Append = IniRead ($tFile, "Config", "Append" , "") If $Append = "CD" Then $Append = @ScriptDir & "\" ;CHANGE 'Replace' 2/3***************A $Replace = IniRead ($tFile, "Config", "Replace" , "") If $Replace<>"" Then $ReplaceArray = StringSplit ($Replace, "-->", 1) If $ReplaceArray[0]=2 Then $ReplaceMarker = $ReplaceArray[1] $ReplacePath = $ReplaceArray[2] EndIf EndIf If $ReplacePath = "CD" Then $ReplacePath = @ScriptDir & "\" ;CHANGE 'Replace' 2/3 END************ ;CHANGE 'Title' 2/5*****************A $GUITitle = IniRead ($tFile, "Config", "GUITitle", $OS & " " & @OSServicePack) $ProgressTitle = IniRead ($tFile, "Config", "ListTitle", "Installing Applications") ;CHANGE 'Title' 2/5 END************** ;CHANGE 'Title' 3/5*****************A $RunningTitle = IniRead ($tFile, "Config", "RunningTitle", "Installing ...") $OverallProgress = IniRead ($tFile, "Config", "OverallProgress", "Overall Progress") $SoftwareInstallation = IniRead ($tFile, "Config", "SoftwareInstallation", "Software Installation") ;CHANGE 'Title' 3/5 END************** $tOpenFile = FileOpen ($tFile, 0 ) While 1 $tLine = FileReadLine ($tOpenFile) If @error = -1 Then ExitLoop $tLine = StringStripWS ($tLine, 3 ) Select Case StringLeft ( $tLine, 1) = "[" If StringLeft ( $tLine, 8) <> "[Config]" And StringLeft ( $tLine, 10) <> "[Profiles]" Then FillArray ($tArray, $tLine, "Section" , $i) $tArray[$i-1][0] = StringReplace ($tArray[$i-1][0], "[", "") $tArray[$i-1][0] = StringReplace ($tArray[$i-1][0], "]", "") $Available = $Available & "|" & $tArray[$i-1][0] EndIf Case StringLeft ( $tLine, 7) = "RunWait" FillArray ($tArray, $tLine, "RunWait" , $i) Case StringLeft ( $tLine, 3) = "Run" FillArray ($tArray, $tLine, "Run" , $i) Case StringLeft ( $tLine, 3) = "MSI" FillArray ($tArray, $tLine, "MSI" , $i) Case StringLeft ( $tLine, 3) = "PRE" FillArray ($tArray, $tLine, "PRE" , $i) Case StringLeft ( $tLine, 3) = "DOS" FillArray ($tArray, $tLine, "DOS" , $i) Case StringLeft ( $tLine, 3) = "REG" FillArray ($tArray, $tLine, "REG" , $i) Case StringLeft ( $tLine, 11) = "WaitProcess" FillArray ($tArray, $tLine, "WaitProcess" , $i) Case StringLeft ( $tLine, 12) = "WinWaitClose" FillArray ($tArray, $tLine, "WinWaitClose" , $i) Case StringLeft ( $tLine, 6) = "Reboot" FillArray ($tArray, $tLine, "Reboot" , $i) Case StringLeft ( $tLine, 13) = "FolderCommand" FillArray ($tArray, $tLine, "FolderCommand" , $i) Case StringLeft ( $tLine, 13) = "FolderPreCommand" FillArray ($tArray, $tLine, "FolderPreCommand" , $i) Case StringLeft ( $tLine, 11) = "FolderFiles" FillArray ($tArray, $tLine, "FolderFiles" , $i) Case StringLeft ( $tLine, 12) = "FolderSwitch" FillArray ($tArray, $tLine, "FolderSwitch" , $i) Case StringLeft ( $tLine, 6) = "Folder" FillArray ($tArray, $tLine, "Folder" , $i) Case StringLeft ( $tLine, 16) = "FileExistVersion" FillArray ($tArray, $tLine, "FileExistVersion" , $i) Case StringLeft ( $tLine, 15) = "FileExistAction" FillArray ($tArray, $tLine, "FileExistAction" , $i) Case StringLeft ( $tLine, 9) = "FileExist" FillArray ($tArray, $tLine, "FileExist" , $i) Case StringLeft ( $tLine, 18) = "FileNotExistAction" FillArray ($tArray, $tLine, "FileNotExistAction" , $i) Case StringLeft ( $tLine, 12) = "FileNotExist" FillArray ($tArray, $tLine, "FileNotExist" , $i) Case StringLeft ( $tLine, 11) = "Description" FillArray ($tArray, $tLine, "Description" , $i) Case StringLeft ( $tLine, 7) = "Context" FillArray ($tArray, $tLine, "Context" , $i) Case Else EndSelect Wend FileClose ($tOpenFile) EndFunc ;FileToArray ;done Func FillArray (ByRef $tArray, $tLine, $tCommand, ByRef $tCounter) ReDim $tArray [$tCounter+1][2] $tPos = StringInStr ($tLine, "=") $tLine = StringTrimLeft ($tLine, $tPos) $tLine = StringStripWS ($tLine, 3) $tArray [$tCounter][0] = $tLine $tArray [$tCounter][1] = $tCommand $tCounter = $tCounter + 1 EndFunc ;FillArray ;done Func DelFromList (ByRef $tList, $tItem) $tList = StringReplace ( $tList & "|", "|" & $tItem & "|" , "|") $tList = StringTrimRight ( $tList, 1 ) EndFunc ;DelFromList ;done func CheckList ($tString, $tSubstring); Check if substring is in the list $tString = $tString & "|" If StringInStr ($tString, "|" & $tSubstring & "|") > 0 then return 1 Else return 0 EndIf EndFunc ;CheckList ;done Func ReadSelection () $tSelected = "" $Subcommands = 0 $SoftwareToInstall = 0 $tNumber = UBound ( $AvailableArray ) $j = 1 $tTriger = 0 For $i = 0 To $tNumber - 1 If $AvailableArray [$i][1] = "Section" Then If CheckList($Selected, $AvailableArray [$i][0]) = 1 Then $SoftwareToInstall = $SoftwareToInstall + 1 $tTriger = 1 $tSelected = $tSelected & "|" & $AvailableArray [$i][0] Else $tTriger = 0 EndIf EndIf If $tTriger = 1 Then Redim $SelectedArray [$j][2] $SelectedArray [$j-1][0] = $AvailableArray [$i][0] $SelectedArray [$j-1][1] = $AvailableArray [$i][1] If $AvailableArray [$i][1] = "Reboot" Then $RebootCount = $RebootCount + 1 $j = $j + 1 EndIf Next $Selected = $tSelected EndFunc ;ReadSelection ;done Func FindNextSection ($tArray, $tCounter) For $i = $tCounter To UBound ($tArray) - 1 If $tArray[$i][1] = "Section" Then Return $i Next Return -1 EndFunc ;FindNextSection ;done Func CountFiles ($tFolder, $tFileType) $i = 0 $tFile = FileFindFirstFile($tFolder & "\*." & $tFileType) If $tFile = -1 Then Return 0 EndIf While 1 FileFindNextFile($tFile) If @error Then Return $i $i = $i + 1 Wend FileClose($tFile) EndFunc ;CountFiles ;done Func GUI () ;************************************************************* ;REPLACED: all (5) GUIRead function calls by GUICtrlRead calls ;************************************************************* ;CHANGE 'Title' 3/5*****************M ; GUICreate ( "kTool v1.1a - " & $OS & " " & @OSServicePack , 510, 420) GUICreate ( "kTool v1.1c - " & $GUITitle , 510, 420) ;CHANGE 'Title' 3/5 END************** GUICtrlCreateLabel (IniRead (@ScriptDir & "\config\config.ini", "Language", "Available", "Available Programs"), 20, 10, 160, 20) GUICtrlSetFont (-1, 12 ,646) GUICtrlCreateLabel (IniRead (@ScriptDir & "\config\config.ini", "Language", "Selected", "Selected Programs"), 210, 10, 160, 20) GUICtrlSetFont (-1, 10 ,400) GUICtrlCreateLabel (" Edited December 6, 2008 by SmOke_N Link to comment Share on other sites More sharing options...
FireFox Posted December 6, 2008 Share Posted December 6, 2008 Hi, On the second picture I see simple progress so look at Progress functions for exemple ProgressOn() 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