Jump to content

'DirCreate' combined with 'FileOpen' results in empty directory


fmlk
 Share

Recommended Posts

Hello,

In a main script I have added logging and that is working. Now I created another small script where I need also logging. So I used the same code:

What is wrong? Why is the logfile not created?


$default_delay = 2000
$logFilePath = ("C:\AutoIT_TestLogs")
DirCreate($logFilePath)

$Logfile = FileOpen($logFilePath & "\GMS_install" & @MON & "/" & @MDAY & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & ".log",1)

FileWriteLine($logFile,@CR & @MON & "/" & @MDAY & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & "_Install_licenses")
Consolewrite("Install_licenses" & @CR)
Run("C:\Users\factory\Desktop\LicenseInstaller\LicenseInstaller.exe","C:\Users\factory\Desktop\LicenseInstaller")
Sleep(1000)
WinWait("Gatan License Installer")
WinActivate("Gatan License Installer")
WinWaitActive("Gatan License Installer")
ControlClick("[ACTIVE]","","[NAME:CMD_Install]")
Sleep($default_delay)

 If WinExists("LicenseInstaller") Then
     WinActivate("LicenseInstaller")
      WinWaitActive("LicenseInstaller")
      ControlClick("[ACTIVE]","","[CLASS:Button; INSTANCE:1]")
        sleep($default_delay)
   EndIf

FileWriteLine($logFile,@CR & @MON & "/" & @MDAY & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & "_Licenses_Installed")
Consolewrite("Licenses are installed" & @CR)

 

Link to comment
Share on other sites

@fmlk,

1 hour ago, fmlk said:

$Logfile = FileOpen($logFilePath & "\GMS_install" & @MON & "/" & @MDAY & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & ".log",1)

your log file name contains slashes ("/") and colons (":") which are not valid characters for a file name.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

@fmlk

Please encode your code in autoit code ('< >' button) so it's easier to read.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

  • 3 weeks later...

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

×
×
  • Create New...