Page 1 of 1 1
Topic Options
#160192 - 2006-04-03 01:33 AM W2K Clients are Rebooted B4 Log file is created
rtoles Offline
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
#160193 - 2006-04-03 04:24 AM Re: W2K Clients are Rebooted B4 Log file is created
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
I will attempt to review the code for you and offer advice, but in the future please use the INSTANT UBB CODE tags to control how your script looks.


What version of KiXtart are you using?
 

Top
#160194 - 2006-04-03 05:08 AM Re: W2K Clients are Rebooted B4 Log file is created
NTDOC Administrator Offline
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
#160195 - 2006-04-03 03:08 PM Re: W2K Clients are Rebooted B4 Log file is created
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
Hi and welcome!

Just curious, wouldn't checking a regvalue of the existence of a file on the computer be better then writing a logfile with the status only?
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#160196 - 2006-04-03 03:11 PM Re: W2K Clients are Rebooted B4 Log file is created
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
Quote:

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.






Wouldn't writing success when triggering install be a bit wrong?
Or, perhaps writing that the installation was triggered, then at second run write successfull if file exists in share and a specific file exists (or version) after reboot?
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#160197 - 2006-04-03 07:09 PM Re: W2K Clients are Rebooted B4 Log file is created
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Yes it probably would be wrong unless you knew for a fact that say 99%+ of all systems that initiated the installed completed successfully.

I don't know what he's really doing here, just saying that his current method is not going to work. I agree that doing some better checks on the local system would probably be the best approach.

Top
#160198 - 2006-04-03 07:34 PM Re: W2K Clients are Rebooted B4 Log file is created
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I despise the use of cookie files. Look to the registry for proof of success.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#160199 - 2006-04-05 02:04 PM Re: W2K Clients are Rebooted B4 Log file is created
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
I dislike cookie-files, but love cookies.
The method of checking should depend on the installation-type, right?
But I agree that checking the registry is a good role to apply as a first-choice.
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 323 anonymous users online.
Newest Members
Audio, Hoschi, Comet, rrosell, PatrickPinto
17880 Registered Users

Generated in 0.056 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org