myk3 0 Posted May 4, 2011 (edited) I am not sure if anyone is interested.. I have made a GUI frontend for PsExec..PsExec / >filelist.au3 is in the same folder as the script I had to modify the first line of filelist.au3 to look like this.. Func _FileListToArrayEx($s_path, $s_mask = "*.txt", $i_flag = 1, $s_exclude = -1, $f_recurse = True, $f_full_path = FALSE) This is my first real app so if anyone has suggestions or improvements please let me know.. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #Include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <array.au3> #Include <File.au3> #include "filelist.au3" #RequireAdmin global $test =9999, $form1=9999, $form2=9999, $form3=9999,$Form4=9999, $ok = 9999, $cancel = 9999, $add=9999, $delete=9999, $edit=9999, $file=9999,$add1 =9999,$sSft Global $edit1=9999, $IName2=9999, $location=9999,$Location1=9999,$Location2=9999,$deploy=9999,$hostname=9999,$list2=9999,$import=9999,$hostnames=9999, $command1=9999,$sRtn=9999 global $command=9999, $FileName=9999, $file1 =9999, $switches=99991, $INAME=9999, $IName1=9999, $List1=9999, $select=9999, $deployarray[1],$exitcode,$switches1, $Label3, $temp, $ListView1, $aComputer=9999 Global $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $1 = 1 $message = "Pick the file you wish to install" $dir = _FileListToArrayEx(@ScriptDir & "\installers\",'*.txt',1) if FileExists(@scriptdir & "\Installers\") Then Else DirCreate(@scriptdir & "\Installers\") endif if FileExists(@scriptdir & "\Deployments\") Then Else DirCreate(@scriptdir & "\Deployments\") EndIf FileInstall("C:\Users\michael.c.chipser\Desktop\Installer\PSEXEC.exe",@TempDir&"\") $PsExec = @TempDir & "\PsExec.exe" _main() func _Main() $h =1 $Form1 = GUICreate("Remote Installer", 749, 468, 186, 117) Local $tab = GUICtrlCreateTab(-1, -1, 749, 468) Local $BIOStab = GUICtrlCreateTabItem("Installers") GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $List1 = GUICtrlCreateList("", 16, 24, 169, 390) GUICtrlCreateGroup("", -99, -99, 1, 1) $add = GUICtrlCreateButton("Add", 8, 424, 83, 33) $delete = GUICtrlCreateButton("Delete", 112, 424, 83, 33) $Group2 = GUICtrlCreateGroup("", 200, 56, 537, 105, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT)) $file = GUICtrlCreateLabel("File Name: " , 208, 72,300, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $command = GUICtrlCreateLabel("Command Line: ", 208, 112,500, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlCreateGroup("", -99, -99, 1, 1) $delpoy = GUICtrlCreateButton("Deploy Now", 656, 24, 83, 33) $edit = GUICtrlCreateButton("Edit Installer", 568, 24, 83, 33) $Name = GUICtrlCreateLabel("INSTALLER NAME", 200, 24, 250, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Group3 = GUICtrlCreateGroup("Deployments", 200, 168, 537, 289, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $ListView1 =GUICtrlCreateListView("Hostname|Status|Date", 208, 185, 522, 262) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlCreateGroup("", -99, -99, 1, 1,$LVS_REPORT) Local $BIOStab = GUICtrlCreateTabItem("Installed Software") GUICtrlCreateLabel("Insert Hostname / IP",8,28) $SoftwareHost = GUICtrlCreateInput("", 120, 24, 400, 21, BitOR($GUI_SS_DEFAULT_INPUT,$WS_BORDER)) $SoftwareQuery = GUICtrlCreateButton("Query", 525, 23, 35, 25) $ListView2 =GUICtrlCreateListView("Name|Version|Publisher", 5, 50,735, 410) GUISetState(@SW_SHOW) if $dir <> "" Then do $str = StringTrimRight($dir[$1],4) GUICtrlSetData($List1,$str) $1 += 1 until $1 = UBound($dir) endif While 1 $1 = 1 $msg = GUIGetMsg(1) if $msg = "" Then ContinueLoop endif if GUICtrlRead($List1) <> "" Then if GUICtrlRead($List1) = $select Then Else $select = GUICtrlRead($List1) GUICtrlSetData($Name,$select) $fileO = FileOpen(@ScriptDir & "\Installers\" & $select &".txt",0) $switches = FileReadLine($fileO,1) $location1 = FileReadLine($fileO,2) FileClose($fileO) $array = StringSplit($location1,"\",1) $u = UBound($array) GUICtrlSetData($file,$array[$u-1]) GUICtrlSetData($command,$array[$u-1] & " " & $switches) _GUICtrlListView_DeleteAllItems($listview1) if FileExists(@ScriptDir & "\Deployments\"& $select & ".txt") Then _FileReadToArray(@ScriptDir & "\Deployments\"& $select & ".txt",$temp) $im = 1 do GUICtrlCreateListViewItem($temp[$im],$ListView1) $im += 1 until $im = UBound($temp) _GUICtrlListView_SetColumnWidth($ListView1,0,$LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($ListView1,1,$LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($ListView1,2,$LVSCW_AUTOSIZE) endif $command1 = '"' &$array[$u-1] &'"'& " " & $switches endif endif switch $msg[1] case $Form1;MAIN FORM Switch $msg[0] Case $GUI_EVENT_CLOSE Exit Case $add GUISetState(@SW_disable,$Form1) _Installer() Case $delete $delete1 = MsgBox(4,"Delete?","Are you sure you want to delete """& $select &'"') if $delete1 = 6 Then if FileExists(@ScriptDir & "\installers\" & $select &".txt") Then FileDelete (@ScriptDir & "\installers\" & $select &".txt") EndIf $item2delete = ControlCommand ( "Patch Management", "", $list1, "FindString", $select) ControlCommand("Remote Installer","",$list1,"DelString",$item2delete) EndIf Case $delpoy if $select = "" then ContinueLoop Else GUISetState(@SW_disable,$Form1) _deploy() endif Case $edit $edit1 = GUICtrlRead($List1) if GUICtrlRead($List1) = "" Then ContinueLoop Else $fileO = FileOpen(@scriptdir & "\installers\" & $select &".txt",0) $switches = FileReadLine($fileO,1) $location1 = FileReadLine($fileO,2) FileClose($fileO) _edit($select,$switches,$location1) endif case $SoftwareQuery _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView2)) $aComputer = GUICtrlRead($SoftwareHost,0) $var = ping($aComputer) if $var Then _ComputerGetSoftware($sSft) if IsArray ($sSft) then _GUICtrlListView_AddArray($ListView2,$sSft) endif Else MsgBox(0,"PING Error!","Unable to ping system") endif _GUICtrlListView_SetColumnWidth($ListView2,0,$LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($ListView2,1,$LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($ListView2,2,$LVSCW_AUTOSIZE) EndSwitch case $Form2 ;ADD INSTALLER Switch $msg[0] case $file1 $location1= FileOpenDialog($message,@ScriptDir, "ALL (*.*)", 1);file browse to get the location of the patch If @error Then ContinueLoop EndIf GUICtrlSetData($Location2,$location1) case $ok if FileExists(@ScriptDir & "\installers\" & GUICtrlRead($INAME,0) &".txt") Then FileDelete (@ScriptDir & "\installers\" & GUICtrlRead($INAME,0) &".txt") $item2delete = ControlCommand ("Remote Installer", "", $list1, "FindString", $select) ControlCommand("Remote Installer","",$list1,"DelString",$item2delete) EndIf $fileO = FileOpen(@ScriptDir & "\installers\" & GUICtrlRead($INAME,0) &".txt",1) FileWriteLine($fileO,GUICtrlRead($switches1)) FileWriteLine($fileO,GUICtrlRead($Location2)) FileClose($fileO) ControlCommand("Remote Installer","",$list1,"addstring",GUICtrlRead($INAME,0)) GUIDelete($Form2) GUISetState(@SW_enable,$Form1) case $cancel GUIDelete($Form2) GUISetState(@SW_enable,$Form1) case $GUI_EVENT_CLOSE GUIDelete($Form2) GUISetState(@SW_enable,$Form1) EndSwitch case $Form3 ;EDIT INSTALLER Switch $msg[0] case $file1 $location1= FileOpenDialog($message,@ScriptDir, "ALL (*.*)", 1);file browse to get the location of the patch If @error Then ContinueLoop EndIf GUICtrlSetData($Location2,$location1) case $ok $IName2 = GUICtrlRead($INAME,0) if $select <> $IName2 Then if FileExists(@ScriptDir & "\installers\" & $select &".txt") Then FileDelete (@ScriptDir & "\installers\" & $select &".txt") EndIf if FileExists(@ScriptDir & "\deployments\" & $select &".txt") Then FileDelete (@ScriptDir & "\deployments\" & $select &".txt") EndIf $item2delete = ControlCommand ("Remote Installer", "", $list1, "FindString", $select) ControlCommand("Remote Installer","",$list1,"DelString",$item2delete) EndIf $selects = GUICtrlRead($Label3,0) if $selects <> $switches Then if FileExists(@ScriptDir & "\installers\" & $select &".txt") Then FileDelete (@ScriptDir & "\installers\" & $select &".txt") EndIf $item2delete = ControlCommand ("Remote Installer", "", $list1, "FindString", $select) ControlCommand("Remote Installer","",$list1,"DelString",$item2delete) EndIf $fileO = FileOpen(@ScriptDir & "\installers\" & GUICtrlRead($INAME,0) &".txt",1) FileWriteLine($fileO,GUICtrlRead($switches1)) FileWriteLine($fileO,GUICtrlRead($Location2)) FileClose($fileO) ControlCommand("Remote Installer","",$list1,"addstring",GUICtrlRead($INAME,0)) GUIDelete($Form3) GUISetState(@SW_enable,$Form1) case $cancel GUIDelete($Form3) GUISetState(@SW_enable,$Form1) case $GUI_EVENT_CLOSE GUIDelete($Form3) GUISetState(@SW_enable,$Form1) EndSwitch case $form4 ;DEPLOY FORM switch $msg[0] Case $add1 GUICtrlSetData($List2,GUICtrlRead($hostname,0)) ;---------------------------- ;----------DEPLOY------------ ;---------------------------- Case $deploy;DEPLOY HERE GUISetState(@SW_DISABLE,$Form4) GUISetState(@SW_hide,$Form4) GUISetState(@SW_hide,$Form1) $l = 0 ProgressOn("Deployment progress","Deploying: " & $select) do $deploy1 = _GUICtrlListBox_GetText($list2, $l) if IsArray ($deployarray) = 1 Then $bound = ubound($deployarray) ReDim $deployarray[$bound+$1] $deployarray[$bound] = _GUICtrlListBox_GetText($list2, $l) endif $l += 1 until _GUICtrlListBox_GetText($list2, $l) = "" $l = 1 do if $l > $bound then exitloop if $deployarray[$l] = " " Then $l +=1 ContinueLoop endif $deploy1 = $deployarray[$l] if $deploy1 = "localhost" Then $deploy1 = @ComputerName endif $var = ping($deploy1,2000) if $var then;deployment commands go here ProgressSet(50,"Copying " & '"' & $select & '"' & " on " & @CRLF & $deploy1,"Deploying: " & $select) $filecopy = FileCopy($location1,"\\" & $deploy1 & "\admin$\",1) if $filecopy = 0 Then FileWriteLine(@scriptdir & "\Deployments\" & $select & ".txt",$deploy1 & "|" & "COPY_ERROR" &"|" & @mday & "/" & @mon & "/" & @year & " " &@hour & ":" & @min) $l += 1 ContinueLoop EndIf ProgressSet(75,"Installing "& $l & " of " & $bound & @CRLF &'"'& $select &'"'& " on " & $deploy1 ,"Deploying: " & $select) $filerun = runwait($PsExec &" -accepteula -i -n 120 \\" & $deploy1 & " " & $command1 ,"",@SW_HIDE) Switch $filerun case 0 $exitcode = "Success" Case else $exitcode = "Error" EndSwitch if $filerun <> 0 Then FileWriteLine(@scriptdir & "\Deployments\" & $select & ".txt",$deploy1 & "|" & $exitcode &"|" & @mday & "/" & @mon & "/" & @year & " " &@hour & ":" & @min) $l += 1 ContinueLoop endif FileWriteLine(@scriptdir & "\Deployments\" & $select & ".txt",$deploy1 & "|" & $exitcode &"|" & @mday & "/" & @mon & "/" & @year & " " &@hour & ":" & @min) $l += 1 ProgressSet(90,"Cleaning up: "& @CRLF &'"'& $select &'"' & " on "& $deploy1 ,"Deploying: " & $select) if FileExists ("\\" & $deploy1 & "\admin$\"& $array[$u-1]) then FileDelete("\\" & $deploy1 & "\admin$\"& $array[$u-1]) EndIf endif _GUICtrlListView_DeleteAllItems($listview1) if FileExists(@ScriptDir & "\Deployments\"& $select & ".txt") Then _FileReadToArray(@ScriptDir & "\Deployments\"& $select & ".txt",$temp) $im = 1 do GUICtrlCreateListViewItem($temp[$im],$ListView1) $im += 1 until $im = UBound($temp) endif Until $1 = $bound ProgressOff() ReDim $deployarray[1] GUISetState(@SW_enable,$Form4) GUISetState(@SW_enable,$Form1) GUISetState(@SW_show,$Form1) GUISetState(@SW_show,$Form4) case $import $location2 = FileOpenDialog($message,@ScriptDir, "ALL (*.*)", 1) If @error Then MsgBox(4096,"","No File(s) chosen");if there was no file selected state soand exit ContinueLoop EndIf _FileReadToArray($location2,$hostnames) if IsArray ($hostnames) then $im = 1 do GUICtrlSetData($List2,$hostnames[$im]) $im += 1 until $im = UBound($hostnames) Else MsgBox (0,"","No hostnames in the file specified") endif case $cancel GUIDelete($Form4) GUISetState(@SW_enable,$Form1) case $GUI_EVENT_CLOSE GUIDelete($Form4) GUISetState(@SW_enable,$Form1) EndSwitch endswitch WEnd EndFunc func _Installer();add $Form2 = GUICreate("Installer", 738, 160, 380, 154) $Label1 = GUICtrlCreateLabel("Installer Name: ", 16, 16, 112, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $INAME = GUICtrlCreateInput("", 128, 16, 585, 21, BitOR($GUI_SS_DEFAULT_INPUT,$WS_BORDER)) $Label2 = GUICtrlCreateLabel("Installer File: ", 16, 48, 97, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $location2 = GUICtrlCreateInput("", 129, 48, 551, 21, BitOR($GUI_SS_DEFAULT_INPUT,$WS_BORDER)) $file1 = GUICtrlCreateButton("...", 688, 48, 27, 25) $Label3 = GUICtrlCreateLabel("Switches: ", 16, 80, 73, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $switches1 = GUICtrlCreateInput("", 128, 80, 585, 21, BitOR($GUI_SS_DEFAULT_INPUT,$WS_BORDER)) $Label4 = GUICtrlCreateLabel("NOTE: Ensure you have selected the proper silent switches, otherwise the deployment may appear to hang indefinitely", 128, 104, 584, 17) GUICtrlSetColor(-1, 0xFF0000) $ok = GUICtrlCreateButton("OK", 645, 125, 27, 25) GuiCtrlSetState(-1, 512) $cancel = GUICtrlCreateButton("Cancel", 675, 125, 45, 25) GUISetState(@SW_SHOW) EndFunc func _edit($INAME1,$switches2,$location1) $Form3 = GUICreate("Installer", 738, 160, 380, 154) $Label1 = GUICtrlCreateLabel("Installer Name: ", 16, 16, 112, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $INAME = GUICtrlCreateInput($INAME1, 128, 16, 585, 21, BitOR($GUI_SS_DEFAULT_INPUT,$WS_BORDER)) $Label2 = GUICtrlCreateLabel("Installer File: ", 16, 48, 97, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $location2 = GUICtrlCreateInput($location1, 129, 48, 551, 21, BitOR($GUI_SS_DEFAULT_INPUT,$WS_BORDER)) $file1 = GUICtrlCreateButton("...", 688, 48, 27, 25) $Label3 = GUICtrlCreateLabel("Switches: ", 16, 80, 73, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $switches1 = GUICtrlCreateInput($switches2, 128, 80, 585, 21, BitOR($GUI_SS_DEFAULT_INPUT,$WS_BORDER)) $Label4 = GUICtrlCreateLabel("NOTE: Ensure you have selected the proper silent switches, otherwise the deployment may appear to hang indefinitely", 128, 104, 584, 17) GUICtrlSetColor(-1, 0xFF0000) $ok = GUICtrlCreateButton("OK", 645, 125, 27, 25) GuiCtrlSetState(-1, 512) $cancel = GUICtrlCreateButton("Cancel", 675, 125, 45, 25) GUISetState(@SW_SHOW) EndFunc func _Deploy() $Form4 = GUICreate("Targets", 406, 355, 192, 124) GUICtrlCreateLabel("Insert Hostname / IP",8,2) $Import = GUICtrlCreateButton("Import", 320, 16, 75, 25);,$WS_DISABLED) $add1 = GUICtrlCreateButton("Add", 280, 16, 35, 25) GuiCtrlSetState(-1, 512) $List2 = GUICtrlCreateList("", 8, 48, 385, 253) $deploy = GUICtrlCreateButton("Deploy Now", 240, 304, 75, 25) $cancel = GUICtrlCreateButton("Cancel", 320, 304, 75, 25) $hostname = GUICtrlCreateInput("", 8, 16, 265, 21) $deployC = GUICtrlCreateLabel($command1, 8, 330,400, 21) GUICtrlSetFont(-1, 10, 200, 0, "MS Sans Serif") GUISetState(@SW_SHOW) endfunc Func _FileCopy($fromFile,$tofile);function for the file copy.. uses the built in file copy shell app. Local $FOF_RESPOND_YES = 16 Local $FOF_SIMPLEPROGRESS = 256 $winShell = ObjCreate("shell.application") $winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES) EndFunc Func _ComputerGetSoftware(ByRef $aSoftwareInfo) ProgressOn("Software Query","test","") Local Const $UnInstKey = "\\" & $aComputer & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" Local $i = 1 Dim $aSoftwareInfo[1][3] For $j = 1 To 500 ProgressSet($j / 5,$aComputer,"Software Query") $AppKey = RegEnumKey($UnInstKey, $j) If @error <> 0 Then Exitloop If RegRead($UnInstKey & "\" & $AppKey, "DisplayName") = '' Then ContinueLoop ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][3] $aSoftwareInfo[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3) $aSoftwareInfo[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3) $aSoftwareInfo[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3) $i = $i + 1 Next ProgressOff() $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1 If $aSoftwareInfo[0][0] < 1 Then SetError(1, 1, 0) Return _ArraySort($aSoftwareInfo) EndFunc ;---------------------------------------------------------------------------------------------------------- ; Com Error Handler ;---------------------------------------------------------------------------------------------------------- Func MyErrFunc() Local $HexNumber Local $strMsg $HexNumber = Hex($oMyError.Number, 8) $strMsg = "Error Number: " & $HexNumber & @CRLF $strMsg &= "WinDescription: " & $oMyError.WinDescription & @CRLF $strMsg &= "Script Line: " & $oMyError.ScriptLine & @CRLF MsgBox(0, "ERROR", $strMsg) SetError(1) Endfunc Added remote software viewer tab.. EDIT: added the documentation i used when I built the app.. Edited June 15, 2018 by myk3 Share this post Link to post Share on other sites
lsakizada 0 Posted May 4, 2011 hi, missing include file: filelist.au3 Where to get it? C:\Documents and Settings\Desktop\New AutoIt v3 Script (2).au3(22,10) : ERROR: can't open include file "filelist.au3" #include "filelist.au3" Be Green Now or Never (BGNN)! Share this post Link to post Share on other sites
myk3 0 Posted May 4, 2011 (edited) I have updated the first post with links to PsExec and the filelist.au3 Edited May 4, 2011 by myk3 Share this post Link to post Share on other sites