Jump to content

Psexec with Autoti


Dipesh18
 Share

Recommended Posts

Local $execPath = @ScriptDir & '\PsExec.exe'

Local $valid = True

Local $username = "admin"

Local $password = "admin"

Local $computer = "ipadd.csv"

Run(@ComSpec & " /c " & $execPath & ' \\' & $computer & ' -u ' & $username & ' -p ' & $password & 'java.exe /qn')

If @error Then $valid = False

$n = @error

;Return $valid

MsgBox(0, $computer, $valid & " " & $n)

i have 15 ip list in ipadd.csv i want to start install java.exe in 15 computer at time not one by one.

PLS GUIED ME. & yes error msg show window name with "ipadd.csv" that i want ipaddress.

Link to comment
Share on other sites

You could save all the returning into one string variable and print that on the end.

Dim $string
For $i = 0 To $xy
  Run(@ComSpec & " /c " & $execPath & ' ' & $computer & ' -u ' & $username & ' -p ' & $password & 'java.exe /qn')

  If @error Then $valid = False
      $n = @error
      ;Return $valid 
      $string &= $computer & ": " & $valid & " " & $n & @CRLF
  EndIf
Next
MsgBox(0,"Returns:", $string)
Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

Once again without the error.

It was just meant as an example...

Dim $string
For $i = 0 To $xy
  Run(@ComSpec & " /c " & $execPath & ' ' & $computer & ' -u ' & $username & ' -p ' & $password & 'java.exe /qn')

  If @error Then 
      $valid = False
      $n = @error
      $string &= $computer & ": " & $valid & " " & $n & @CRLF
  EndIf
Next
MsgBox(0,"Returns:", $string)

Search the forum for multi-thread you may find a solution.

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

Thanks for the reply bro..

Dear @Danny35d & @Colyn1337

i know this commands but it will run one by one.. have 150 pc's with 30 pcs labs, if any error come in 2nd machine it will stop whole chain...(it always wait for 0 or 1 error) if nothing happen it will stop all things.....

So for that i want to start Parallel execution on 30 pcs at time.... so if one machine get error other installation going smooth..

Link to comment
Share on other sites

Thanks for the reply bro..

Dear @Danny35d & @Colyn1337

i know this commands but it will run one by one.. have 150 pc's with 30 pcs labs, if any error come in 2nd machine it will stop whole chain...(it always wait for 0 or 1 error) if nothing happen it will stop all things.....

So for that i want to start Parallel execution on 30 pcs at time.... so if one machine get error other installation going smooth..

You can use switch -d so PSEXEC.EXE won't wait for the process to finish and continue with the next computer in the list. Any way the code below is a PsexecGui that I created with the help of AutoIt Forum to push script over the network, you can manually add computer names or load a list of computer names or scan a domain for computer in the network. It also allow you to save settings so you can re-use them again, once you click execute it will push the jobs to all the computers from the list.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=PsexecGUIMenu.exe
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#NoTrayIcon
#include <Crypt.au3>
#include <Constants.au3>
#include <ButtonConstants.au3>
#include <ButtonConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <StatusBarConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
#include <GuiListView.au3>
#include <file.au3>
#include <GuiTab.au3>
#include <IE.au3>

