Okay, this is some ugly code, but please review it as it hopefully might be a little more what you're looking for.
Part of the issue though I think is that the installer may be rebooting your system before the log can write if the installer process reboots. You need to write to the log just before you run the installer.
Code:
Break On
Dim $ServerChk
;If WIN9X then exit
If @INWIN <> 1
Exit 10
EndIf
;Check for Server and exit if Server found
$ServerChk = ReadValue('HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions','ProductType')
If $ServerChk<>'WinNT' ;System is not a Workstation
Exit 10
EndIf
;Check to see if Hummingbird DM has already run on this machine
If Exist('\\filer-lan\data\printer\hummingbird\dm_install\'+@WKSTA+'_DLL.txt')
;If file found exit script
Exit 13
EndIf
;Check to see if Hummingbird DM has already run on this machine
If Exist('\\filer-lan\data\printer\hummingbird\dm_install\'+@WKSTA+'_DM.txt')
Exit 10
EndIf
;If the folder C:\Program Files\Hummingbird\DM Extensions does not exist create it
If GetFileAttr($directory) & 16
;Do nothing
Else
;Create it
MD ('%SystemDrive%\Program Files\Hummingbird')
MD ('%SystemDrive%\Program Files\Hummingbird\DM Extensions')
EndIf
Global $Directory, $OK_DLL_logfile, $ERR_DLL_logfile, $DateTime, $SleepTime
$Directory ="%SystemDrive%\Program Files\Hummingbird\DM Extensions"
$OK_DLL_logfile = 'R:\printer\hummingbird\dm_install\'+@WKSTA+'_DLL.txt'
$ERR_DLL_logfile = 'R:\printer\hummingbird\dm_install\ERR_'+@WKSTA+'_DLL.txt'
$DateTime = @DATE+'_'+@TIME
$dmcode = ""
$SleepTime = 40
Function DM_COPY()
Copy '\\filer-lan\data\printer\hummingbird\DMLookup.dll' $Directory+'\DMLookup.dll'
Copy '\\filer-lan\data\printer\hummingbird\DMLookup.reg' $Directory+'\DMLookup.reg'
Copy '\\filer-lan\data\printer\hummingbird\DMLookup.bat' $Directory+'\DMLookup.bat'
$dmcode = @ERROR
If $dmcode <> 0
;Write to log file if the dll was not copied in the time allowed
$WL=WriteProfileString($ERR_DLL_logfile,$DateTime,@USERID,'dmlookup.bat Return Code = '+$dmcode)
Else
$WL=WriteProfileString($OK_DLL_logfile,$DateTime,@USERID,'APA_PROD.bat Return Code = 0')
EndIf
EndFunction
$OK_logfile = 'R:\printer\hummingbird\dm_install\'+@WKSTA+'_DM.txt'
$ERR_logfile = 'R:\printer\hummingbird\dm_install\ERR_'+@WKSTA+'_DM.txt'
$DateTime = @DATE+'_'+ @TIME
$dmcode = ""
$SleepTime = 40
;Run the DM Install
'Running Hummingbird DM Install (APA MIS Dept)....' ?
SHELL '\\filer-lan\data\printer\hummingbird\APA_PROD.bat'
$dmcode = @ERROR
;Well if the system is going to reboot here then you're not going to write
;to a log file in time maybe
If $dmcode <> 0
$WL=WriteProfileString($ERR_DLL_logfile,$DateTime,@USERID,'dmlookup.bat Return Code = '+$dmcode)
Else
$WL=WriteProfileString($OK_logfile,$DateTime,@USERID,'APA_PROD.bat Return Code = 0')
EndIf