Jump to content

Unable to write log path


DigDeep
 Share

Recommended Posts

Hi,

Can someone help me fix the below code. Basically, this will search the whole drive for a specific filename "xyz" and will display it. Once done, it will create a log path and copy the files along with the location path.

Everything works fine here. The files found are saved in the Output.txt file. Except that when the log is generated, it doesn't show the files found. I want the files saved in the Output.txt to be displayed in the Logpath entry.

 

#Include <Array.au3>
#Include <File.au3>
#include <Constants.au3>
#include <IE.au3>
#include <ClipBoard.au3>

Global $sHDD, $sfilename, $aOutput

$Login_Flag = 0
$Virus_Flag = 0


FUNC LoginDetails()
   IF $Login_Flag = 0 Then
; Creating Logs
      Global $InstallFolder = "C:ProgramDataabcd"
;Set path for the install Log
      Global $InstallEvent_File_Path = $InstallFolder & "" & "test.log"
; create a log file in the Results/install folder
      _FileCreate($InstallEvent_File_Path)
      If FileExists($InstallEvent_File_Path) Then ; Check we have created the install log file before writing to it
      $Login_Flag = 1
       EndIf
    EndIf
EndFunc
 

;~ Scan the drive for any file name xyz.

Global $sHDD, $sfilename, $aOutput
$sHDD = "C:"
$sfilename = "xyz*.*"
RunWait(@ComSpec & " /c " & "dir " & $sHDD & $sfilename & " /B /S > output.txt", "C:ProgramDataabcd", @SW_HIDE,  $STDOUT_CHILD+$STDERR_CHILD)
_FileReadToArray("C:ProgramDataabcd" & "output.txt", $aOutput)
If FileExists("C:ProgramDataabcd" & "output.txt") Then
_ArrayDisplay($aOutput)
         LoginDetails()
         VirusUpdate()

         _FileWriteLog($InstallEvent_File_Path, "I WOULD NEED THE FILES FOUND TO BE ENTERRED HERE...")
EndIf

Link to comment
Share on other sites

Could you please enclose your script in AutoIt code tags? That's the blue "A" icon in the editor. Greatly enhances readability :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

#RequireAdmin
#NoTrayIcon

#Include <Array.au3>
#Include <File.au3>
#include <Constants.au3>
#include <IE.au3>
#include <ClipBoard.au3>



Global $sHDD, $sfilename, $aOutput

$Login_Flag = 0
$Virus_Flag = 0


FUNC LoginDetails()
   IF $Login_Flag = 0 Then
; Creating Logs
      Global $InstallFolder = "C:\ProgramData\abcd\"
;Set path for the install Log
      Global $InstallEvent_File_Path = $InstallFolder & "\" & "test.log"
; create a log file in the Results/install folder
      _FileCreate($InstallEvent_File_Path)
      If FileExists($InstallEvent_File_Path) Then ; Check we have created the install log file before writing to it
      $Login_Flag = 1
       EndIf
    EndIf
EndFunc


;~ Scan the drive for any file name xyz.

Global $sHDD, $sfilename, $aOutput
$sHDD = "C:\"
$sfilename = "xyz*.*"
RunWait(@ComSpec & " /c " & "dir " & $sHDD & $sfilename & " /B /S > output.txt", "C:\ProgramData\abcd\", @SW_HIDE,  $STDOUT_CHILD+$STDERR_CHILD)
_FileReadToArray("C:\ProgramData\abcd\" & "\output.txt", $aOutput)
If FileExists("C:\ProgramData\abcd\" & "\output.txt") Then
_ArrayDisplay($aOutput)
         LoginDetails()
         VirusUpdate()

         _FileWriteLog($InstallEvent_File_Path, "I WOULD NEED THE FILES FOUND TO BE ENTERRED HERE...")
EndIf

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...