;FileInstall('.\Include\Psexec.exe', @TempDir & '\')

Global Const $SV_TYPE_WORKSTATION = 0x1
Global Const $SV_TYPE_SERVER = 0x2
Global Const $SV_TYPE_SQLSERVER = 0x4
Global Const $SV_TYPE_DOMAIN_CTRL = 0x8
Global Const $SV_TYPE_DOMAIN_BAKCTRL = 0x10
Global Const $SV_TYPE_TIME_SOURCE = 0x20
Global Const $SV_TYPE_AFP = 0x40
Global Const $SV_TYPE_NOVELL = 0x80
Global Const $SV_TYPE_DOMAIN_MEMBER = 0x100
Global Const $SV_TYPE_PRINTQ_SERVER = 0x200
Global Const $SV_TYPE_DIALIN_SERVER = 0x400
Global Const $SV_TYPE_XENIX_SERVER = 0x800
Global Const $SV_TYPE_NT = 0x1000
Global Const $SV_TYPE_WFW = 0x2000
Global Const $SV_TYPE_SERVER_MFPN = 0x4000
Global Const $SV_TYPE_SERVER_NT = 0x8000
Global Const $SV_TYPE_POTENTIAL_BROWSER = 0x10000
Global Const $SV_TYPE_BACKUP_BROWSER = 0x20000
Global Const $SV_TYPE_MASTER_BROWSER = 0x40000
Global Const $SV_TYPE_DOMAIN_MASTER = 0x80000
Global Const $SV_TYPE_WINDOWS = 0x400000
Global Const $SV_TYPE_CLUSTER_NT = 0x1000000
Global Const $SV_TYPE_TERMINALSERVER = 0x2000000
Global Const $SV_TYPE_CLUSTER_VS_NT = 0x4000000
Global Const $SV_TYPE_LOCAL_LIST_ONLY = 0x40000000
Global Const $SV_TYPE_DOMAIN_ENUM = 0x80000000
Global Const $SV_TYPE_ALL = 0xFFFFFFFF
Global Const $PsExecReg = 'HKCU\Software\Sysinternals\PsExec'

Local $DomainList = _NetServerEnum($SV_TYPE_DOMAIN_ENUM)
$DomainList = _ArrayToString($DomainList, '|', 1)

;~ $PS = 'psexec.exe'
$TOOLS = GUICreate("PSexec GUI", 532, 455, -1, -1, $WS_SYSMENU)

$filemenu = GUICtrlCreateMenu("&File")
$loaditem = GUICtrlCreateMenuItem("Load", $filemenu)
$saveitem = GUICtrlCreateMenuItem("Save", $filemenu)
$exititem = GUICtrlCreateMenuItem("Exit", $filemenu)
$helpmenu = GUICtrlCreateMenu("?")
$helpitem = GUICtrlCreateMenuItem("Help", $helpmenu)

$App = GUICtrlCreateInput("", 8, 24, 201, 21)
$Browse1 = GUICtrlCreateButton("Browse", 218, 23, 75, 23, 0)
$PL2 = GUICtrlCreateLabel("Application to run on remote PC", 8, 6, 184, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$CLO = GUICtrlCreateInput("", 8, 67, 289, 21)
$PL3 = GUICtrlCreateLabel("Command line parameters", 8, 50, 148, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$PL4 = GUICtrlCreateLabel("Admin User Name", 8, 95, 124, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$PL5 = GUICtrlCreateLabel("Admin Password", 155, 95, 124, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Usrnm = GUICtrlCreateInput("", 8, 112, 143, 21)
$Pw = GUICtrlCreateInput("", 155, 112, 143, 21, $ES_PASSWORD)
$PCH8 = GUICtrlCreateCheckbox("Run process as limited user", 16, 138, 225, 17)
$PCH9 = GUICtrlCreateCheckbox("Does not load the specified account's profile", 16, 154, 226, 17)
$Group1 = GUICtrlCreateGroup("Parameters", 8, 178, 289, 225)
$PCH1 = GUICtrlCreateCheckbox("Interact with the users desktop", 16, 194, 185, 17)
$PCH2 = GUICtrlCreateCheckbox("Run application in the system account", 16, 210, 225, 17)
$PCH3 = GUICtrlCreateCheckbox("Copy file to remote", 16, 226, 113, 17)
$Group2 = GUICtrlCreateGroup("Copy Options", 40, 245, 250, 54)
$PCH4 = GUICtrlCreateRadio("Overwrite existing file", 48, 261, 121, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$PCH5 = GUICtrlCreateRadio("Copy file only if it is a higher version or newer", 48, 278, 241, 17)
$PCH6 = GUICtrlCreateCheckbox("Don't wait for the process to terminate", 16, 300, 225, 17)
$SliderLbl = GUICtrlCreateLabel('Timeont Connecting To Remote 15 Secs.', 16, 318, 275, 21, $SS_CENTER)
$Slider = GUICtrlCreateSlider(16, 335, 275, 21)
GUICtrlSetLimit(-1, 120, 1)
GUICtrlSetData(-1, 15)

$Wkd = GUICtrlCreateInput("", 16, 378, 201, 21)
$Browse3 = GUICtrlCreateButton("Browse", 220, 377, 75, 23, 0)
GUICtrlCreateLabel("Working directory on remote PC", 16, 360, 184, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$PT1 = GUICtrlCreateTab(304, 8, 217, 313)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
$PTS1 = GUICtrlCreateTabItem("Enter Name")
$RPC = GUICtrlCreateInput("", 312, 56, 137, 21)
$PL6 = GUICtrlCreateLabel("Remote PC name (or add PC to the list)", 312, 32, 188, 17)
$Add = GUICtrlCreateButton("Add", 456, 54, 41, 25, 0)
$List0 = GUICtrlCreateListView("", 310, 85, 200, 200, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT, $WS_VSCROLL))
_GUICtrlListView_InsertColumn($List0, 0, "Machine name or IP", 200)
_GUICtrlListView_SetExtendedListViewStyle($List0, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
$Rms1 = GUICtrlCreateButton("Remove from list", 310, 287, 100, 25, 0)
$Clr1 = GUICtrlCreateButton("Clear list", 440, 287, 70, 25, 0)
$PTS2 = GUICtrlCreateTabItem("Load PC List")
$PL7 = GUICtrlCreateLabel("Load text file (one pc name per line)", 312, 34, 172, 17)
$CL = GUICtrlCreateInput("", 312, 56, 156, 21)
$Browse2 = GUICtrlCreateButton("Browse", 470, 54, 41, 25, 0)
$List1 = GUICtrlCreateListView("", 310, 85, 200, 200, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT, $WS_VSCROLL))
_GUICtrlListView_InsertColumn($List1, 0, "Machine name or IP", 200)
_GUICtrlListView_SetExtendedListViewStyle($List1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
$Rms2 = GUICtrlCreateButton("Remove From List", 310, 287, 100, 25, 0)
$Clr2 = GUICtrlCreateButton("Clear List", 440, 287, 70, 25, 0)


$PTS3 = GUICtrlCreateTabItem("Browse Net")
GUICtrlCreateLabel("Select Domain", 330, 38, 172, 17)
$PCB2 = GUICtrlCreateCombo("", 310, 56, 121, 21)
GUICtrlSetData($PCB2, $DomainList)
$List2 = GUICtrlCreateListView("", 310, 85, 200, 200, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT, $WS_VSCROLL))
_GUICtrlListView_InsertColumn($List2, 0, "Machine name or IP", 200)
_GUICtrlListView_SetExtendedListViewStyle($List2, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
$Rms3 = GUICtrlCreateButton("Remove from list", 310, 287, 100, 25, 0)
$Clr3 = GUICtrlCreateButton("Clear list", 440, 287, 70, 25, 0)


GUICtrlCreateTabItem("")
$PL11 = GUICtrlCreateLabel("Thread priority:", 350, 325, 74, 17)
$PCB1 = GUICtrlCreateCombo("", 428, 323, 90, 17)
GUICtrlSetData($PCB1, "Low|Below Normal|Normal|Above Normal|High|Real Time")
_GUICtrlComboBox_SetCurSel($PCB1, 2)
$LOG = GUICtrlCreateButton("View Log", 374, 370, 70, 25, 0)
$EX = GUICtrlCreateButton("Execute", 445, 370, 70, 25, 0)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUISetState(@SW_SHOW)

If RegRead($PsExecReg, 'EulaAccepted') = '' Then RegWrite($PsExecReg, 'EulaAccepted', 'REG_DWORD', 1)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
     Case $GUI_EVENT_CLOSE, $exititem
         FileDelete(@TempDir & '\Psexec.exe')
         FileDelete(@TempDir & '\Psexec.log')
         ExitLoop
     Case $LOG
         ShellExecute(@TempDir & '\Psexec.log', '', @TempDir)
     Case $loaditem
         $sFileName = FileOpenDialog('', "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", '(*.Exec)', 3, '', $TOOLS)
         If @error Then ContinueLoop

         GUICtrlSetState($PCH3, IniRead($sFileName, 'Settings', 'c', ''))
         GUICtrlSetState($PCH6, IniRead($sFileName, 'Settings', 'd', ''))
         GUICtrlSetState($PCH9, IniRead($sFileName, 'Settings', 'e', ''))
         GUICtrlSetState($PCH4, IniRead($sFileName, 'Settings', 'f', ''))
         GUICtrlSetState($PCH1, IniRead($sFileName, 'Settings', 'i', ''))
         GUICtrlSetState($PCH8, IniRead($sFileName, 'Settings', 'l', ''))
         GUICtrlSetData($SliderLbl, 'Timeount Connecting To Remote ' & IniRead($sFileName, 'Settings', 'n', '') & ' Secs.')
         GUICtrlSetData($Slider, Number(IniRead($sFileName, 'Settings', 'n', '')))

         GUICtrlSetData($Pw, BinaryToString(_Crypt_DecryptData(IniRead($sFileName, 'Settings', 'p', ''), $sFileName, $CALG_RC4)))

         GUICtrlSetState($PCH2, IniRead($sFileName, 'Settings', 's', ''))
         GUICtrlSetData($Usrnm, IniRead($sFileName, 'Settings', 'u', ''))
         GUICtrlSetState($PCH5, IniRead($sFileName, 'Settings', 'v', ''))
         GUICtrlSetData($Wkd, IniRead($sFileName, 'Settings', 'w', ''))
         GUICtrlSetData($PCB1, IniRead($sFileName, 'Settings', 'priority', ''))
         GUICtrlSetData($App, IniRead($sFileName, 'Settings', 'Application', ''))
         GUICtrlSetData($CLO, IniRead($sFileName, 'Settings', 'Parameters', ''))

         $list = Eval('List' & _GUICtrlTab_GetCurSel($PT1))
         $aCompList = IniReadSection($sFileName, 'ComputerList')
         If IsArray($aCompList) Then
             Clear($list)
             For $item = 1 To $aCompList[0][0]
                 _GUICtrlListView_AddItem($list, $aCompList[$item][1])
             Next
         EndIf
     Case $saveitem
         $sFileName = FileSaveDialog('', "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", '(*.Exec)', 18, '', $TOOLS)
         If @error Then ContinueLoop
         If Not StringInStr($sFileName, '.Exec') Then $sFileName &= '.Exec'

         _Crypt_Startup()
         $hKey = _Crypt_DeriveKey($sFileName, $CALG_RC4)

         IniWrite($sFileName, 'Settings', 'c', GUICtrlRead($PCH3))
         IniWrite($sFileName, 'Settings', 'd', GUICtrlRead($PCH6))
         IniWrite($sFileName, 'Settings', 'e', GUICtrlRead($PCH9))
         IniWrite($sFileName, 'Settings', 'f', GUICtrlRead($PCH4))
         IniWrite($sFileName, 'Settings', 'i', GUICtrlRead($PCH1))
         IniWrite($sFileName, 'Settings', 'l', GUICtrlRead($PCH8))
         IniWrite($sFileName, 'Settings', 'n', GUICtrlRead($Slider))

         IniWrite($sFileName, 'Settings', 'p', _Crypt_EncryptData(GUICtrlRead($Pw), $hKey, $CALG_USERKEY))

         IniWrite($sFileName, 'Settings', 's', GUICtrlRead($PCH2))
         IniWrite($sFileName, 'Settings', 'u', GUICtrlRead($Usrnm))
         IniWrite($sFileName, 'Settings', 'v', GUICtrlRead($PCH5))
         IniWrite($sFileName, 'Settings', 'w', GUICtrlRead($Wkd))
         IniWrite($sFileName, 'Settings', 'priority', _GUICtrlComboBox_GetEditText($PCB1))
         IniWrite($sFileName, 'Settings', 'Application', GUICtrlRead($App))
         IniWrite($sFileName, 'Settings', 'Parameters', StringStripWS(GUICtrlRead($CLO), 3))

         $list = Eval('List' & _GUICtrlTab_GetCurSel($PT1))
         $IC = _GUICtrlListView_GetItemCount($list)
         For $item = 0 To $IC - 1
             IniWrite($sFileName, 'ComputerList', $item, _GUICtrlListView_GetItemText(GUICtrlGetHandle($list), $item))
         Next
         _Crypt_DestroyKey($hKey)
         _Crypt_Shutdown()
     Case $Slider
         GUICtrlSetData($SliderLbl, 'Timeount Connecting To Remote ' & GUICtrlRead($Slider) & ' Secs.')
     Case $Browse1, $Browse2
         ;If browse buttong is selected will read selection and set data to input box
         $FileFullName = FileOpenDialog("Browse", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "All Files (*.*)")
         If @error Then ContinueLoop
         If $nMsg = $Browse1 Then
             GUICtrlSetData($App, $FileFullName)
         Else
             GUICtrlSetData($CL, $FileFullName)
             $PCL = GUICtrlRead($CL)
             If $PCL <> "" Then load($PCL)
         EndIf
     Case $Browse3
         $FolderName = FileSelectFolder("Browse", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 2)
         If @error Then ContinueLoop
         GUICtrlSetData($Wkd, $FolderName)
     Case $PCB2
         clear($List2)
         $CursorID = MouseGetCursor()
         GUICtrlSetCursor($List2, 15)
         $aCompList = _NetServerEnum($SV_TYPE_WORKSTATION, _GUICtrlComboBox_GetEditText($PCB2))
         If IsArray($aCompList) Then
             For $x = 1 To $aCompList[0]
                 _GUICtrlListView_AddItem($List2, $aCompList[$x])
             Next
         EndIf
         GUICtrlSetCursor($List2, $CursorID)
     Case $Add
         ;check if remote computer was specified
         $PC = GUICtrlRead($RPC)
         _GUICtrlListView_AddItem($List0, $PC)
         GUICtrlSetData($RPC, "")
         GUICtrlSetState($RPC, $GUI_FOCUS)
     Case $Clr1, $Clr2, $Clr3
         ;Clears list1 on Enter name tab if clear button is pressed
         $ClearList = Eval('List' & _GUICtrlTab_GetCurSel($PT1))
         Clear($ClearList)
     Case $Rms1, $Rms2, $Rms3
         ;removes selected item
         $ClearSelected = Eval('List' & _GUICtrlTab_GetCurSel($PT1))
         _GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($ClearSelected))
     Case $helpitem
         If Ping('www.google.com') = 0 Then
             Run(@ComSpec & ' /k ' & @TempDir & '\Psexec.exe /?', @TempDir, @SW_MAXIMIZE)
         Else
             _IECreate('http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx')
         EndIf
     Case $EX
Local $Switches = ''
         Local $d = '', $c = '', $v = '', $f = '', $e = '', $s = '', $i = '', $w = '', $l = '', $USN = '', $PAS = '', $TO = ''
         $CursorID = MouseGetCursor()
         GUISetCursor(15)
         ;reads app input box
         $AP = StringStripWS(GUICtrlRead($App), 3)
         ;Don't wait for process to terminate
         If BitAND(GUICtrlRead($PCH6), $GUI_CHECKED) = $GUI_CHECKED Then $Switches &= ' -d'
         ;Copy file to remote machine
         If BitAND(GUICtrlRead($PCH3), $GUI_CHECKED) = $GUI_CHECKED Then $Switches &= ' -c'
         ;Copy if newer or higher version
         If BitAND(GUICtrlRead($PCH5), $GUI_CHECKED) = $GUI_CHECKED And BitAND(GUICtrlRead($PCH3), $GUI_CHECKED) = $GUI_CHECKED Then $Switches &= ' -v'
         ;Overwrite existing file
         If BitAND(GUICtrlRead($PCH4), $GUI_CHECKED) = $GUI_CHECKED And BitAND(GUICtrlRead($PCH3), $GUI_CHECKED) = $GUI_CHECKED Then $Switches &= ' -f'
         ;Run application in the system account
         If BitAND(GUICtrlRead($PCH2), $GUI_CHECKED) = $GUI_CHECKED Then $Switches &= ' -s'
         ;Interact with the users desktop
         If BitAND(GUICtrlRead($PCH1), $GUI_CHECKED) = $GUI_CHECKED Then $Switches &= ' -i'
         ;Does not load the speified account's profile.
         If BitAND(GUICtrlRead($PCH9), $GUI_CHECKED) = $GUI_CHECKED Then $Switches &= ' -e'
         ;Run process as limeted user
         If BitAND(GUICtrlRead($PCH8), $GUI_CHECKED) = $GUI_CHECKED Then $Switches &= ' -l'
         ;reads any command line options were specified
         $CO = StringStripWS(GUICtrlRead($CLO), 3)
         ;Specifies what priority was selected
$Switches &= ' -' & StringLower(StringReplace(GUICtrlRead($PCB1), ' ', ''))
         ;Timeout connecting to remote machine
         $TO = ' -n ' & GUICtrlRead($Slider)
         ;Depending which tab is active create the correct computer list
         $list = Eval('List' & _GUICtrlTab_GetCurSel($PT1))
         ;checks if alternate username was specified
         If GUICtrlRead($Wkd) <> '' Then $Switches &= ' -w "' & GUICtrlRead($Wkd) & '"'
         $USN = GUICtrlRead($Usrnm)
         If $USN <> '' Then
             $USN = ' -u "' & GUICtrlRead($Usrnm) & '"'
             $PAS = ' -p ' & GUICtrlRead($Pw)
         EndIf
         ;Execution loop
         While 2
             If $AP = '' Then
                 MsgBox(0, "", "No application was specified.")
             Else
                 $IC = _GUICtrlListView_GetItemCount($list)
                 If $IC = 0 Then MsgBox(0, '', 'Need to add a computer name or ip to the list.')
                 If $IC > 1 Then ProgressOn('', 'Processing ', '', Default, Default)
                 For $item = 0 To $IC - 1
                     $FL = 'psexec.exe \\' & _GUICtrlListView_GetItemText(GUICtrlGetHandle($list), $item) & $USN & $PAS & $TO & $Switches & ' "' & $AP & '" ' & $CO
                     If $IC > 1 Then ProgressSet(Int(($item+1)/$IC*100), 'Step ' & $item + 1 & ' of ' & $IC, 'Processing ' & _GUICtrlListView_GetItemText(GUICtrlGetHandle($list), $item))
$ExitCode = RunWait(@TempDir & '\' & $FL, @TempDir, @SW_HIDE);, $STDERR_CHILD + $STDOUT_CHILD)
                     If $USN <> '' Then $FL = StringReplace($FL, $PAS, ' -p (password is not logged)')
                     _FileWriteLog(@TempDir & '\Psexec.log', $FL)
                     _FileWriteLog(@TempDir & '\Psexec.log', 'ErrorCode: ' & $ExitCode & ' ' & _GetExitCode($ExitCode) & @CRLF & @CRLF)
                 Next
                 If $IC > 1 Then ProgressOff()
             EndIf
             ExitLoop
         WEnd
         GUISetCursor($CursorID)
EndSwitch
WEnd

;load pc list from text file
Func Load($list)
$file = FileOpen($list, 0)
If $file = -1 Then
     MsgBox(0, 'Error', 'Unable To open file')
EndIf
While 2
     $FRPCL = FileReadLine($file)
     If @error = -1 Then ExitLoop
     _GUICtrlListView_AddItem($List1, $FRPCL)
WEnd
EndFunc ;==>Load

;clears array and list
Func Clear($listview)
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($listview))
EndFunc ;==>Clear

; Unknown programmer
Func _NetServerEnum ($iSrvType = -1, $sDomain = '')
Local $uBufPtr = DllStructCreate("ptr;int;int"), $res[1]=[0], $i
Local $uRecord = DllStructCreate("dword;ptr"), $iRecLen = DllStructGetSize($uRecord)
Local $uString = DllStructCreate("char[16]")
Local $uDomain = DllStructCreate("byte[32]"), $pDomain = 0
If Not ($sDomain='' Or $sDomain='*') Then
     DllStructSetData($uDomain, 1, StringToBinary($sDomain,2))
     $pDomain = DllStructGetPtr($uDomain)
EndIf
Local $ret = DllCall ("netapi32.dll", "int", "NetServerEnum", _
     "ptr", 0, "int", 100, _
     "ptr", DllStructGetPtr($uBufPtr,1), "int", -1, _
     "ptr", DllStructGetPtr($uBufPtr,2), _
     "ptr", DllStructGetPtr($uBufPtr,3), _
     "int", $iSrvType, "ptr", $pDomain, "int", 0 )
If $ret[0] Then Return SetError(1, $ret[0], '')
Local $res[DllStructGetData($uBufPtr,3)+1]=[DllStructGetData($uBufPtr,3)]
For $i=1 To DllStructGetData($uBufPtr,3)
     Local $uRecord = DllStructCreate("dword;ptr", DllStructGetData($uBufPtr,1)+($i-1)*$iRecLen)
     Local $sNBName = DllStructCreate("byte[32]", DllStructGetData($uRecord,2))
     DllStructSetData($uString,1,BinaryToString(DllStructGetData($sNBName,1),2))
     $res[$i] = DllStructGetData($uString,1)
Next
$ret = DllCall ("netapi32.dll", "int", "NetApiBufferFree", "ptr", DllStructGetData($uBufPtr,1))
Return $res
EndFunc

Func _GetExitCode($iExitCode)
Local $sLine = ''
$Pid = Run(@ComSpec & " /c net helpmsg " & $iExitCode, @SystemDir, @SW_HIDE, 2)
While 1
     $sLine &= StdoutRead($Pid)
     If @error Then ExitLoop
Wend
Return(StringStripWS(StringStripCR($sLine), 3))
EndFunc
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

Thanks for the reply bro..

Dear @Danny35d & @Colyn1337

i know this commands but it will run one by one.. have 150 pc's with 30 pcs labs, if any error come in 2nd machine it will stop whole chain...(it always wait for 0 or 1 error) if nothing happen it will stop all things.....

So for that i want to start Parallel execution on 30 pcs at time.... so if one machine get error other installation going smooth..

Ahhh.... Ok, I get you now...... I run into that problem with my vPro powermanagement scripts which run at night. I would recommend you put your action into a powershell script.

At the start of your ps script add:

$ErrorActionPreference="silentlyContinue"

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...