#160192 - 2006-04-03 01:33 AM
W2K Clients are Rebooted B4 Log file is created
|
rtoles
Lurker
Registered: 2005-01-18
Posts: 2
|
We have a very important implementation some new software this week. I created a script to install the software and it creates a log file in a network directory. The script checks this log file in order to prevent the software from installing again if the initial installation was successful. The installation requires a reboot and the user is prompted to do so. It works on all XP machines. But on the 2K machines I think PC is rebooted before the log file is created.
Here it goes. Any help will be appreciated. I'm fairly new to kixtart.
;If WIN9X then exit
IF @INWIN <> 1
goto END
EndIf
;Test for Server (DO not run on servers) ;Determine that client is a workstation and not a server using the 2003 gettype ;Checks errorlevel. ON 2K 1 = Windows NT Workstation, 2 = Windows 2000 Professional. ;On 2K3 or XP 1 = Home Edition, 2 = Professional. 3 and up = Server types, So will run on 1 or 2 only.
SHELL @LDRIVE + "\gettype.exe /type" $os_type = @ERROR ;MESSAGEBOX ("$os_type","OS-TYPE",64) ;Test window to see value IF $os_type=1 OR $os_type=2
goto MAKDIR EndIf
goto END :MAKDIR $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
;Check to see if Hummingbird DM has already run on this machine if exist("\\filer-lan\data\printer\hummingbird\dm_install\@WKSTA_DLL.txt") goto END EndIF ;If the folder C:\Program Files\Hummingbird\DM Extensions does not exist if not exist ($directory) ;Create it MD ("%SystemDrive%\Program Files\Hummingbird") MD ("%SystemDrive%\Program Files\Hummingbird\DM Extensions") goto DM_COPY EndIF
M_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 goto DM_DLL_ERR EndIf
LL_OK ;Write to logfile if the intallation was OK and END WRITEPROFILESTRING("$OK_DLL_logfile","$DateTime","@USERID","APA_PROD.bat Return Code = 0") goto RUNBAT :RUNBAT $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
;Check to see if Hummingbird DM has already run on this machine if exist("\\filer-lan\data\printer\hummingbird\dm_install\@WKSTA_DM.txt") goto END EndIF
;Run the DM Install ? "Running Hummingbird DM Install (APA MIS Dept)...." SHELL "\\filer-lan\data\printer\hummingbird\APA_PROD.bat" $dmcode = @ERROR If $dmcode <> 0 goto DM_ERR EndIf
M_OK ;Write to logfile if the intallation was OK and END
WRITEPROFILESTRING("$OK_logfile","$DateTime","@USERID","APA_PROD.bat Return Code = 0") goto END
M_ERR ;Write to log file if the services were not installed in the time allowed WRITEPROFILESTRING("$ERR_logfile","$DateTime","@USERID","APA_PROD.bat Return Code = $dmcode")
M_DLL_ERR ;Write to log file if the dll was not copied in the time allowed WRITEPROFILESTRING("$ERR_DLL_logfile","$DateTime","@USERID","dmlookup.bat Return Code = $dmcode")
:END
|
Top
|
|
|
|
#160194 - 2006-04-03 05:08 AM
Re: W2K Clients are Rebooted B4 Log file is created
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11625
Loc: CA
|
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
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 323 anonymous users online.
|
|
|