Sign in to follow this  
Followers 0
mrajl

Script debugging logfile

2 posts in this topic

Hello All,

My colleges and I we have been working with AutoIT to help deploy applications with MS SMS 2003.

AutoIt has been working great except for a few minor issues here and there.

We have tried to make a logging feature from pieces from the forums and what we could come up within the script to help solve these minor issues.

We used the File Open/File Close and FileWriteLine command.

The Logfile wont write till you close the file so what I get is a zero bytes file when it runs due to the install not finishing the script.

Does anyone know how to get this to flush the data before I close the file or maybe suggest a better way to do this task.

This is my first post on the site. So if I miss any forum protocol I am sorry.

Thank you for your help

AJ

Here is the install script. It has been cut down for the example.

It installs a Civil Engineering Package called Staad Pro.

; Safety testing

$SF_1 = "StaadInstall"

If WinExists ( $SF_1 ) Then Exit

AutoItWinSetTitle ( $SF_1 )

;SplashImageOn("Installing software...", "image1.jpg", 2000, 2000)

; Create log file

DirCreate("C:\Windows\Temp\Staad_install")

$file = FileOpen("C:\Windows\Temp\Staad_install\Staad_install.log", 1)

; Check if file opened for writing OK

If $file = -1 Then

; Attempt to re-create directory and file

DirCreate("C:\Windows\Temp\Staad_install")

$file = FileOpen("C:\Windows\Temp\Staad_install\Staad_install.log", 1)

If $file = -1 Then

Do

$error = MsgBox(0, "Error", "This program encountered an unexpected error. Please see the install log located in C:\Windows\Temp\Staad_install for details.")

Until $error = 1

Exit

EndIf

EndIf

FileWriteLine($file, "")

FileWriteLine($file, "")

FileWriteLine($file, "----------------------------------------------------------------------------")

FileWriteLine($file, "Start: " & @MDAY & "/" & @MON & "/" & @YEAR & ", " & @HOUR & ":" & @MIN & ":" & @SEC)

FileWriteLine($file, "")

FileWriteLine($file, "Entering Staad_install...")

FileWriteLine($file, "")

; Run the setup program

FileWrite($file, "Run the setup program...")

; ------------------------------------------------------------------------------------------------------

; Uninstall the program if it's already installed on the machine

If FileExists("C:\SPro2005") Then

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{92337117-8C7D-44FA-B29D-7BF7F7BE51C2}", "DisplayName")

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{92337117-8C7D-44FA-B29D-7BF7F7BE51C2}", "Version")

; Copy License files

;DirCopy("serverfiles", "c:\windows\temp", 1)

; Run the setup program

Run("Install\setup.exe")

; Click YES

WinWait("Question")

WinActivate("Question")

ControlClick("Question", "build of STAAD.Pro 2005 is found", 6)

; If the program isn't already installed then just run the setup file

Else

; Copy License files

DirCopy("serverfiles", "c:\windows\temp", 1)

; Run the setup program

Run("Install\setup.exe")

EndIf

; ------------------------------------------------------------------------------------------------------

FileWriteLine($file, "OK")

; ------------------------------------------------------------------------------------------------------

; Welcome

FileWrite($file, "Run through the different windows...")

WinWait("STAAD.Pro 2005 - InstallShield Wizard", "The InstallShield® Wizard will")

; Installation complete

WinWait("STAAD.Pro 2005 - InstallShield Wizard", "Setup has finished installing")

WinActivate("STAAD.Pro 2005 - InstallShield Wizard", "Setup has finished installing")

ControlClick("STAAD.Pro 2005 - InstallShield Wizard", "Setup has finished installing", 1)

; ------------------------------------------------------------------------------------------------------

FileWriteLine($file, "OK")

; Give access rights

FileWrite($file, "Give access rights to the appropriate people...")

RunWait(@ComSpec & " /c " & "cacls C:\SPro2005\STAAD\Sections\*.* /e /c /g EVERYONE:f""", "", @SW_HIDE)

FileWriteLine($file, "OK")

FileWriteLine($file, "Staad_install completed successfully.")

FileWriteLine($file, "")

FileWriteLine($file, "End Time: " & @MDAY & "/" & @MON & "/" & @YEAR & ", " & @HOUR & ":" & @MIN & ":" & @SEC)

FileWriteLine($file, "----------------------------------------------------------------------------")

FileWriteLine($file, "")

FileWriteLIne($file, "")

; Close the log file

FileClose($file)

Exit

;SplashOff()

; Installation Complete

;SplashImageOn("Installation complete", "image2.jpg", 2000, 2000)

;Sleep(3000)

;SplashOff()

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

use [ autoit] and [ /autoit] to place code here.... no spaces

replace all of the Filewriteline()'s with _Filewritelog()

that should do it... it also has a time stamp built in

_FileWriteLog

--------------------------------------------------------------------------------

Writes current date,time and the specified text to a log file.

#include <File.au3>

_FileWriteLog( $sLogPath, $sLogMsg )

8)

Edited by Valuater

NEWHeader1.png

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  
Followers 0