chaos945 Posted March 14, 2008 Share Posted March 14, 2008 I could use some feed back on this little sequential execution script I've been working on. It uses a config.ini file (which is generated on first run) to launch applications sequentialy. I use it at the shop to run programs to prep systems for service. I am utilizing PsKill.exe for this script it must be installed in the script directory prior to running. To use the script: 1. Copy a program you use into the script directory (ie. copy entire "CCleaner folder") 2. Add the name of the executable to config.ini (ie. ccleaner.exe) 3. Run Script For example my config.ini looks like this: [Processes] pagedfrg.exe StartupCPL.exe CCleaner.exe Spywareblaster.exe expandcollapse popup#RequireAdmin #include <File.au3> #include <Array.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #NoTrayIcon If @OSTYPE <> "WIN32_NT" Then MsgBox(4096, "Error", @OSVersion & " is not supported by this rollout. Only WIN32/NT versions of Windows are compatible.") Exit EndIf Opt("GUIOnEventMode", 1) ;BEGIN MAIN GUI $Form1 = GUICreate("Tech Tools Macro", 178, 66, 1136, 6, BitOR($WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW), $WS_EX_TOOLWINDOW+$WS_EX_TOPMOST) $Terminate = GUICtrlCreateButton("Terminate", 8, 8, 95, 49, 0) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUICtrlSetCursor (-1, 0) $Next = GUICtrlCreateButton("Next", 112, 8, 57, 49, 0) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUICtrlSetCursor (-1, 0) GUISetState(@SW_SHOW) ;END MAIN GUI ;AdlibEnable("GUIRefresh", 250);Allows GUI to refresh during a process and between processes GUISetOnEvent($GUI_EVENT_CLOSE, "Exit1") GUICtrlSetOnEvent($Terminate, "Terminate") GUICtrlSetOnEvent($Next, "Nextf") DIM $config ;BEGIN - File config.ini array and file search ;Read Config.ini to an array and Run Processes in sequence If NOT _FileReadToArray("Config.ini", $config) Then $genfile = FileOpen("Config.ini", 2) FileWrite("Config.ini", "[Processes]") FileClose($genfile) _FileReadToArray("Config.ini", $config) EndIf For $a = 2 to $config[0] $runcode = $a $nextf = 0 Do If $runcode = $a Then $search1 = _FileListToArray(@ScriptDir, "*", 1) $results = _ArraySearch($search1, $config[$a], 0, 0, 0, True);search @ScriptDir for file If @error = 6 Then;if it was not found then list the directories and array $search2 = _FileListToArray(@ScriptDir, "*", 2);search2 is a list of directories in @ScriptDir ;_ArrayDisplay($search2) For $b = 1 to $search2[0];check each directory for file; $search2[0] is the total number of directories $filelist = _FileListToArray($search2[$b], "*", 1);array files in directory $b ;_ArrayDisplay($filelist) ;MsgBox(0, "Process to launch", $config[$a]) $results = _ArraySearch($filelist, $config[$a], 0, 0, 0, True);search directory $b for file $a If @error = 6 Then $results = "not found" ElseIf $filelist[$results] = $config[$a] Then $runcode = Run(@Scriptdir & "\" & $search2[$b] & "\" & $config[$a]) ExitLoop EndIf Next If $results = "not found" Then If NOT $config[$a] = "" Then;ignores blank entries in config.ini MsgBox(0, "Tech Tools Macro", $config[$a] & " could not be found.", 10) EndIf ;ExitLoop 1 EndIf ElseIf $search1[$results] = $config[$a] Then $runcode = Run($config[$a], @Scriptdir) EndIf EndIf Sleep(250);performance Until NOT ProcessExists($runcode) OR $nextf = 1 Next GUISetState(@SW_HIDE) MsgBox(0, "Tech Tools Macro", "All processes complete!") Exit ;END Func Exit1() $choice1 = MsgBox(4, "Tech Tools Macro", "Are you sure you want to exit? All currently running processes will be terminated.") If $choice1 = 6 Then For $b = 2 to $config[0] Run("Pskill.exe " & ($config[$b]), @SCRIPTDIR, @SW_HIDE) Next Exit EndIf EndFunc Func Terminate() Run("Pskill.exe " & ($config[$a]), @SCRIPTDIR, @SW_HIDE) EndFunc Func Nextf() Global $nextf = 1 EndFunc 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