spudw2k Posted April 2, 2008 Share Posted April 2, 2008 (edited) expandcollapse popup#RequireAdmin #include <GuiListView.au3> #include <GuiTab.au3> #include <Array.au3> Global $arrTabs[1][4] ;Hostname|Tab#|ListView|WindDir $gui = GUICreate("SchTasksGUI", @DesktopWidth * .525, @DesktopHeight * .3725, -1, -1, 0x00070000) $tabs = GUICtrlCreateTab(2, 0, (@DesktopWidth * .525) - 6, (@DesktopHeight * .3725) - 22) GUICtrlSetResizing(-1, 102) $blanktab = GUICtrlCreateTabItem("Connect to ...") _NewConnection() GUIRegisterMsg(0x004E, "WM_NOTIFY") GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case -3 _GUIExit() Case -7 If _GUICtrlTab_GetCurSel($tabs) = _GUICtrlTab_GetItemCount($tabs)-1 Then _NewConnection() _GUICtrlTab_SetCurFocus($tabs,_GUICtrlTab_GetItemCount($tabs)-2) EndIf EndSwitch WEnd Func _AddTasksToGUI($arrTasks, $listTasks) ;Add captured task information and populate Listview in GUI If Not IsArray($arrTasks) Then Return 0 For $i = 0 To UBound($arrTasks) - 1 $arrTasks[$i] = StringReplace(StringReplace($arrTasks[$i], Chr(34) & "," & Chr(34), "|"), Chr(34), "") $arrEntry = StringSplit($arrTasks[$i], "|") $arrEntry[6] = "0x" & Hex($arrEntry[6],8) For $x = 2 To 27 If $x = 2 Then _GUICtrlListView_AddItem($listTasks, $arrEntry[$x]) Else _GUICtrlListView_AddSubItem($listTasks, $i, $arrEntry[$x], $x - 2) EndIf Next Next For $x = 0 To 24 If $x = 6 Then $x = 9 Else _GUICtrlListView_SetColumnWidth($listTasks, $x, $LVSCW_AUTOSIZE) EndIf Next EndFunc ;==>_AddTasksToGUI Func _FileDisplayProperties($sFile,$job) ;Display File Properties for Highlighted Items $objShell = ObjCreate("Shell.Application") $objCP = $objShell.Namespace($sFile) If Not IsObj($objCP) Then Return 0 For $clsConn In $objCP.Items If $clsConn.Name = $job Then For $clsVerb in $clsConn.verbs If $clsVerb.name = "P&roperties" then $clsVerb.DoIt Next EndIf Next $objShell = 0 $objCP = 0 EndFunc;==>_FileDisplayProperties Func _GetTasks($strHost = "") ;Retrieve task information from SCHTASKS.EXE $strExe = "schtasks.exe /query /v /fo csv /nh" If $strHost <> "" Then $strExe = $strExe & " /s " & $strHost $pid = Run($strExe, @WorkingDir, "", 2) $stdout = "" While 1 $line = StdoutRead($pid) If @error Then ExitLoop $stdout = $stdout & StringReplace($line, @CR, "") WEnd If StringInStr($stdout, "ERROR:") Or StringInStr($stdout, "INFO:") Then Return 0 $arrData = StringSplit($stdout, @LF) Do _ArrayDelete($arrData, 0) Until StringInStr($arrData[0], Chr(34) & "," & Chr(34)) _ArrayDelete($arrData, UBound($arrData) - 1) Return $arrData EndFunc ;==>_GetTasks Func _GetWindowsDir($strHost = ".") $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strHost & "\root\cimv2") If Not IsObj($objWMIService) Then Return 0 $objWMIQuery = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem") For $objOS in $objWMIQuery Return StringReplace($objOS.WindowsDirectory,":","$") Next EndFunc Func _GUIDblClick($tasklist="",$strHost="",$varWindowsDir="") $itemHit = _GUICtrlListView_SubItemHitTest($tasklist) If $itemHit[0] > -1 Then $strJob = "" $job = _GUICtrlListView_GetItemText($tasklist,$itemHit[0],0) If $varWindowsDir Then $strJob = "\\" & $strHost & "\" & $varWindowsDir & "\Tasks\" Else $varWindowsDir = _GetWindowsDir($strHost) If $varWindowsDir Then $strJob = "\\" & $strHost & "\" & $varWindowsDir & "\Tasks\" EndIf If $strJob Then _FileDisplayProperties($strJob,$job) EndIf Return True EndFunc Func _GUIExit() GUIDelete($gui) Exit EndFunc Func _NewConnection() $strHost = InputBox("Connect to...", "Hostname?", @ComputerName, "", 200, 120) $strHost = StringUpper($strHost) If Not Ping($strHost) Then msgbox(0,"","Could not Ping " & $strHost) Return 0 EndIf $tasks = _GetTasks($strHost) If $blanktab<>0 Then GUICtrlDelete($blanktab) If $arrTabs[0][1] <> "" Then ReDim $arrTabs[UBound($arrTabs)+1][4] $arrTabs[UBound($arrTabs)-1][0] = $strHost $arrTabs[UBound($arrTabs)-1][1] = GUICtrlCreateTabItem("Current Tasks on " & $strHost) $pos = WinGetPos($gui) $varWinHeight = $pos[3] $varWinWidth = $pos[2] $arrTabs[UBound($arrTabs)-1][2] = GUICtrlCreateListView("TaskName|Next Run Time|Status|Last Run Time|Last Result|Creator|Schedule|Task To Run|Start In|Comment|Scheduled Task State|Scheduled Type|Start Time|Start Date|End Date|Days|Months|Run as User|Delete Task If Not Rescheduled|Stop Task If Runs X Hours and X Mins|Repeat: Every|Repeat: Until|Repeat: Until Duration|Repeat: Stop If Still Running|Idle Time|Power Management", $varWinWidth - ($varWinWidth * .98), $varWinHeight - ($varWinHeight * .98) + ($varWinHeight * .0475), $varWinWidth * .95, ($varWinHeight * .875) - 12,0x0004) GUICtrlSetResizing(-1, 102) _AddTasksToGUI($tasks, $arrTabs[UBound($arrTabs)-1][2]) $blanktab = GUICtrlCreateTabItem("Connect to ...") $tasks = "" EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) ;Notify func Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") For $x = 0 To UBound($arrTabs)-1 Switch $hWndFrom Case GUICtrlGetHandle($arrTabs[$x][2]) $tasklist = GUICtrlGetHandle($arrTabs[$x][2]) $strHost = $arrTabs[$x][0] $varWindowsDir = $arrTabs[$x][3] Switch $iCode Case -3 Return _GUIDblClick($tasklist,$strHost,$varWindowsDir) Case -5 Return True EndSwitch EndSwitch Next EndFunc ;==>WM_NOTIFY Edited July 30, 2013 by spudw2k JScript 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Triblade Posted April 3, 2008 Share Posted April 3, 2008 Cool, automating/manipulating windows parts is exacly what AutoIt is for Nice. My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted April 4, 2008 Share Posted April 4, 2008 Could be handy Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
ken82m Posted October 29, 2008 Share Posted October 29, 2008 Very nice I tried running it on the latest beta and had to include "GUIListView.au3" for it to work "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains." Link to comment Share on other sites More sharing options...
gcue Posted July 10, 2012 Share Posted July 10, 2012 clean and simple - thanks for sharing =) Link to comment Share on other sites More sharing options...
JScript Posted July 10, 2012 Share Posted July 10, 2012 Very nice, thanks 4 sharing! Regards, João Carlos. http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
matwachich Posted July 10, 2012 Share Posted July 10, 2012 (edited) C:UsersXXXDesktopSchTaskGUI.au3 (84) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: Until StringInStr($arrData[0], Chr(34) & "," & Chr(34)) Until StringInStr(^ ERROR Edited July 10, 2012 by matwachich 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