Jump to content

Odewallrus

Active Members
  • Posts

    20
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Odewallrus's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Thank you sooo very much! sorry about the tags it does read much better!
  2. I have looked and read for 2 days now without finding what I assume is a simple solution. Can someone please look at the codebelow and help me to understand why when the gui opens the controls on the default tab (tab1) do not show up unless another tab is selected and tab1 is re-selected. I am trying to get the controls to be available when the form opens. This code uses GUIScrollbars_Ex.au3 which I have attached if needed. and reads a MobileMan.ini file the contents wich are below. Thank you, [Groups] ActiveGroups=MobileTest,Mobile [Mobile] ActiveHosts=computer1,computer2,computer3,computer4 [MobileTest] ActiveHosts=computer5,computer6 #include <GuiConstants.au3> #include <GuiEdit.au3> #Include <Date.au3> #include <GUIScrollbars_Ex.au3> #include <Array.au3> $Logfile = @ScriptDir & '\' & @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & "-" & @min & "-" & @SEC & "_" & 'MobileMan.log' Global $aHosts[1][18] = [[0, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",""]] ;~ Create Gui $sTitle = "Mobile Management Console" $sINI = @ScriptDir & "\MobileMan.ini" $GUI = GUICreate($sTitle,900, 570, -1, -1) $MessageMenu = GUICtrlCreateMenu("&File") $HelpMenu = GUICtrlCreateMenu("Help") GUICtrlCreateTab(160,10,730,310) $tabFreeform = GUICtrlCreateTabItem("tab1") $tabInpMessage = GUICtrlCreateInput("Enter text here...", 180,50,400,40, $ES_MULTILINE ) GUICtrlCreateTabItem("tab2") GUICtrlCreateTabItem("tab3") GUICtrlCreateTabItem("tab4") GUISetState() ;~ Create Child gui $cGUI = GUICreate("Child GUI", 140,525,10,10, $WS_CHILD, $WS_EX_CLIENTEDGE, $Gui) GUICtrlSetResizing($cGUI, $GUI_DOCKALL) Opt("GUICoordMode", 2) $GrpCord = GUISetCoord(5,5) $bToggleAll = GUICtrlCreateButton("Toggle All", -1, 1, 115, 20) GUISetState() FileOpen($Logfile,1) FileWrite($Logfile, _Now() & " - Session started" & @CRLF) ;~ Read ini $aGroups = IniReadSection($sINI, "Groups") If @error Then MsgBox(16, "Error", "Failed to read 'Groups' section.") FileWrite($Logfile, _Now() & " - Failed to read 'Groups' section" & @CRLF) Exit EndIf If ($aGroups[0][0] >= 1) And ($aGroups[1][0] = "ActiveGroups") Then $aActiveGroups = StringSplit($aGroups[1][1], ",") If ($aActiveGroups[0] = 1) And (StringStripWS($aActiveGroups[1], 8) = "") Then Dim $aActiveGroups[1] = [0] Else MsgBox(16, "Error", "Missing or invalid Groups keys.") FileWrite($Logfile, _Now() & " - Missing or invalid Groups keys" & @CRLF) Exit EndIf For $g = 1 To $aActiveGroups[0] $sGroupName = $aActiveGroups[$g] $aGroupSection = IniReadSection($sINI, $sGroupName) If @error Then MsgBox(16, "Error", "Failed to read groups section: '" & $sGroupName & "'.") FileWrite($Logfile, _Now() & " - Failed to read groups section: '" & $sGroupName & "'" & @CRLF) ContinueLoop EndIf If ($aGroupSection[0][0] >= 1) And ($aGroupSection[1][0] = "ActiveHosts") Then $aActiveHosts = StringSplit($aGroupSection[1][1], ",") If ($aActiveHosts[0] = 1) And (StringStripWS($aActiveHosts[1], 8) = "") Then Dim $aActiveHosts[1] = [0] For $h = 1 To $aActiveHosts[0] _AddActiveHost($sGroupName, $aActiveHosts[$h]) Next Else MsgBox(16, "Error", "Missing or invalid keys in group: '" & $sGroupName & "'.") FileWrite($Logfile, _Now() & " - Missing or invalid keys in group: '" & $sGroupName & "'." & @CRLF) ContinueLoop EndIf Next Dim $GrpButton[($aActiveGroups[0] + 1)] $Btn_Start = GUICtrlCreateDummy() For $g = 1 To $aActiveGroups[0] $GrpButton[$g] = GUICtrlCreateButton($aActiveGroups[$g],-1, 1, 115, 20) FileWrite($Logfile, _Now() & " - Group created: '" & $aActiveGroups[$g] & "'" & @CRLF) For $n = 1 To $aHosts[0][0] if $aActiveGroups[$g] = $aHosts[$n][0] then $aHosts[$n][2] = GUICtrlCreateCheckbox($aHosts[$n][1],-1,0,130,15) if $aActiveGroups[$g] = $aHosts[$n][0] then FileWrite($Logfile, _Now() & " - Host created: '" & $aHosts[$n][1] & "'") if $aActiveGroups[$g] = $aHosts[$n][0] then $aHosts[$n][3] = IniRead($sINI, $aActiveGroups[$g], 'Share','C$') ;~ if $aActiveGroups[$g] = $aHosts[$n][0] then $aHosts[$n][4] = ping ($aHosts[$n][1],$PingTimeout) ;~ if not $aHosts[$n][4] = 1 then GUICtrlSetState ($aHosts[$n][2],$GUI_DISABLE) if $aHosts[$n][4] = 1 then GUICtrlSetState ($aHosts[$n][2],$GUI_ENABLE) if $aActiveGroups[$g] = $aHosts[$n][0] and not $aHosts[$n][4] = 1 then FileWrite($Logfile, " -DISABLED" & @CRLF) Elseif $aActiveGroups[$g] = $aHosts[$n][0] Then FileWrite($Logfile, @CRLF) EndIf Next Next $Btn_End = GUICtrlCreateDummy() _GUIScrollbars_Generate($cGUI, 0, ($n * 15) + ($g * 21)) ;number of checkboxes in the list * 15 pixels (height of the checkbox + spacing ???) GUISetState() ;~ _ArrayDisplay($aActiveGroups) ;~ _ArrayDisplay($aHosts) While 1 $msg = GUIGetMsg() Switch $msg ;~ If $msg = $GUI_EVENT_CLOSE Then Case $GUI_EVENT_CLOSE Exit ;~ ElseIf $msg = $bToggleAll Then Case $bToggleAll For $n = 1 To $aHosts[0][0] If $aHosts[$n][0] = True Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsEnabled") Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsChecked") Then ControlCommand($cGUI, "", $aHosts[$n][2], "Uncheck") Else ControlCommand($cGUI, "", $aHosts[$n][2], "Check") EndIf EndIf EndIf Next Case $bToggleAll For $n = 1 To $aHosts[0][0] If $aHosts[$n][0] = True Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsEnabled") Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsChecked") Then ControlCommand($cGUI, "", $aHosts[$n][2], "Uncheck") Else ControlCommand($cGUI, "", $aHosts[$n][2], "Check") EndIf EndIf EndIf Next Case $Btn_Start To $Btn_End For $n = 1 To $aHosts[0][0] If $aHosts[$n][0] = GUICtrlRead($Msg) Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsEnabled") Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsChecked") Then ControlCommand($cGUI, "", $aHosts[$n][2], "Uncheck") Else ControlCommand($cGUI, "", $aHosts[$n][2], "Check") EndIf EndIf EndIf Next EndSwitch WEnd Func _AddActiveHost($sGrp, $sHost) ReDim $aHosts[UBound($aHosts) + 1][UBound($aHosts, 2)] ; Resize the array $aHosts[0][0] = UBound($aHosts) - 1 ; Save count in [0][0] $aHosts[$aHosts[0][0]][0] = $sGrp ; Put group in [n][0] $aHosts[$aHosts[0][0]][1] = $sHost ; Put host in [n][1] EndFunc ;==>_AddActiveHostGUIScrollbars_Ex.au3
  3. sorry it took so long to respond.... $sActSec[$h][10] = full path to a zip file if the option to compress the source files has been set. ex. C:LogArchive2012-05-22_08-58-16_ComputernameSourceDirectory_2012-05-22_08-58-16_Computername.zip $sSrvShare & '' & $sActSec[$h][3] & '' = LogServerShare & '' & OrigionalDirectoryName & '' $sSrvShare = LOGSERVERARCHIVE $sActSec[$h][3] = PBWEB
  4. I have this script functional for some time now and recently it has stopped functioning on the FileMove. I have tried FileCopy with the same results. I originally had the FileMove going to a UNC path with no problems. During testing I set it to a mapped drive. When testing this by running the script sometimes it works sometimes it does not. I had this running from a scheduled task in windows for over a year with minimal to no problems. The task has correct credentials and run with highest privileges set. The destination share is on a NAS and has been verified to have proper privileges. You can manually create directories and copy manually with no issues. I have looked up and down this site and nothing seems to address this exact ally. Please help… ;~ completes a dirmove or filemove of the collected/zipped files based on the ini file, archiving them to a server share For $h = 1 to $sActSec[0][0] If $sActSec[$h][4] = 1 And FileExists($sActSec[$h][10]) then $sDirSize = DirGetSize($sTmpRoot & '\' & $sDTStamp & '\' & $sActSec[$h][0], 1) $sFileSize = FileGetSize($sActSec[$h][10]) FileWriteLine($sLogFile, ' ' & $sActSec[$h][0] & ' Section archive:') FileWriteLine($sLogFile, ' Files: ' & $sDirSize[1]) FileWriteLine($sLogFile, ' Origional directory size (MB): ' & Round($sDirSize[0] / 1048576, 1)) FileWriteLine($sLogFile, ' Local compressed file size (MB): ' & Round($sFileSize / 1048576, 1)) $Answer = FileMove($sActSec[$h][10], $sSrvShare & '\' & $sActSec[$h][3] & '\',8) If $answer = 1 then FileWriteLine($sLogFile, 'SUCCESS- FileMove ' & $sActSec[$h][10] & ' ' & $sSrvShare & '\' & $sActSec[$h][3] & '\') $answer = DirRemove($sTmpBaseDir & '\' & $sActSec[$h][0],1) If $answer = 1 then FileWriteLine($sLogFile, 'SUCCESS- DirRemove ' & $sTmpBaseDir & '\' & $sActSec[$h][0]) If $answer = 0 Then FileWriteLine($sLogFile, 'FAILED- DirRemove ' & $sTmpBaseDir & '\' & $sActSec[$h][0]) FileWriteLine($sLogFile, @CRLF) ElseIf $answer = 0 then FileWriteLine($sLogFile, 'FAILED- FileMove ' & $sActSec[$h][10] & ' ' & $sSrvShare & '\' & $sActSec[$h][3] & '\') FileWriteLine($sLogFile, @CRLF) EndIf ElseIf FileExists($sTmpBaseDir & '\' & $sActSec[$h][0] & '\') Then $sDirSize = DirGetSize($sTmpRoot & '\' & $sDTStamp & '\' & $sActSec[$h][0], 1) FileWriteLine($sLogFile, ' ' & $sActSec[$h][0] & ' Section archive:') FileWriteLine($sLogFile, ' Files: ' & $sDirSize[1]) FileWriteLine($sLogFile, ' Origional directory size (MB): ' & Round($sDirSize[0] / 1048576, 1)) $Answer = DirMove($sTmpBaseDir & '\' & $sActSec[$h][0], $sSrvShare & '\' & $sActSec[$h][3] & '\' & $sActSec[$h][3] & '_' & $sDTStamp) If $answer = 1 then FileWriteLine($sLogFile, 'SUCCESS- DirMove ' & $sTmpBaseDir & '\' & $sActSec[$h][0] & ' ' & $sSrvShare & '\' & $sActSec[$h][3] & '\' & $sActSec[$h][3] & '_' & $sDTStamp) If $answer = 0 then FileWriteLine($sLogFile, 'FAILED- DirMove ' & $sTmpBaseDir & '\' & $sActSec[$h][0] & ' ' & $sSrvShare & '\' & $sActSec[$h][3] & '\' & $sActSec[$h][3] & '_' & $sDTStamp) FileWriteLine($sLogFile, @CRLF) EndIf $pbArchivePercent = $pbArchivePercent + $pbArchiveStep GUICtrlSetData($pb, $pbArchivePercent) Next
  5. Yes, I had tried that as well with no luck.
  6. I have a compiled script that is being installed on a computer via PsExec. 3 exe's are being copied to a remote computer: Client.exe (main app) ClientMon.exe (monitor for the main app to restart if the user shuts it down) ClientStart.exe (application to start both Client.exe and ClientMon.exe and handle install and uninstall. Does not run once the other 2 apps are started) My problem is that when I remote execute the ClientStart.exe with: RunWait(@ComSpec & " /c " & 'PSexec.exe -i -s \\' & $aHosts[$p][1] & ' "c:\Program Files\Client\ClientStart.exe"') My Client.exe is unable to write to an ini file on a \\computer\share It is able to read the file. It is not a securities issue on the share. Once the remote computer is rebooted, the Client.exe starts under the logged in users account from the “RUN” Registry key instead of the system account and everything works fine. I have tried multiple switch combinations on PsExec with no luck, and I am not sure why. Is there a way to have my ClientStart.exe execute the 2 apps under the currently logged on users account? I am open to any solution that will make my app read and write to the share.
  7. Excelent. Thank you. I have it working.
  8. Sorry, I should have been more clear... I am looking to update a scrolling marquis (update function) from a GUICtrlCreateInput field on the same AutoIt GUI. I would like to call my Function to update the marquis when the cursor exits the Input field. I am open to other suggestions as well if there is a better way of doing this. With my current level this was my direction. Thank you for your assistance.
  9. Can some tell me how I can run a function when focus on an input field is lost? I have searched the help and forum and I am sure I am missing something easy.
  10. Can someone please help me with why this code is not adding a column to the array? I have used it in the past, but cannot seem to figure out what I am missing here. $sINI = @ScriptDir & "\FileBackup.ini" $iSource = IniReadSection($sINI, "Source" Global $FileArray[1] $FileArray[0]="0" For $s = 1 To $iSource[0][0] $iTypes = StringSplit($iSource[$s][1],",",0) For $t = 1 To $iTypes[0] $fArray = _FileListToArray_Recursive($iSource[$s][0], "", $iTypes[$t], "", 1, 2, True) _ArrayConcatenate($FileArray,$fArray,1) Next Next $aRows = UBound($FileArray) $FileArray[0] = $aRows - 1 _ArrayAdd_Column($FileArray) _ArrayDisplay($FileArray, "Debug: $FileArray") Func _ArrayAdd_Column($Array) Local $aTemp[UBound($Array)][UBound($Array, 0) + 1] For $i = 0 To UBound($Array) - 1 For $j = 0 To UBound($Array, 0) - 1 If UBound($Array, 0) = 1 Then $aTemp[$i][0] = $Array[$i] If UBound($Array, 0) > 1 Then $aTemp[$i][$j] = $Array[$i][$j] Next Next Return $aTemp EndFunc ;==>_ArrayAdd_Column
  11. Anyone heard of a way to control the master volume on a remote machine? I have a computer that controls a radio interface. The computer is locked in a server room but the volume level needs to be accessed by personnel without access to this machine. If there is nothing available any ideas on a starting point? Sorry... I searched prior to posting. This looks like a very good starting point! http://www.autoitscript.com/forum/index.php?showtopic=80154&st=0&p=577004&hl=volume%20control&fromsearch=1&#entry577004
  12. SaltyD, Thanks for the kick start… if you are interested. Here is what I have so far… I am still working on the progress bars and having a bit of trouble with how to get a return from _LargeFileCopy $sFunction. PushFiles.ini [Groups] ActiveGroups=Group1,Group2,Group3,Group4,Group5 InactiveGroups=Group6 PingTimeout=300 [Group1] ActiveHosts=Computer1,Computer2,Computer,Computer3,Computer4 InactiveHosts= Share=C$ [Group2] ActiveHosts=Computer5,Computer6,Computer7,Computer8,Computer9 InactiveHosts= Share=C$ [Group3] ActiveHosts=Computer10,Computer11,Computer12,Computer13,Computer14 InactiveHosts= Share=C$ [Group4] ActiveHosts=Computer15,Computer16,Computer17,Computer18 InactiveHosts= Share=C$ [Group5] ActiveHosts=Computer19,Computer20,Computer21,Computer22 IncativeHosts= Share=C$ [Group6] ActiveHosts=Computer23,Computer24,Computer25 InactiveHosts= Share=C$ PushFiles.au3 #include <Array.au3> ; Only for _ArrayDisplay() #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #Include <GuiButton.au3> #include <WindowsConstants.au3> #include <GUIScrollbars_Ex.au3> #include <EditConstants.au3> #include <_LargeFileCopy.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <_FileListToArray_Recursive.au3> #Include <File.au3> #Include <Date.au3> Global $aHosts[1][5] = [[0, "", "", "", ""]] Global $FilesArray[1][3] Global $Answer,$SrcDir,$DestDir,$TotSize,$TotFiles,$TotFolders,$FileCalc $Logfile = @ScriptDir & '\' & @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & "-" & @min & "-" & @SEC & "_" & 'PushFiles.log' ;~ Create Gui $sTitle = "Push Files" $sINI = @ScriptDir & "\PushFiles.ini" $Gui = GUICreate($sTitle, 500, 550, -1, -1) Opt("GUICoordMode", 2) $GrpCord = GUISetCoord(200,10) $radio1 = GUICtrlCreateRadio("Dir Copy", -1, -1, 75, 20) GUICtrlSetTip(-1, 'Copies the current directory and all sub directories.' & @CR & 'Will create the entire directory structure on the host.') $radio2 = GUICtrlCreateRadio("File Copy", 0, -1, 75, 20) GUICtrlSetTip(-1, 'Copies ONLY the current directory and files.' & @CR & 'No sub directories will be created on the host.') GUICtrlSetState($radio2, $GUI_CHECKED) ;~ Buttons $bRePing = GUICtrlCreateButton("Re-Ping Hosts",45, 1, 100, 20, $BS_VCENTER + $BS_CENTER) GUICtrlSetTip(-1, "Re-ping hosts for changes in their status") $ModifyIni = GUICtrlCreateButton("Open Config File", -1, 1, 100, 20, $BS_VCENTER + $BS_CENTER) GUICtrlSetTip(-1, "Modify the configuration file") GUICtrlCreateLabel ('Source Folder:', -340, 1, 100) $input1 = GUICtrlCreateEdit($SrcDir, -1, 1, 320, 20, $ES_READONLY) $SelectSource = GUICtrlCreateButton("...",0, -1, 20, 20, $BS_VCENTER + $BS_CENTER) GUICtrlSetTip(-1, "Select directory containing files to push") GUICtrlCreateLabel ('Destination Folder:', -340, 15, 100) GUICtrlCreateLabel ('\\<Computer>\<Share>\', -1, 1,120) $input2 = GUICtrlCreateEdit($DestDir, 0, -1, 200, 20, $ES_READONLY) $SelectDestination = GUICtrlCreateButton("...", 0, -1, 20, 20, $BS_VCENTER + $BS_CENTER) GUICtrlSetTip(-1, "Select directory containing files to push") GUICtrlCreateLabel ('Log:', -340, 15, 100) $GuiLog = GUICtrlCreateList("",-1,1,340,175) $Lbl1 = GUICtrlCreateLabel('Size(MegaBytes): ' & $TotSize, -340, 15, 240) $CopyFiles = GUICtrlCreateButton("Copy Files",0,-1, 100, 20, $BS_VCENTER + $BS_CENTER) GUICtrlSetTip(-1, "Copy files to selected computers") GUICtrlSetState($CopyFiles, $GUI_DISABLE) $Lbl2 = GUICtrlCreateLabel(' Total Files: ' & $TotFiles, -340, 0, 200) $Lbl3 = GUICtrlCreateLabel(' Sub Folders: ' & $TotFolders, -1, 0, 300) $lbl_Status = GUICtrlCreateLabel('',-1, 0, 400) $PbFile = GUICtrlCreateProgress(-1,1,300,10,$PBS_SMOOTH) $PrFile = GUICtrlCreateLabel("0 %", 0, -1, 35, 16, $SS_RIGHT) $PbHost = GUICtrlCreateProgress(-335,1,300,10,$PBS_SMOOTH) $PrHost = GUICtrlCreateLabel("0 %", 0, -1, 35, 16, $SS_RIGHT) $PbOverall = GUICtrlCreateProgress(-335,0,300,10,$PBS_SMOOTH) $PrOverall = GUICtrlCreateLabel("0 %", 0, -1, 35, 16, $SS_RIGHT) GUISetState() ;~ Create Child gui $cGUI = GUICreate("Child GUI", 130,525,10,10, $WS_CHILD, $WS_EX_CLIENTEDGE, $Gui) GUICtrlSetResizing($cGUI, $GUI_DOCKALL) Opt("GUICoordMode", 2) $GrpCord = GUISetCoord(10,10) $bToggleAll = GUICtrlCreateButton("Toggle All", -1, 1, 100, 20) GUISetState() FileOpen($Logfile,1) FileWrite($Logfile, _Now() & " - Session started" & @CRLF) ;~ Read ini $aGroups = IniReadSection($sINI, "Groups") If @error Then MsgBox(16, "Error", "Failed to read 'Groups' section.") FileWrite($Logfile, _Now() & " - Failed to read 'Groups' section" & @CRLF) Exit EndIf $PingTimeout = IniRead($sINI,'Groups','PingTimeout',300) FileWrite($Logfile, _Now() & " - Ping Timeout set to '" & $PingTimeout & "'"& @CRLF) If ($aGroups[0][0] >= 1) And ($aGroups[1][0] = "ActiveGroups") Then $aActiveGroups = StringSplit($aGroups[1][1], ",") If ($aActiveGroups[0] = 1) And (StringStripWS($aActiveGroups[1], 8) = "") Then Dim $aActiveGroups[1] = [0] Else MsgBox(16, "Error", "Missing or invalid Groups keys.") FileWrite($Logfile, _Now() & " - Missing or invalid Groups keys" & @CRLF) Exit EndIf For $g = 1 To $aActiveGroups[0] $sGroupName = $aActiveGroups[$g] $aGroupSection = IniReadSection($sINI, $sGroupName) If @error Then MsgBox(16, "Error", "Failed to read groups section: '" & $sGroupName & "'.") FileWrite($Logfile, _Now() & " - Failed to read groups section: '" & $sGroupName & "'" & @CRLF) ContinueLoop EndIf If ($aGroupSection[0][0] >= 1) And ($aGroupSection[1][0] = "ActiveHosts") Then $aActiveHosts = StringSplit($aGroupSection[1][1], ",") If ($aActiveHosts[0] = 1) And (StringStripWS($aActiveHosts[1], 8) = "") Then Dim $aActiveHosts[1] = [0] For $h = 1 To $aActiveHosts[0] _AddActiveHost($sGroupName, $aActiveHosts[$h]) Next Else MsgBox(16, "Error", "Missing or invalid keys in group: '" & $sGroupName & "'.") FileWrite($Logfile, _Now() & " - Missing or invalid keys in group: '" & $sGroupName & "'." & @CRLF) ContinueLoop EndIf Next Dim $GrpButton[($aActiveGroups[0] + 1)] $Btn_Start = GUICtrlCreateDummy() SplashTextOn ("Available Hosts", "Checking available hosts. Please be patient...", 400, 80,-1,-1, 1,"",20) For $g = 1 To $aActiveGroups[0] $GrpButton[$g] = GUICtrlCreateButton($aActiveGroups[$g],-1, 1, 100, 20) FileWrite($Logfile, _Now() & " - Group created: '" & $aActiveGroups[$g] & "'" & @CRLF) For $n = 1 To $aHosts[0][0] if $aActiveGroups[$g] = $aHosts[$n][0] then $aHosts[$n][2] = GUICtrlCreateCheckbox($aHosts[$n][1],-1,0,100,15) if $aActiveGroups[$g] = $aHosts[$n][0] then FileWrite($Logfile, _Now() & " - Host created: '" & $aHosts[$n][1] & "'") if $aActiveGroups[$g] = $aHosts[$n][0] then $aHosts[$n][3] = IniRead($sINI, $aActiveGroups[$g], 'Share','C$') if $aActiveGroups[$g] = $aHosts[$n][0] then $aHosts[$n][4] = ping ($aHosts[$n][1],$PingTimeout) if not $aHosts[$n][4] = 1 then GUICtrlSetState ($aHosts[$n][2],$GUI_DISABLE) if $aHosts[$n][4] = 1 then GUICtrlSetState ($aHosts[$n][2],$GUI_ENABLE) if $aActiveGroups[$g] = $aHosts[$n][0] and not $aHosts[$n][4] = 1 then FileWrite($Logfile, " -DISABLED" & @CRLF) Elseif $aActiveGroups[$g] = $aHosts[$n][0] Then FileWrite($Logfile, @CRLF) EndIf Next Next $Btn_End = GUICtrlCreateDummy() _GUIScrollbars_Generate($cGUI, 0, ($n * 15) + ($g * 21)) ;number of checkboxes in the list * 15 pixels (height of the checkbox + spacing ???) SplashOff() While 1 $Msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE FileWrite($Logfile, _Now() & ' - Session ended normally' & @CRLF) FileClose($Logfile) Exit Case $radio1 $RecursiveSearch = True if not $SrcDir = "" then SplashTextOn ("Selecting Files", "Calculating selected files and folders. Please be patient...", 400, 80,-1,-1, 1,"",20) FileWrite($Logfile, _Now() & " - Set to 'Dir Copy'" & @CRLF) $DirArray = _FileListToArray_Recursive($SrcDir, "", "*", "", 2, 2, $recursiveSearch) $FilesArray = _FileListToArray_Recursive($SrcDir, "", "*", "", 1, 2, $recursiveSearch) If ControlCommand($GUI, "", $radio1, "IsChecked") Then $size = DirGetSize($SrcDir,1) If ControlCommand($GUI, "", $radio2, "IsChecked") Then $size = DirGetSize($SrcDir,1+2) If IsArray($size) Then $TotSize = Round($size[0]/ 1024 / 1024) $TotFiles = $size[1] $TotFolders = $size[2] + 1 GUICtrlSetData ($Lbl1, 'Size(MegaBytes): ' & $TotSize,'') GUICtrlSetData ($Lbl2, ' Total Files: ' & $TotFiles,'') If ControlCommand($GUI, "", $radio1, "IsChecked") Then GUICtrlSetData ($Lbl3, ' Sub Folders: ' & $TotFolders,'') If ControlCommand($GUI, "", $radio2, "IsChecked") Then GUICtrlSetData ($Lbl3, ' Sub Folders: Subfolders will not be coppied!','') EndIf EndIf SplashOff() Case $radio2 $RecursiveSearch = False if not $SrcDir = "" then SplashTextOn ("Selecting Files", "Calculating selected files and folders. Please be patient...", 400, 80,-1,-1, 1,"",20) FileWrite($Logfile, _Now() & " - Set to 'File Copy'" & @CRLF) $DirArray = _FileListToArray_Recursive($SrcDir, "", "*", "", 2, 2, $recursiveSearch) $FilesArray = _FileListToArray_Recursive($SrcDir, "", "*", "", 1, 2, $recursiveSearch) If ControlCommand($GUI, "", $radio1, "IsChecked") Then $size = DirGetSize($SrcDir,1) If ControlCommand($GUI, "", $radio2, "IsChecked") Then $size = DirGetSize($SrcDir,1+2) If IsArray($size) Then $TotSize = Round($size[0]/ 1024 / 1024) $TotFiles = $size[1] $TotFolders = $size[2] + 1 GUICtrlSetData ($Lbl1, 'Size(MegaBytes): ' & $TotSize,'') GUICtrlSetData ($Lbl2, ' Total Files: ' & $TotFiles,'') If ControlCommand($GUI, "", $radio1, "IsChecked") Then GUICtrlSetData ($Lbl3, ' Sub Folders: ' & $TotFolders,'') If ControlCommand($GUI, "", $radio2, "IsChecked") Then GUICtrlSetData ($Lbl3, ' Sub Folders: Subfolders will not be coppied!','') EndIf EndIf SplashOff() Case $SelectSource _SelectSource() If ControlCommand($GUI, "", $radio1, "IsChecked") Then $RecursiveSearch = True If ControlCommand($GUI, "", $radio2, "IsChecked") Then $RecursiveSearch = False ;~ _FileListToArray_Recursive([$sPath, [$sExcludeFolderList, $sIncludeList, $sExcludeList, $iReturnType, $iReturnFormet, $bRecursive] $DirArray = _FileListToArray_Recursive($SrcDir, "", "*", "", 2, 2, $recursiveSearch) $FilesArray = _FileListToArray_Recursive($SrcDir, "", "*", "", 1, 2, $recursiveSearch) If Not $SrcDir = "" and not $DestDir = "" then GUICtrlSetState($CopyFiles, $GUI_ENABLE) FileWrite($Logfile, _Now() & " - Source directory: '" & $SrcDir & "'" & @CRLF) If $TotFiles > 0 Then _ArrayAdd_Column($FilesArray) Else MsgBox(0,'Error','Source directory contains no files!') FileWrite($Logfile, _Now() & " - Source directory contains no files!" & @CRLF) GUICtrlSetData($input1,"") EndIf $TotalToDownload = 0 For $i = 1 To UBound($FileCalc)-1 ; Get the File size $FileSize = FileGetSize($FileCalc[$i][0]) ; Current File Size $FileCalc[$i][1] = $FileSize ; Cumulative Total $FileCalc[$i][2] = $TotalToDownload ; Add the current file size to the total $TotalToDownload += $FileSize Next Case $SelectDestination _SelectDestination() If Not $SrcDir = "" and not $DestDir = "" then GUICtrlSetState($CopyFiles, $GUI_ENABLE) FileWrite($Logfile, _Now() & " - Destination directory: '" & $DestDir & "'" & @CRLF) Case $CopyFiles FileWrite($Logfile, _Now() & " - 'Copy Files' button selected" & @CRLF) ; Disable the download button GUICtrlSetState($CopyFiles, $GUI_DISABLE) _ArrayAdd_Column($FilesArray) GUICtrlSetData($GuiLog, "") $TotalToDownload = 0 For $i = 1 To UBound($FileCalc)-1 ; Get the File size $FileSize = FileGetSize($FileCalc[$i][0]) ; Current File Size $FileCalc[$i][1] = $FileSize ; Cumulative Total $FileCalc[$i][2] = $TotalToDownload ; Add the current file size to the total $TotalToDownload += $FileSize Next if $SrcDir = "" or $DestDir = "" then MsgBox(0,'Error','You must select a source and destination!') FileWrite($Logfile, _Now() & " - You must select a source and destination!" & @CRLF) else if MsgBox(1+32+256,'Push Files','From:' & @CRLF & $SrcDir & @CRLF & 'To:' & @CRLF & '\\<Computer>\<Share>\' & $DestDir) = 1 then FileWrite($Logfile, _Now() & " - Push files From: '" & $SrcDir & "' To: '" & $DestDir & "'" & @CRLF) for $n = 1 to $aHosts[0][0] If ControlCommand($cGUI, "", $aHosts[$n][2], "IsEnabled") Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsChecked") Then ;~ _ArrayDisplay($DirArray) If IsArray($DirArray) Then For $d = 1 to $DirArray[0] ;~ MsgBox (0,'test','\\' & $aHosts[$n][1] & '\' & $aHosts[$n][3] & '\' & StringReplace($DirArray[$d],$SrcDir,$DestDir,1,2)) If ControlCommand($GUI, "", $radio1, "IsChecked") Then DirCreate ('\\' & $aHosts[$n][1] & '\' & $aHosts[$n][3] & '\' & StringReplace($DirArray[$d],$SrcDir,$DestDir,1,2)) If ControlCommand($GUI, "", $radio1, "IsChecked") Then FileWrite($Logfile, _Now() & " - Create Directory : '\\" & $aHosts[$n][1] & '\' & $aHosts[$n][3] & '\' & StringReplace($DirArray[$d],$SrcDir,$DestDir,1,2) & "'" & @CRLF) If ControlCommand($GUI, "", $radio2, "IsChecked") And Not FileExists ('\\' & $aHosts[$n][1] & '\' & $aHosts[$n][3] & '\' & $DestDir) Then DirCreate ('\\' & $aHosts[$n][1] & '\' & $aHosts[$n][3] & '\' & $DestDir) If ControlCommand($GUI, "", $radio2, "IsChecked") And Not FileExists ('\\' & $aHosts[$n][1] & '\' & $aHosts[$n][3] & '\' & $DestDir) Then FileWrite($Logfile, _Now() & '\\' & $aHosts[$n][1] & '\' & $aHosts[$n][3] & '\' & $DestDir & @CRLF) Next Else EndIf For $f = 1 to $FilesArray[0] ;~ _LargeFileCopy($sSrc, $sDest[, $fOverwrite = False[, $fFlush = False[, $fVerify = False[, $sFunction = ""[, $vUserVar = Default[, $iAlg = $CALG_MD5]]]]]]) ;~ msgbox(0,'test','\\' & $aHosts[$n][1] & '\' & $aHosts[$n][3] & '\' & StringReplace($FilesArray[$f],$SrcDir,$DestDir,1,2)) $Answer = _LargeFileCopy($FilesArray[$f], '\\' & $aHosts[$n][1] & '\' & $aHosts[$n][3] & '\' & StringReplace($FilesArray[$f],$SrcDir,$DestDir,1,2), True, False, True, "1", Default, $CALG_MD5) $DirCopyError = @error if $Answer = 1 then GUICtrlSetData($GuiLog, 'Sucess: \\' & $aHosts[$n][1] & '\' & $aHosts[$n][3] & '\' & StringReplace($FilesArray[$f],$SrcDir,$DestDir,1,2)) FileWrite($Logfile, _Now() & " - Sucess: \\" & $aHosts[$n][1] & '\' & $aHosts[$n][3] & '\' & StringReplace($FilesArray[$f],$SrcDir,$DestDir,1,2) & @CRLF) Else if $Answer = 0 then GUICtrlSetData($GuiLog, 'Failed: ' & $aHosts[$n][1] & ' ' & $FilesArray[$f] & ' ' & $DirCopyError) FileWrite($Logfile, _Now() & " - Failed: " & $aHosts[$n][1] & ' ' & $FilesArray[$f] & ' ' & $DirCopyError & @CRLF) EndIf EndIf Next Else EndIf ControlCommand($cGUI, "", $aHosts[$n][2], "Uncheck") EndIf Next ; Enable the download button GUICtrlSetState($CopyFiles, $GUI_DISABLE) EndIf EndIf Case $bRePing FileWrite($Logfile, _Now() & " - Re-Ping Hosts" & @CRLF) ;~ _ArrayDisplay($aHosts, "Debug: $aHosts") ;~ _ArrayDisplay($FileCalc) ;~ _ArrayDisplay($DirArray) ;~ _ArrayDisplay($FilesArray) _RePingHosts() Case $bToggleAll For $n = 1 To $aHosts[0][0] If $aHosts[$n][0] = True Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsEnabled") Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsChecked") Then ControlCommand($cGUI, "", $aHosts[$n][2], "Uncheck") Else ControlCommand($cGUI, "", $aHosts[$n][2], "Check") EndIf EndIf EndIf Next Case $Btn_Start To $Btn_End For $n = 1 To $aHosts[0][0] If $aHosts[$n][0] = GUICtrlRead($Msg) Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsEnabled") Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsChecked") Then ControlCommand($cGUI, "", $aHosts[$n][2], "Uncheck") Else ControlCommand($cGUI, "", $aHosts[$n][2], "Check") EndIf EndIf EndIf Next Case $ModifyIni $Answer = MsgBox(1, 'Information','You must restart the application for configuration modifications to take effect') if $Answer = 1 then Run("notepad.exe " & $sINI) Else EndIf EndSwitch WEnd Func _ArrayAdd_Column($Array) Global $FileCalc[UBound($Array)][UBound($Array, 0) + 2] For $i = 0 To UBound($Array) - 1 For $j = 0 To UBound($Array, 0) - 1 If UBound($Array, 0) = 1 Then $FileCalc[$i][0] = $Array[$i] If UBound($Array, 0) > 1 Then $FileCalc[$i][$j] = $Array[$i][$j] Next Next ;~ Return $FileCalc EndFunc Func _AddActiveHost($sGrp, $sHost) ReDim $aHosts[UBound($aHosts) + 1][UBound($aHosts, 2)] ; Resize the array $aHosts[0][0] = UBound($aHosts) - 1 ; Save count in [0][0] $aHosts[$aHosts[0][0]][0] = $sGrp ; Put group in [n][0] $aHosts[$aHosts[0][0]][1] = $sHost ; Put host in [n][1] EndFunc ;==>_AddActiveHost Func _RePingHosts() SplashTextOn ("Available Hosts", "Checking available hosts. Please be patient...", 400, 80,-1,-1, 1,"",20) For $g = 1 To $aActiveGroups[0] For $n = 1 To $aHosts[0][0] if $aActiveGroups[$g] = $aHosts[$n][0] then $aHosts[$n][4] = ping ($aHosts[$n][1],$PingTimeout) if not $aHosts[$n][4] = 1 then GUICtrlSetState ($aHosts[$n][2],$GUI_DISABLE) if $aActiveGroups[$g] = $aHosts[$n][0] then FileWrite($Logfile, _Now() & " - '" & $aHosts[$n][1] & "' -DISABLED" & @CRLF) EndIf if $aHosts[$n][4] = 1 then GUICtrlSetState ($aHosts[$n][2],$GUI_ENABLE) if $aActiveGroups[$g] = $aHosts[$n][0] then FileWrite($Logfile, _Now() & " - '" & $aHosts[$n][1] & "'" & @CRLF) EndIf Next Next SplashOff() EndFunc Func _SelectSource() $SrcDir = FileSelectFolder("Select the source directory", "",2) GUICtrlSetData($input1,$SrcDir,'') if @error == 1 Then MsgBox(0, "Error", "Unable to read the source directory.") Exit EndIf if not $SrcDir = "" then SplashTextOn ("Selecting Files", "Calculating selected files and folders. Please be patient...", 400, 80,-1,-1, 1,"",20) If ControlCommand($GUI, "", $radio1, "IsChecked") Then $size = DirGetSize($SrcDir,1) If ControlCommand($GUI, "", $radio2, "IsChecked") Then $size = DirGetSize($SrcDir,1+2) If IsArray($size) Then $TotSize = Round($size[0]/ 1024 / 1024) $TotFiles = $size[1] $TotFolders = $size[2] + 1 GUICtrlSetData ($Lbl1, 'Size(MegaBytes): ' & $TotSize,'') GUICtrlSetData ($Lbl2, ' Total Files: ' & $TotFiles,'') If ControlCommand($GUI, "", $radio1, "IsChecked") Then GUICtrlSetData ($Lbl3, ' Sub Folders: ' & $TotFolders,'') If ControlCommand($GUI, "", $radio2, "IsChecked") Then GUICtrlSetData ($Lbl3, ' Sub Folders: Subfolders will not be coppied!','') EndIf EndIf SplashOff() EndFunc Func _SelectDestination() $DestDir = StringTrimLeft(FileSelectFolder("Select the Destination directory", "",1+2),3) GUICtrlSetData($input2,$DestDir,'') If @error == 1 Then MsgBox(0, "Error", "Unable to read the source directory.") Exit EndIf EndFunc
  13. That worked for me. Does someone have a code example of how to use the $sFunction parameter in _LargeFileCopy. I am trying to learn how to incorporate a (multiple… current file and total files) progress bars into my app.
  14. I am getting the log written with everything except the @error value at the end when a failure occurs. Currently the GUI log is a GUICtrlCreateList on the GUI itself.
×
×
  • Create New...