MystrE Posted October 4, 2013 Share Posted October 4, 2013 I am very new to autoit, been using it for a week and i've hit a roadbump. I'm able to install programs with the code below and now my question is how do i create a log file that says "Installation succesfull" and "Installation not succesfull". I don't want it to pop-up in a messagebox just want to be able to export it to a .txt file where it has the "Year-month-day-hour-minute | Installed succesfull / Not succesfull" Global $iniFileProg = @ScriptDir & "\Prog.ini" Global $iniFileNetwork = @ScriptDir & "\Network.ini" Local $username = IniRead($iniFileNetwork, "Netwerk", "Username", "NotFound") Local $domain = IniRead($iniFileNetwork, "Netwerk", "Domain", "Not Found") Local $password = IniRead($iniFileNetwork, "Netwerk", "Password", "Not Found") Local $path = IniRead($iniFileNetwork, "Netwerk", "Netpath", "Not Found") Local $scriptDir = IniRead($iniFileProg, "Programma", "ScriptDir", "Not Found") Local $filename = IniRead($iniFileProg, "Programma", "Filename", "Not Found") Local $switch = IniRead($iniFileProg, "Programma", "Switch", "Not Found") RunAsWait($username, $domain, $password, 2, '"' & $path & $scriptDir & "\" & $fileName & '"' & " " & $switch) Exit Link to comment Share on other sites More sharing options...
Developers Jos Posted October 4, 2013 Developers Share Posted October 4, 2013 Guess you haven't opened the Helpfile and searched on LogFile...right? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
MystrE Posted October 4, 2013 Author Share Posted October 4, 2013 I have and i found the _FileWriteLog Function, but i just can't figure it out. It doesn't matter how i configure it it always gives out an log file with "Succesfull" even if the program hasn't started to run. Link to comment Share on other sites More sharing options...
Developers Jos Posted October 4, 2013 Developers Share Posted October 4, 2013 That means you have posted the wrong snippet of code you are having issues with. So, post what you have that is not working. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
MystrE Posted October 8, 2013 Author Share Posted October 8, 2013 (edited) Hey Jos, Sorry for the late reply. I've found a workaround for the problem ( looking in the forums and searching for a couple of days ) #include <file.au3> Global $iniFileProg = @ScriptDir & "\Prog.ini" Global $iniFileNetwork = @ScriptDir & "\Network.ini" Local $username = IniRead($iniFileNetwork, "Netwerk", "Username", "NotFound") Local $domain = IniRead($iniFileNetwork, "Netwerk", "Domain", "Not Found") Local $password = IniRead($iniFileNetwork, "Netwerk", "Password", "Not Found") Local $path = IniRead($iniFileNetwork, "Netwerk", "Netpath", "Not Found") Local $scriptDir = IniRead($iniFileProg, "Programma", "ScriptDir", "Not Found") Local $filename = IniRead($iniFileProg, "Programma", "Filename", "Not Found") Local $switch = IniRead($iniFileProg, "Programma", "Switch", "Not Found") $LogFile = @ScriptDir & "\" & @ScriptName & "_" & @YEAR & "_" & @MON & "_" & @MDAY & "-" & @HOUR & @MIN & ".log" If Not _FileWriteLog($LogFile, "Initialized script from: " & @ScriptFullPath) Then MsgBox(16, "Error!", "Could not initialize log file! Exiting...") Exit EndIf RunAsWait($username, $domain, $password, 2, '"' & $path & $scriptDir & "\" & $fileName & '"' & " " & $switch) If FileExists("C:\Program Files (x86)\7-Zip\") Then _FileWriteLog($LogFile, "Programma is al ge-installeerd " & @ScriptName) Else If RunAsWait($username, $domain, $password, 2, '"' & $path & $scriptDir & "\" & $fileName & '"' & " " & $switch) Then _FileWriteLog($LogFile, "Programma succesvol ge-installeerd: " & @ScriptName) Else _FileWriteLog($LogFile, "Programma niet succesvol ge-installeerd: " & @ScriptName) EndIf EndIf Exit THe only problem here is now that it looks for the folder of the installation if it exists, but if the installation stops halfway and still makes the folder the log isn't right. I'd like to log the progress in a .txt file of an installed file. So like the on that is written now : 2013-10-08 09:14:33 : Initialized script from: C:\7Zip.au3 2013-10-08 09:14:33 : Programma niet succesvol ge-installeerd: 7Zip.au3 But with another entry like "Initializing script" / "Program installed Started" / "Program installed succesfully or Program installation Failed" Sorry for the confusion Jos, like i said i'm very new to autoit and to programming so i'm still puzzling around and searching the help and forums for tips EDIT- Something like '?do=embed' frameborder='0' data-embedContent>> Post #6 by PsaltyDS. He explains here how it's done for the function dircreate, i would like to do the same with runwait. Please if it's possible could you help, or at least direct me to the page where i can find the info on how to do this. That would be great Edited October 8, 2013 by MystrE Link to comment Share on other sites More sharing options...
Developers Jos Posted October 8, 2013 Developers Share Posted October 8, 2013 I am not sure why you do the If with a second Run() statement when the first one failed. Could you explain your intent there? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now