Jump to content
Sign in to follow this  
DigDeep

Unable to write log path

Recommended Posts

DigDeep

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

Share this post


Link to post
Share on other sites
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
DigDeep

#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

Share this post


Link to post
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
Sign in to follow this  

×