#RequireAdmin ; Runs script as admin user #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include ; #Include <_DBUG.au3>  ;  Used for debugging script #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Run_AU3Check=N ;#Autoit3Wrapper_Testing=Y Opt("MouseCoordMode", 2) ; define standard drives and network share folders Global $CDrive = "C:" Global $usbFixedDrive = "E:" Global $usbRemovDrive = "G:" Global $mappedNWShareDrive = "\\FILSERVER\Users\User\SharedFolder" ; Global $mappedNWShareDrive = "M:" Global $mappedShareptDrive = "\\g-cad1\Storage\ShellbagsTest" Global $zipped = "C:\Users\User\zipped" Global $USB_MTP = "H:" Global $maxNum = 3 Global $WinHandOrig[10][10] Global $i = 0 Global $j = 0 Global $k = 0 Global $m = 0 ; get desktop width and height to orient explorer windows Global $iWidth = @DesktopWidth / 2 Global $iHeight = @DesktopHeight - 50 Sleep(2000) ; ; Create a constant variable with the filepath ; Global $FilePath[10] $FilePath[0] = @DesktopDir $FilePath[1] = @MyDocumentsDir $FilePath[2] = "C:\Users\User\AppData\Local\Temp" $FilePath[3] = $usbFixedDrive $FilePath[4] = $usbRemovDrive $FilePath[5] = $mappedNWShareDrive $FilePath[6] = $CDrive $FilePath[7] = $mappedShareptDrive $FilePath[8] = $USB_MTP $FilePath[9] = $zipped ; Sleep(2000) ; ; Create a constant variable with the window title ; Global $FileTitle[10] $FileTitle[0] = "Desktop" $FileTitle[1] = "Documents" $FileTitle[2] = "Temp" $FileTitle[3] = "USBFixed" $FileTitle[4] = "Monster" $FileTitle[5] = "mappedNWShare" $FileTitle[6] = "CDrive" $FileTitle[7] = $mappedShareptDrive $FileTitle[8] = $USB_MTP $FileTitle[9] = "zipped" Sleep(2000) ; ; Define file names for different directories ; Global $rundate = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC Global $FileName[10] For $h = 0 To $maxNum Step 1     $FileName[$h] = $FilePath[$h] & "\" & $rundate & ".txt" Next Sleep(2000) Main() Func Main()     ; Open file to write to     ; Create a constant variable in Local scope of the filepath that will be read/written to.     Local Const $sFilePath = $FilePath[0] & "\" & $rundate & ".me"     ; Create a temporary file to write data to.     If Not FileWrite($sFilePath, "Main Function start of the FileWrite Main Function, line 1. " & @CRLF) Then         MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file." & @CRLF)         Return False     EndIf     ; Open the file for writing (append to the end of a file) and store the handle to a variable.     Global $hFileOpen = FileOpen($sFilePath, $FO_APPEND)     If $hFileOpen = -1 Then         MsgBox(0, "Error -1 =hFileOpen", "Main - An error occurred whilst writing the temporary file." & @CRLF)         Return False     EndIf     ; End of Open file to write log data     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "Main Start.  Win7UltNx64.au3" & @CRLF)     For $m = 0 To $maxNum Step 1         For $j = 0 To $maxNum Step 1             If $m = $j Then                 ; do nothing -              Else                 ; CreateFilePath                 $WinHandOrig[$m][$j] = CreateFilePath($FilePath[$m], $FileTitle[$m])                 $tCur = _Date_Time_GetSystemTime()                 FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & "Main CreateFilePath Done. $WinHandOrig[" & $m & "][" & $j & "] " & $WinHandOrig[$m][$j] & " $FilePath[" & $m & "]: " & _                         $FilePath[$m] & @CRLF)                 Sleep(2000)                 CreateRundateFolder($rundate, $WinHandOrig[$m][$j], $FileTitle[$m], $FileTitle[$j], "DAD_")                 $tCur = _Date_Time_GetSystemTime()                 FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & "Main CreateRundateFolder  DAD_ $FileTitle[" & $m & "]: " & $FileTitle[$m] & _                         " $FileTitle[" & $j & "] " & $FileTitle[$j] & @CRLF)                 $tCur = _Date_Time_GetSystemTime()                 FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & "Main CreateRundateFolder   $WinHandOrig[" & $m & "][" & $j & "] " & _                         $WinHandOrig[$m][$j] & @CRLF)                 Sleep(2000)                 CreateRundateFolder($rundate, $WinHandOrig[$m][$j], $FileTitle[$m], $FileTitle[$j], "CA_")                 Sleep(2000)                 $tCur = _Date_Time_GetSystemTime()                 FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & "Main CreateRundateFolder  CA_  $FileTitle[" & $m & "]: " & $FileTitle[$m] & _                         " $FileTitle[" & $j & "] " & $FileTitle[$j] & @CRLF)                 $tCur = _Date_Time_GetSystemTime()                 FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & "Main CreateRundateFolder   $WinHandOrig[" & $m & "][" & $j & "] " & _                         $WinHandOrig[$m][$j] & @CRLF)                 Sleep(2000)             EndIf         Next ; j     Next ; m    $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "Main End" & @CRLF)     ; Close the handle returned by FileOpen.     FileClose($hFileOpen)     MsgBox(0, "Success!", "Win10Nx64SB Ended Successfully." & @CRLF) EndFunc   ;==>Main Func CreateFilePath($FilePath, $FileTitle)     ; opens explorer window and returns the windows handle for the file path specified     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateFilePath Start. $filePath: " & $FilePath & @CRLF)     Sleep(2000)     Local $iPid = Run("explorer.exe " & $FilePath)     Sleep(2000)     If $iPid = 0 Then ; Run failed         MsgBox(0, "Error -2", "CreateFilePath run explorer failed." & @CRLF)         $tCur = _Date_Time_GetSystemTime()         FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _                 "Error -2  CreateFilePath run explorer failed." & @CRLF)         Exit (-2)      EndIf         Local $WinHand = WinGetHandle("[CLASS:CabinetWClass]", "")         Sleep(2000)         If @error = 0 Then ; WinGetHandle worked             $tCur = _Date_Time_GetSystemTime()             FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _                     "CreateFilePath $WinHand: " & $WinHand & " $filePath: " & $FilePath & _                     " @error: " & @error & @CRLF)             Sleep(2000)             $tCur = _Date_Time_GetSystemTime()             FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _                     "CreateFilePath   End" & @CRLF)             Return $WinHand         Else             MsgBox(0, "Error -3", "CreateFilePath WinGetHandle failed." & @CRLF)             $tCur = _Date_Time_GetSystemTime()             FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _                     "Error -3 CreateFilePath WinGetHandle failed." & @CRLF)             Exit (-3)         EndIf         Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateFilePath end " & @CRLF) EndFunc   ;==>CreateFilePath Func CreateRundateFolder($rundate, $fromWinHand, $fromFileTitle, $toFileTitle, $filePrefix)     ; create a new folder (temporary one) with rundate & $fileTitle as the name     ; For $j = 0 To $maxNum Step 1     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder Start. $rundate " & $rundate & " $fromWinHand: " & $fromWinHand & @CRLF)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder $fromFileTitle " & $fromFileTitle & " $toFileTitle: " & $toFileTitle & @CRLF)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder $filePrefix " & $filePrefix & @CRLF)     Sleep(2000)     Local $rundatelocalfold = $filePrefix & $fromFileTitle & $rundate & $toFileTitle     Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder $rundatelocalfold: " & $rundatelocalfold & _             " $filePrefix: " & $filePrefix & @CRLF)     Sleep(2800)     $retval4 = ControlSend($fromWinHand, "", "ToolbarWindow324", "!F") ; alt F - file menu     Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder Alt F " & $retval4 & @CRLF)     Sleep(2000)     #cs     $retval4 = ControlSend($retVal1, "", "[CLASS:NetUIHWND]", "{DOWN 1}") ; $downNum hard coded     Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder {1} " & $retval4 & @CRLF)     Sleep(2000)     #ce     $retval4 = ControlSend($fromWinHand, "", "ToolbarWindow324", "W") ; New  - Folder is first on the list     Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder W " & $retval4 & @CRLF)     Sleep(2000)     $retval4 = ControlSend($fromWinHand, "", "ToolbarWindow324", "F")     ;Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder F " & $retval4 & @CRLF)     Sleep(2000)     $retval4 = ControlSend($fromWinHand, "", "ToolbarWindow324", "{ENTER}")     ;Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder {ENTER} " & $retval4 & @CRLF)     Sleep(2000)     $retval4 = ControlSend($fromWinHand, "", "", $rundatelocalfold)     ;Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder enter $rundatelocalfold: " & $rundatelocalfold & " " & $retval4 & @CRLF)     Sleep(2000)     $retval4 = ControlSend($fromWinHand, "", "", "{ENTER}")     ;Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder {ENTER} " & $retval4 & @CRLF)     Sleep(2000)     Local $winhandlocalfold = $filePrefix & $fromFileTitle & $fromWinHand & $toFileTitle     Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder $winhandlocalfold: " & $winhandlocalfold & _             " $filePrefix: " & $filePrefix & @CRLF)     Sleep(2000)     $retval4 = ControlSend($fromWinHand, "", "ToolbarWindow324", "!F") ; alt F - file     Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder Alt F " & $retval4 & @CRLF)     Sleep(2000)     $retval4 = ControlSend($fromWinHand, "", "ToolbarWindow324", "W") ; New - Folder is the first one listed     Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder W " & $retval4 & @CRLF)     Sleep(2000)     $retval4 = ControlSend($fromWinHand, "", "ToolbarWindow324", "F") ; folder     ;Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder F " & $retval4 & @CRLF)     Sleep(2000)     $retval4 = ControlSend($fromWinHand, "", "ToolbarWindow324", "{ENTER}") ; to select new folder     Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder {ENTER} " & $retval4 & @CRLF)     Sleep(2000)     $retval4 = ControlSend($fromWinHand, "", "", $winhandlocalfold)     Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder $winhandlocalfold: " & $winhandlocalfold & " " & $retval4 & @CRLF)     Sleep(2000)     $retval4 = ControlSend($fromWinHand, "", "", "{ENTER}")     Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder {ENTER} " & $retval4 & @CRLF)     Sleep(2000)     $tCur = _Date_Time_GetSystemTime()     FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _             "CreateRundateFolder end " & @CRLF) EndFunc   ;==>CreateRundateFolder