#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 $usbFixedDrive = "E:" Global $usbRemovDrive = "G:" Global $mappedNWShareDrive = "\\FILSERVER\Users\User\SharedFolder" ; Global $mappedNWShareDrive = "M:" Global $maxNum = 5 Global $WinHandOrig[10][10] Global $i = 0 Global $j = 0 Global $k = 0 Global $m = 0 ; ; 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 ; Sleep(3500) ; ; 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] = "USBExt" $FileTitle[5] = "mappedNWShare" Sleep(3500) ; ; 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(4000) 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." & @CRLF) For $m = 5 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]) $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(3500) 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) ; 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(3500) Local $iPid = Run("explorer.exe " & $FilePath) Sleep(3500) 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) Else Sleep(3500) Local $WinHand = WinGetHandle($FilePath, "") Sleep(3500) 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(3500) $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(3500) EndIf Sleep(3500) $tCur = _Date_Time_GetSystemTime() FileWrite($hFileOpen, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & _ "CreateFilePath end " & @CRLF) EndFunc ;==>CreateFilePath