WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Configure a workstation to run HealthStar

Keywords: 	 Configure a workstation to run HealthStar   HStarWSConfig.WBT

; +-------------------------------------------------------------------+
; |                                                                   |
; |     * * *   P R O G R A M   F I L E  HStarWSConfig.WBT   * * *    |
; |                                                                   |
; | Purpose: Configure a workstation to run HealthStar.               |
; |          1) Copy the DATAPIPE.INI file from the server to the     |
; |             %SystemRoot% directory and set permissions on it.     |
; |          2) Create and populate a "HealthStar in Windows" folder  |
; |                                                                   |
; |          3) Find the CALMSDS.DOT file in the \HOME subdirectory   |
; |             of the HealthStar installation and install it into    |
; |             either the Directory for Workgroup Templates or the   |
; |             Directory for User Templates (whichever it finds      |
; |             first and can successfuly copy into).                 |
; |                                                                   |
; | Notes:   1) This program may be run from any folder.              |
; |          2) This program need not be run from a workstation that  |
; |             is already configured to run HealthStar.              |
; |          2) This program reads data from a private profile string |
; |             in the SUPERBAS.INI files associated with HealthStar. |
; |          3) This program needs to be able to copy files into the  |
; |             appropriate directory for Microsoft Word templates.   |
; |             Since the Workgroup Templates directory is usually    |
; |             stored on a server and protected, this program must   |
; |             run in an administrator context IF you intend for it  |
; |             to install the template into a shared folder.         |
; |          4) Unlike its progenitor INSTWDOT.EXE, this program will |
; |             not try to replace an up to date template.            |
; |                                                                   |
; +--------------------------- Change Log ----------------------------+
; |                                                                   |
; | Date       By Whom  Remarks about what was done and why it was.   |
; | ---------- -------- --------------------------------------------- |
; | 08/31/1999 DAG      Adapted INSTWDOT to create this program.      |
; | to 09/21                                                          |
; |                                                                   |
; +-------------------------------------------------------------------+

; WIL functions must be declared before they can be used. So, here they are!

#DefineFunction RunProgramAndLog_P6C ( pstrProgramName , pstrProgramArgs , phLogFile )

	dtmNow = ""
	fReturnCode = @true
	fDummy = @false
	fResult = @true
	MSGBOX_ICON_FATAL_P6C = 16
	MSGBOX_ICON_INFO_P6C = 1088
	LogMessage = ""
	MessageText = ""

	BoxText ( StrCat ( "Running " , pstrProgramName , " ... " ) )
	dtmNow = TimeYmdHms ( )
	if pstrProgramArgs <> ""
		LogMessage = StrCat ( dtmNow , " - Program ", pstrProgramName , " Begin" , @crlf )
		LogMessage = StrCat ( LogMessage , "                           Program Arguments " , pstrProgramArgs )
	else
		LogMessage = StrCat ( dtmNow , " - Program ", pstrProgramName  , " Begin" )
	endif
	FileWrite ( phLogFile ,  LogMessage )	
	fResult = RunShell ( pstrProgramName , pstrProgramArgs , "" , @normal , @wait )
	if fResult
		BoxText ( StrCat ( "Running " , pstrProgramName , " ... Done " ) )
		dtmNow = TimeYmdHms ( )
		LogMessage = StrCat ( dtmNow , " - Program ", pstrProgramName  , " End" )
	else
		fReturnCode = @false
		MessageText = StrCat ( "ABORTING!" , @crlf , @crlf , "Unable to run program ", pstrProgramName )
		fDummy = xMessageBox ( "RunProgramAndLog_P6C" , MessageText , MSGBOX_ICON_FATAL_P6C )
		dtmNow = TimeYmdHms ( )
		LogMessage = StrCat ( dtmNow , " = ABORTING - Unable to run program ", pstrProgramName )
	endif
	FileWrite ( phLogFile ,  LogMessage )	
	Return fReturnCode

#EndFunction


#DefineFunction DoesFileExist_P6C ( pFileName )

; +-------------------------------------------------------------------+
; |                                                                   |
; | Function Name:    	DoesFileExist_P6C                             |
; |                                                                   |
; | Purpose:            Use the built-in WIL FileExist function to    |
; |                     test for the existence of a file. Since we    |
; |                     don't care whether the file is open, return   |
; |                     the same result whether it exists and is open |
; |                     by another process in deny write mode or is   |
; |                     present and not open in deny write mode.      |
; |                                                                   |
; | Arguments:          pFileName      = Name of file to fiind per    |
; |                                      requirements for FileExist   |
; |                                      function.                    |
; |                                                                   |
; | Returns:            fResult        = Result flag:                 |
; |                                          @true   = file exists.   |
; |                                          @false  = file does not  |
; |                                                    exist.         |
; |                                                                   |
; | Notes:            	None.                                         |
; |                                                                   |
; | Author:    			David A. Gray of P6 Consulting.               |
; |                                                                   |
; | Date Written:       Thursday, 06 September 2001.                  |
; |                                                                   |
; | Maintenance Log                                                   |
; |                                                                   |
; | Date       Who Description                                        |
; | ========== === ================================================== |
; |                                                                   |
; +-------------------------------------------------------------------+

    FileStatusCode = FileExist ( pFileName )
    select FileStatusCode
        case 1
            ; The file exists and is not open by another application in deny write mode.
            fResult = @true
            break
        case 0
            ; The file does not exist or the path is invalid.
            fResult = @false
            break
        case 2
            ; The file exists but another application has opened it in deny write mode.
            ; Since we just want to know that the file exists, it doesn't matter if
            ; another process has opened it.
            fResult = @true
            break
    endselect
    return fResult

#EndFunction


#DefineFunction CopyFileAndLog_P6C ( pSourceFileFQFN , pDestFileDir , pOverWriteRule , pfAttended , pWindowCaption , pFlags , pHLogFile )

; +-------------------------------------------------------------------+
; |                                                                   |
; | Subroutine Name:    CopyFileAndLog_P6C                            |
; |                                                                   |
; | Purpose:            Check the appropriate Registry key and return |
; |                     TRUE if User Profiles are enabled on the      |
; |                     local machine, otherwise return FALSE.        |
; |                                                                   |
; | Arguments:			pSourceFileFQFN   = Fully qualified name of   |
; |                                         file to be copied.        |
; |                                                                   |
; |                     pDestFileDir      = Directory into which file |
; |                                         is to be copied.          |
; |                                         NOTE: Trailing backslash  |
; |                                               is REQUIRED.        |
; |                                                                   |
; |                     pOverWriteRule    = Overwrite rule:           |
; |                                             A = Overwrite ALL.    |
; |                                             O = Overwrite OLDER.  |
; |                                             N = Overwrite NEWER.  |
; |                                             D = Overwrite (DON'T).|
; |                                                                   |
; |                                         Default = A.              |
; |                                                                   |
; |                     pfAttended        = Attended operation flag:  |
; |                                             @true  = Attended. OK |
; |                                                      to display   |
; |                                                      messages.    |
; |                                             @false = Unattended.  |
; |                                                      Suppress all |
; |                                                      messages.    |
; |                                                                   |
; |                                         Default = @false          |
; |                                                                   |
; |                     pWindowCaption    = Window title to use for   |
; |                                         any message boxes.        |
; |                                         Default=Function Name     |
; |                                         Ignored if pfAttended     |
; |                                         is false, as no messages  |
; |                                         will be displayed.        |
; |                                                                   |
; |                     pFlags            = Attribute flags to set:   |
; |                                             COPY = Copy from src. |
; |                                             COPY+mask = copy from |
; |                                                         source +  |
; |                                                         override  |
; |                                                         per mask: |
; |                                             	R = Set Read Only |
; |                                             mask = Set per Mask.  |
; |                                                                   |
; |                                             Mask Values:          |
; |                                             	R = Set Read Only |
; |                                             	r = Clear RO      |
; |                                             	A = Set Archive   |
; |                                             	a = Clear Archvie |
; |                                             	H = Set Hidden    |
; |                                             	h = Clear Hidden  |
; |                                             	S = Set System    |
; |                                             	s = Claar System  |
; |                                                                   |
; |                                         Default = nothing, sets A |
; |                                                   flag just like  |
; |                                                   MS-DOS COPY.    |
; |                                                                   |
; |                     pHLogFile         = Handle for log file or 0  |
; |                                         if logging is DISabled.   |
; |                                                                   |
; | Returns:            CopyResult        = Multi-part comma delimi-  |
; |                                         ted string as follows:    |
; |                                          	OVWR=pOverWriteRule   |
; |                                          	FLGS=pFlags           |
; |                                          	DEST=P|A|I:           |
; |                                          	     P=Dest. Present. |
; |                                          	     N=Dest. Absent.  |
; |                                          	     I=Dest. In Use.  |
; |                                          	AGED=EQ|SN|SO:        |
; |                                          	     EQ=Dates equal.  |
; |                                          	     SN=Source Newer. |
; |                                          	     SO=Source Older. |
; |                                          	     NA=Not Available |
; |                                          	        (Destination  |
; |                                          	        file does not |
; |                                          	        exist.)       |
; |                                          	     RSLT=OK|FAIL_xx, |
; |                                          	          where xx is |
; |                                          	          the ordinal |
; |                                          	          number of a |
; |                                          	          fail point. |
; |                                                                   |
; | Notes:            	None.                                         |
; |                                                                   |
; | Author:    			David A. Gray of P6 Consulting.               |
; |                                                                   |
; | Date Written:       06 - 07 September 2001.                       |
; |                                                                   |
; | Maintenance Log                                                   |
; |                                                                   |
; | Date       Who Description                                        |
; | ========== === ================================================== |
; |                                                                   |
; +-------------------------------------------------------------------+

	MSGBOX_ICON_FATAL_P6C = 16
	MSGBOX_ICON_INFO_P6C = 1088

	LogMessage = StrCat ( TimeYmdHms () , " - " )
	fOKtoCopyFile = @false
	if pfAttended == ""
		pfAttended = @false
	else
		if pfAttended && pWindowCaption == ""
			pWindowCaption = "CopyFileAndLog_P6C"
		endif
	endif
	FileSourceDir = FilePath ( pSourceFileFQFN )
	FileSourceDirLen = StrLen ( FileSourceDir )
	FileToCopy = StrSub ( pSourceFileFQFN , ( FileSourceDirLen + 1 ) , -1 )
	DestFileNameFQFN = StrCat ( pDestFileDir , FileToCopy )
	CopyResult = ""
	CopyResult = ItemInsert ( StrCat ( "OVWR=" , pOverWriteRule ) , -1 , CopyResult , "," )
	CopyResult = ItemInsert ( StrCat ( "FLGS=" , pFlags ) , -1 , CopyResult , "," )
	switch FileExist ( pSourceFileFQFN )
		case @true
			SourceFileStamp = FileYmdHms ( pSourceFileFQFN )
			switch FileExist ( DestFileNameFQFN )
				case @true
					CopyResult = ItemInsert ( "DEST=P" , -1 , CopyResult , "," )
					DestFileStamp = FileYmdHms ( DestFileNameFQFN )
					if SourceFileStamp == DestFileStamp
						CopyResult = ItemInsert ( "AGED=EQ" , -1 , CopyResult , "," )
						DateMessage = "SAME AS"
					endif
					if SourceFileStamp > DestFileStamp
						CopyResult = ItemInsert ( "AGED=SN" , -1 , CopyResult , "," )
						DateMessage = "NEWER THAN"
					endif
					if SourceFileStamp < DestFileStamp
						CopyResult = ItemInsert ( "AGED=SO" , -1 , CopyResult , "," )
						DateMessage = "OLDER THAN"
					endif
					if pOverWriteRule == "A" || pOverWriteRule == ""
						fOKtoCopyFile = @true
					else
						if pOverWriteRule == "O" && SourceFileStamp > DestFileStamp
							fOKtoCopyFile = @true
						else
							if pOverWriteRule == "N" && SourceFileStamp < DestFileStamp
								fOKtoCopyFile = @true
							endif
						endif
					endif
					if fOKtoCopyFile
						fResult = FileAttrSet ( DestFileNameFQFN , "rash" )
						DestAttribs = FileAttrGet ( DestFileNameFQFN )
						if DestAttribs <> "----"
							MessageText = StrCat ( "Copying file " , pSourceFileFQFN , " ... Copy FAILED" )
							BoxText ( MessageText )
							if pfAttended
								MessageText = StrCat ( "WARNING!" , @crlf , @crlf , "Unable to copy file " , pSourceFileFQFN )
								MessageText = StrCat ( MessageText , @crlf , "because Read-Only, Hidden, or System attribute" )
								MessageText = StrCat ( MessageText , @crlf , "could not be removed from destination file " )
								MessageText = StrCat ( MessageText , DestFileNameFQFN , @crlf , @crlf , "See log file for details." )
						    	fResult = xMessageBox ( pWindowCaption , MessageText , MSGBOX_ICON_INFO_P6C )
							endif
							if pHLogFile > 0
								LogMessage = StrCat ( LogMessage , "                      copy FAILED" , @crlf )
								LogMessage = StrCat ( LogMessage , "                      because Read-Only, Hidden, or System attribute" , @crlf  )
								LogMessage = StrCat ( LogMessage , "                      could not be removed from destination file " , @crlf )
								LogMessage = StrCat ( LogMessage , "                      file attribute flags are ", DestAttribs )
							endif
							fOKtoCopyFile = @false
							CopyResult = ItemInsert ( "RSLT=FAIL_01" , -1 , CopyResult , "," )
						endif
					endif
					break
				case @false
					CopyResult = ItemInsert ( "DEST=A" , -1 , CopyResult , "," )
					CopyResult = ItemInsert ( "AGED=NA" , -1 , CopyResult , "," )
					DateMessage = "NOT AVAILABLE"
					SourceFileStamp = "NOT AVAILABLE"
					fOKtoCopyFile = @true
					break
				case response
					CopyResult = ItemInsert ( "DEST=I" , -1 , CopyResult , "," )
					break
					; Do nothing. The file will be neither created nor overwritten.
			endswitch
			if fOKtoCopyFile
				MessageText = StrCat ( "Copying file " , pSourceFileFQFN , " ..." )
				BoxText ( MessageText )
				if pHLogFile > 0
					IF DateMessage == "NOT AVAILABLE"
						LogMessage = StrCat ( LogMessage , "COPYING file " , pSourceFileFQFN , @crlf )
	 					LogMessage = StrCat ( LogMessage , "                      into destination directory " , pDestFileDir , @crlf )
						LogMessage = StrCat ( LogMessage , "                      Date stamp on destination file is " , DateMessage , @crlf )
						LogMessage = StrCat ( LogMessage , "                      File does not exist in destination directory" , @crlf )
						LogMessage = StrCat ( LogMessage , "                      File in source directory " , FileSourceDir , @crlf )
						LogMessage = StrCat ( LogMessage , "                      has a date stamp of " , SourceFileStamp , @crlf )
					else
						LogMessage = StrCat ( LogMessage , "COPYING file " , pSourceFileFQFN , @crlf )
					 	LogMessage = StrCat ( LogMessage , "                      Date stamp of " , DestFileStamp , @crlf )
				 		LogMessage = StrCat ( LogMessage , "                      on file in destination directory " , pDestFileDir , " is " , DateMessage , @crlf )
						LogMessage = StrCat ( LogMessage , "                      file stamp of " , SourceFileStamp , @crlf )
						LogMessage = StrCat ( LogMessage , "                      on file in source directory" , FileSourceDir , @crlf )
					endif
				endif
				if StrSub ( pFlags , 1, 4 ) == "COPY"
					SourceFileAttribs = FileAttrGet ( pSourceFileFQFN )
					if FileExist ( DestFileNameFQFN )
						fResult = FileAttrSet ( DestFileNameFQFN , "rash" )
						DestAttribs = FileAttrGet ( DestFileNameFQFN )
					else
						DestAttribs = "----"
					endif
					if DestAttribs == "----"
						ErrorMode ( @off )
						fResult = FileCopyAttr ( pSourceFileFQFN , DestFileNameFQFN , @false , SourceFileAttribs )
						ErrorMode ( @cancel )
					else
						MessageText = StrCat ( "Copying file " , pSourceFileFQFN , " ... Copy FAILED" )
						BoxText ( MessageText )
						if pfAttended
							MessageText = StrCat ( "WARNING!" , @crlf , @crlf , "Unable to copy file " , pSourceFileFQFN )
							MessageText = StrCat ( MessageText , @crlf , "because Read-Only, Hidden, or System attribute" )
							MessageText = StrCat ( MessageText , @crlf , "could not be removed from destination file " )
							MessageText = StrCat ( MessageText , DestFileNameFQFN , @crlf , @crlf , "See log file for details." )
						    fResult = xMessageBox ( pWindowCaption , MessageText , MSGBOX_ICON_INFO_P6C )
						endif
						if pHLogFile > 0
							LogMessage = StrCat ( LogMessage , "                      copy FAILED" , @crlf )
							LogMessage = StrCat ( LogMessage , "                      because Read-Only, Hidden, or System attribute" , @crlf  )
							LogMessage = StrCat ( LogMessage , "                      could not be removed from destination file " , @crlf )
							LogMessage = StrCat ( LogMessage , "                      file attribute flags are ", DestAttribs )
						endif
						CopyResult = ItemInsert ( "RSLT=FAIL_02" , -1 , CopyResult , "," )
					endif
				else
					ErrorMode ( @off )
					fResult = FileCopy ( pSourceFileFQFN , DestFileNameFQFN , @false )
					ErrorMode ( @cancel )
				endif
				if fResult
					if pHLogFile > 0
						LogMessage = StrCat ( LogMessage , "                      copy SUCCEEDED" , @crlf )
						if StrSub ( pFlags , 1, 5 ) == "COPY+" || ( StrLen ( pFlags ) > 0 && StrSub ( pFlags , 1, 4 ) <> "COPY" )
							if StrSub ( pFlags , 1, 5 ) == "COPY+"
								NewFlagMask = StrSub ( pFlags , 5 , -1 )
							else
								NewFlagMask = pFlags
							endif
							OldFlagMask = FileAttrGet ( DestFileNameFQFN )
							fResult = FileAttrSet ( DestFileNameFQFN , "rash" )
							TestFlagMask = FileAttrGet ( DestFileNameFQFN )
							if TestFlagMask == "----"
								fResult = FileAttrSet ( DestFileNameFQFN , NewFlagMask )						
								TestFlagMask = FileAttrGet ( DestFileNameFQFN )
								; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
								
								if CheckFileAttribs_P6C ( TestFlagMask , NewFlagMask )
									MessageText = StrCat ( "Copying file " , pSourceFileFQFN , " ... Done" )
									BoxText ( MessageText )
									if pHLogFile > 0
										LogMessage = StrCat ( LogMessage , "                      Destination file attributes SET to " , NewFlagMask )
									endif
									CopyResult = ItemInsert ( "RSLT=OK" , -1 , CopyResult , "," )
								else
									MessageText = StrCat ( "Copying file " , pSourceFileFQFN , " ... succeeded but attributes NOT SET" )
									BoxText ( MessageText )
									if pfAttended
										MessageText = StrCat ( "WARNING!" , @crlf , @crlf , "Unable to set attributes on destination file " , DestFileNameFQFN )
									    fResult = xMessageBox ( pWindowCaption , MessageText , MSGBOX_ICON_INFO_P6C )
									endif
									if pHLogFile > 0
										LogMessage = StrCat ( LogMessage , "                      attributes NOT SET" )
									endif
							CopyResult = ItemInsert ( "RSLT=FAIL_03" , -1 , CopyResult , "," )
								endif
							else
								MessageText = StrCat ( "Copying file " , pSourceFileFQFN , " ... succeeded but attributes NOT SET" )
								BoxText ( MessageText )
								if pfAttended
									MessageText = StrCat ( "WARNING!" , @crlf , @crlf , "Unable to set attributes on destination file " , DestFileNameFQFN )
								    fResult = xMessageBox ( pWindowCaption , MessageText , MSGBOX_ICON_INFO_P6C )
								endif
								if pHLogFile > 0
									LogMessage = StrCat ( LogMessage , "                      attributes NOT SET" )
								endif
								CopyResult = ItemInsert ( "RSLT=FAIL_04" , -1 , CopyResult , "," )
							endif
						else
							MessageText = StrCat ( "Copying file " , pSourceFileFQFN , " ... Done" )
							BoxText ( MessageText )
							if pHLogFile > 0
								LogMessage = StrCat ( LogMessage , "                      copy SUCCEEDED" , @crlf )
								LogMessage = StrCat ( LogMessage , "                      Destination file attributes SET to " , NewFlagMask )
							endif
							CopyResult = ItemInsert ( "RSLT=OK" , -1 , CopyResult , "," )
						endif
					endif
				else
					MessageText = StrCat ( "Copying file " , pSourceFileFQFN , " ... Copy FAILED" , @crlf )
					BoxText ( MessageText )
					if pfAttended
						MessageText = StrCat ( "WARNING!" , @crlf , @crlf , "Unable to copy file " , pSourceFileFQFN )
			    		fResult = xMessageBox ( pWindowCaption , MessageText , MSGBOX_ICON_INFO_P6C )
					endif
					if pHLogFile > 0
						LogMessage = StrCat ( LogMessage , "                      copy FAILED" , @crlf )
					endif
					CopyResult = ItemInsert ( "RSLT=FAIL_05" , -1 , CopyResult , "," )
				endif
			endif
			break
		case @false
			if pHLogFile > 0	
				LogMessage = StrCat ( LogMessage , "                      COPYING file " , pSourceFileFQFN , @crlf )
	 			LogMessage = StrCat ( LogMessage , "                      into destination directory " , pDestFileDir , @crlf )
				LogMessage = StrCat ( LogMessage , "                      FAILED - Sourcce file does not exist" )
			endif
			if pfAttended
				MessageText = StrCat ( "WARNING!" , @crlf , @crlf , "Source file " , pSourceFileFQFN )
				MessageText = StrCat ( MessageText , @crlf , "does not exist and therefore cannot be copied." )
			    fResult = xMessageBox ( pWindowCaption , MessageText , MSGBOX_ICON_INFO_P6C )
			endif
			CopyResult = ItemInsert ( "RSLT=FAIL_06" , -1 , CopyResult , "," )
			break
		case response
			; Do nothing. The source file is right where it's supposed to be.
			break
	endswitch
	if pHLogFile > 0
		FileWrite ( pHLogFile ,LogMessage )
	endif
	return CopyResult

#EndFunction

#DefineFunction CheckFileAttribs_P6C ( pFlagsFromFile , pDesiredFlags )

	TestResult = @true
	NFlags = StrLen ( pDesiredFlags )
	aTestResults = ArrDimension ( NFlags )
	For I = 1 to NFlags
		J = I - 1
		TestFlagChar = StrSub ( pDesiredFlags , I , 1 )
		TestFlagCode = Char2Num ( TestFlagChar )
		ScanResult = StrIndex ( pFlagsFromFile , StrUpper ( TestFlagChar ) , 1 , @fwdscan )
		; Upper Case Letters = 65-90
		; Lower Case Letters = 97-122
		if TestFlagCode > 64 && TestFlagCode < 91
			if ScanResult				
				aTestResults [ J ] = @true
			else
				aTestResults [ J ] = @false
			endif
		endif
		if TestFlagCode > 96 && TestFlagCode < 123
			if ScanResult
				aTestResults [ J ] = @false
			else
				aTestResults [ J ] = @true
			endif
		endif
	next
	for I = 0 to NFlags - 1
		If aTestResults [ I ] == @false
			break
		endif
	next
	return TestResult

#EndFunction

:MainBegin

    ; This is the start of the mainline routine.

	; Set up error handling.

	IntControl ( 73 , 1 , 0 , 0 , 0 )

	; Declare variables that we intend to use as constants.

	ATTRIBUTE_FLAG_ARCHIVE_SET = "A"
	ATTRIBUTE_FLAG_ARCHIVE_CLEAR = "a"
	ATTRIBUTE_FLAG_HIDDEN_SET = "H"
	ATTRIBUTE_FLAG_HIDDEN_CLEAR = "h"
	ATTRIBUTE_FLAG_READ_ONLY_SET = "R"
	ATTRIBUTE_FLAG_READ_ONLY_CLEAR = "r"
	ATTRIBUTE_FLAG_SYSTEM_SET = "S"
	ATTRIBUTE_FLAG_SYSTEM_CLEAR = "s"

	MSGBOX_ICON_FATAL_P6C = 16
	MSGBOX_ICON_INFO_P6C = 1088

	OVERWRITERULE_ALL = "A"
	OVERWRITERULE_OLDER = "O"
	OVERWRITERULE_NEWER = "N"
	OVERWRITERULE_NEVER = "D"

	; Initialize some other variables variables.

    CopyrightNotice = StrCat ( "HealthStar Workstation configurator version 1.0, copyright 2001, Caltex Corporation." ,  @cr  , @cr )

    mWhichSub = "Main"
    fAbort = @false
    fDone = @false
	fFlagDestinationReadOnly = @true
	fOffice2000Installed = @true
	fOKToOverwriteReadOnlyFile = @true
	fWarning = @false

	MyWindowCaption = "HealthStar HStarWSConfig"

	; Assign a distinctive window title.

	fResult = WinTitle ( "" , MyWindowCaption )
	if fResult == @false
		MessageText = StrCat ( "ABORTING!" , @crlf , @crlf , "I was unable to change my window title!" )
		varTimeNow = TimeYmdHms ()
		MessageText = "%varTimeNow% - Program was unable to change its window title, aborted."
		FileWrite ( hLogFile , MessageText )
		display ( 3 , MyWindowCaption , MessageText )
		goto MainEnd
	endif

	BoxTitle ( MyWindowCaption )
	WinActivate ( MyWindowCaption )
	BoxText ( "Initializing, please wait." )

   	; Load the WILX extender so it will be ready for us to use in the MessageBox routine.

	fResult = AddExtender ( "wilx34i.dll" )
	if fResult == @false
		MessageText = StrCat ( "ABORTING!" , @crlf , @crlf , "The WILX extender library did not load!" )
		varTimeNow = TimeYmdHms ()
		MessageText = "%varTimeNow% - Program was unable to load the WILx Extender DLL, aborted."
		FileWrite ( hLogFile , MessageText )
		display ( 3 , MyWindowCaption , MessageText )
		goto MainEnd
	endif

	; Create a diagnostic log and write a header record into it.

	strMyName = IntControl (1004 , 0 , 0 , 0 , 0 )
	strProgName = FileRoot ( strMyName )
	ProgramPath = FilePath ( strMyName )
	LogFileName = "%ProgramPath%%strProgName%.LOG"
	hLogFile = FileOpen ( LogFileName , "APPEND" )
	if hLogFile == 0
		MessageText = StrCat ( "ABORTING!" , @crlf , @crlf , "Unable to open activity log file " , LogFileName , "!" )
		fResult = xMessageBox ( MyWindowCaption , MessageText , MSGBOX_ICON_FATAL_P6C )
		fAbort = @true
		goto MainEnd
	endif
	
	varTimeNow = TimeYmdHms ()
	MessageText = "%varTimeNow% - HStarWSConfig version 1.0 - Begin"
	FileWrite ( hLogFile , MessageText )

	; Now do the real work.

	BoxText ( "Gathering information about OS and security settings...." )

	; Get Windows version information.

	WinMajorVersion = WinVersion ( 1 )
	if hLogFile > 0
		varTimeNow = TimeYmdHms ()								  
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% - Windows Major Version = " , WinMajorVersion )  )
	endif

	WinMinorVersion = WinVersion ( 0 )
	if hLogFile > 0
		varTimeNow = TimeYmdHms ()
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% - Windows Minor Version = " , WinMinorVersion) )
	endif

	WinPlatformCode = WinVersion ( 4 )
	switch WinPlatformCode
		case 0
			WinPlatformText = "Other"
			ProfileKeyName = ""
			break
		case 1
			WinPlatformText = "Windows (3.x)"
			ProfileKeyName = ""
			break
		case 2
			WinPlatformText  = "Windows for Workgroups"
			ProfileKeyName = ""
			break
		case 3
			WinPlatformText  = "Win32s on Windows 3.1x"
			ProfileKeyName = ""
			break
		case 4
			WinPlatformText  = "Windows NT"
			ProfileKeyName = "Software\Microsoft\Windows NT\CurrentVersion\ProfileList"
			break
		case 5
			WinPlatformText  = "Windows95/98"
			ProfileKeyName = "Software\Microsoft\Windows\CurrentVersion\ProfileList"
			break
		case WinPlatformCode
			WinPlatformText  = StrCat ( "Undefined platform id of " , WinPlatformCode)
			ProfileKeyName = ""
			break
	endswitch
	if hLogFile > 0
		varTimeNow = TimeYmdHms ()
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% - Windows Platform = " , WinPlatformCode, " (" , WinPlatformText , ")" ) )
	endif

	WinBuildNumber = WinVersion ( 2 )
	if hLogFile > 0
		varTimeNow = TimeYmdHms ()
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% - Windows Build Number = ", WinBuildNumber ) )
	endif
	WinCSDNumber = WinVersion ( 3 )
	if hLogFile > 0
		varTimeNow = TimeYmdHms ()
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% - Windows CSD Number = " , WinCSDNumber) )
	endif

	WinVersionString = WinVersion ( 5 )
	if hLogFile > 0
		varTimeNow = TimeYmdHms ()
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% - Windows Version String = " , WinVersionString) )
	endif

	; Get the name of the LOCAL computer.

	LocalMachineName = RegQueryValue ( @regmachine , "System\CurrentControlSet\control\ComputerName\ComputerName[ComputerName]" )
	if hLogFile > 0
		varTimeNow = TimeYmdHms ()
		FileWrite ( hLogFile , "%varTimeNow% - NETBIOS name of this machine = %LocalMachineName%" )
	endif

	; Determine whether User Profiles are enabled.

	if ProfileKeyName == ""
		fProfilesEnabled = @false
	else
    	fResult = RegExistKey ( @regmachine , ProfileKeyName )
		if fResult == @true
			fProfilesEnabled = @true
		else
			fProfilesEnabled = @false
		endif
	endif
	if hLogFile > 0
		varTimeNow = TimeYmdHms ()
		if fProfilesEnabled
			ProfileMessage = "User Profiles = ENABLED"
		else
			ProfileMessage = "User Profiles = DISABLED"
		endif
		FileWrite ( hLogFile , "%varTimeNow% - %ProfileMessage%" )
	endif

	fResult = AddExtender ( "WWNET34I.DLL" )
	if fResult
		WinLocalUserName = netGetUser ( @default )
		if hLogFile > 0
			varTimeNow = TimeYmdHms ()
			FileWrite ( hLogFile , "%varTimeNow% - Windows Local user name = %WinLocalUserName%" )
		endif
	else
		MessageText = "The WWNET34I network extender library did not load!"
		MessageText2 = StrCat ( "ABORTING!" , @crlf , @crlf , MessageText )
		fDummy = xMessageBox ( MyWindowCaption , MessageText , MSGBOX_ICON_FATAL_P6C )
		if hLogFile > 0
			varTimeNow = TimeYmdHms ()
			FileWrite ( hLogFile , "%varTimeNow%" )
			FileWrite ( hLogFile , "%varTimeNow% - ABORTING: MessageText" )
			FileWrite ( hLogFile , "%varTimeNow% - If this problem persists, please send this file to TECHNICAL SUPPORT." )
			FileWrite ( hLogFile , "%varTimeNow%" )
		endif
		goto MainEnd
	endif

	; If the local machine is running Windows NT or Windows 2000, make sure we are running in the contest of a Local Administrator.

	if WinPlatformCode > 3
		fResult = AddExtender ( "WWWNT34I.DLL" )
		if fResult
			AccountPrivilegeLevel = wntUserGetDat ( "", WinLocalUserName , "priv" )
			if AccountPrivilegeLevel == 2
				if hLogFile > 0
					varTimeNow = TimeYmdHms ()
					FileWrite ( hLogFile , "%varTimeNow% - Local User %WinLocalUserName% is a member of the Administrators group." )
					FileWrite ( hLogFile , "%varTimeNow% - Proceeding with configuration." )
					FileWrite ( hLogFile , "%varTimeNow%" )
				endif
			else
				fAbort = @true
				MessageText = StrCat ( "You must be a member of the Local Administrators group to run this program." , @crlf , @crlf )
				MessageText = StrCat ( MessageText , "Please log on with sufficient privileges and run this program again." )
				MessageText2 = StrCat ( "ABORTING!" , @crlf , @crlf , MessageText )
				fDummy = xMessageBox ( MyWindowCaption , MessageText , MSGBOX_ICON_FATAL_P6C )
				if hLogFile > 0
					varTimeNow = TimeYmdHms ()
					FileWrite ( hLogFile , "%varTimeNow%" )
					FileWrite ( hLogFile , "%varTimeNow% - ABORTING: Local User %WinLocalUserName% is not a member of the Administrators group." )
					FileWrite ( hLogFile , "%varTimeNow% - Please log on as a Local Administrator and run this program again." )
					FileWrite ( hLogFile , "%varTimeNow%" )
				endif
				goto MainEnd
			endif
		else
			fAbort = @true
			MessageText = "The WWNET34I network extender library did not load!"
			MessageText2 = StrCat ( "ABORTING!" , @crlf , @crlf , MessageText )
			fDummy = xMessageBox ( MyWindowCaption , MessageText , MSGBOX_ICON_FATAL_P6C )
			if hLogFile > 0
				varTimeNow = TimeYmdHms ()
				FileWrite ( hLogFile , "%varTimeNow%" )
				FileWrite ( hLogFile , "%varTimeNow% - ABORTING: MessageText" )
				FileWrite ( hLogFile , "%varTimeNow% - If this problem persists, please send this file to TECHNICAL SUPPORT." )
				FileWrite ( hLogFile , "%varTimeNow%" )
			endif
			goto MainEnd
		endif
	endif

	; Copy configuration files to %SystemRoot% directory on local machine.

	SystemRoot = DirWindows ( 0 )
	HomeDirName = StrCat ( ProgramPath , "HOME\" )
	HStarProfileName = StrCat ( HomeDirName , "DATAPIPE.INI" )
	ResultFlags = CopyFileAndLog_P6C ( HStarProfileName , SystemRoot , OVERWRITERULE_ALL , @true , MyWindowCaption , ATTRIBUTE_FLAG_READ_ONLY_CLEAR , hLogFile )
	if StrIndex ( ResultFlags , "RSLT=OK" , 1 , @fwdscan ) == 0
		fAbort = @true
		if IsDefined ( hLogFile )
			if hLogFile > 0
				varTimeNow = TimeYmdHms ()
				MessageText = StrCat ( "Function CopyFileAndLog_P6C failed," , @crlf )
			 	MessageText = StrCat ( MessageText , "                      returning a result string of " , ResultFlags )
				FileWrite ( hLogFile , "%varTimeNow%" )
				FileWrite ( hLogFile , StrCat ( "%varTimeNow% - ABORTING: " , MessageText , @crlf ) )
				FileWrite ( hLogFile , "%varTimeNow% - If this problem persists, please send this file to EHS SERVICES." )
				FileWrite ( hLogFile , "%varTimeNow%" )
			endif
		endif
		goto MainEnd
	endif
	HStarProfileInstalled = StrCat ( SystemRoot , "DATAPIPE.INI" )
	SuperBaseProfileName = StrCat ( HomeDirName , "SUPERBAS.INI" )
	ResultFlags = CopyFileAndLog_P6C ( SuperBaseProfileName , SystemRoot , OVERWRITERULE_ALL , @true , MyWindowCaption , ATTRIBUTE_FLAG_READ_ONLY_CLEAR , hLogFile )
	if StrIndex ( ResultFlags , "RSLT=OK" , 1 , @fwdscan ) == 0
		fAbort = @true
		if IsDefined ( hLogFile )
			if hLogFile > 0
				varTimeNow = TimeYmdHms ()
				MessageText = StrCat ( "Function CopyFileAndLog_P6C failed," , @crlf )
			 	MessageText = StrCat ( MessageText , "                      returning a result string of " , ResultFlags )
				FileWrite ( hLogFile , "%varTimeNow%" )
				FileWrite ( hLogFile , StrCat ( "%varTimeNow% - ABORTING: " , MessageText , @crlf ) )
				FileWrite ( hLogFile , "%varTimeNow% - If this problem persists, please send this file to EHS SERVICES." )
				FileWrite ( hLogFile , "%varTimeNow%" )
			endif
		endif
		goto MainEnd
	endif

	; If the local OS is Windows NT, Set permissions on configuration files.

	if WinPlatformCode > 3
		FileWrite ( hLogFile , "%varTimeNow%" )

		AccessList = wntAccessList ( "" , HStarProfileInstalled ,  300 , 0 )
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% - Users who have permissions for file " , HStarProfileInstalled , " = " , AccessList ) )

		OldPermissionsEveryone = wntAccessGet ( "" , HStarProfileInstalled , "Everyone" , 300 )
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% - Default permissions for group Everyone return for file " , HStarProfileInstalled , " = " , OldPermissionsEveryone ) )

		NewPermissionsEveryone = wntAccessAdd ( "" , HStarProfileInstalled , "Everyone" , 300 , "File:Change" )
		if NewPermissionsEveryone
			FileWrite ( hLogFile , StrCat ( "%varTimeNow% - CHANGE permissions successfully assigned to file " , HStarProfileInstalled , " = " , NewPermissionsEveryone ) )
		else
			fAbort = @true
			MessageText = StrCat ( "Unable to set required permissions on file " , HStarProfileInstalled , @crlf )
			MessageText = StrCat ( MessageText , "HealthStar users require CHANGE permissions on this file." )
			MessageText2 = StrCat ( "ABORTING!" , @crlf , @crlf , MessageText )
			fDummy = xMessageBox ( MyWindowCaption , MessageText , MSGBOX_ICON_FATAL_P6C )
			if hLogFile > 0
				varTimeNow = TimeYmdHms ()
				FileWrite ( hLogFile , "%varTimeNow%" )
				FileWrite ( hLogFile , "%varTimeNow% - ABORTING: Unable to set required permissions on file " , HStarProfileInstalled , @crlf )
				FileWrite ( hLogFile , "%varTimeNow% - If this problem persists, please send this file to EHS SERVICES." )
				FileWrite ( hLogFile , "%varTimeNow%" )
			endif
			goto MainEnd
		endif

		ChkPermissionsEveryone = wntAccessGet ( "" , HStarProfileInstalled , "Everyone" , 300 )
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% - New permissions for group Everyone return for file " , HStarProfileInstalled , " = " , ChkPermissionsEveryone ) )

		FileWrite ( hLogFile , "%varTimeNow%" )
	endif

	; For all installations, locate the Start Menu and create or update the HealthStar icons as necessary.

	MainStartMenuDir = RegQueryValue ( @regmachine , "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders[Common Start Menu]")
	HealthStarMenu = StrCat ( MainStartMenuDir , "\Programs\HealthStar in Windows\" )
	if DirExist ( HealthStarMenu )
		varTimeNow = TimeYmdHms ()
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% - Program folder " , HealthStarMenu , " already exists." ) )
		if FileExist ( StrCat ( HealthStarMenu , "Add MSDS User to HealthStar.lnk" ) )
			fResult = FileDelete ( StrCat ( HealthStarMenu , "Add MSDS User to HealthStar.lnk" ) )
			if fResult
				varTimeNow = TimeYmdHms ()
				FileWrite ( hLogFile , "%varTimeNow% - Program icon Add MSDS User to HealthStar.lnk exists, removed" )
			else
				fAbort = @true
				MessageText = StrCat ( "Unable to delete shortcut on Start Menu for HealthStar in Windows." , @crlf )
				MessageText = StrCat ( MessageText , "for Add MSDS User to HealthStar program." , @crlf )
				MessageText = StrCat ( MessageText , "Please contact EHS Services for instructions." )
				MessageText2 = StrCat ( "ABORTING!" , @crlf , @crlf , MessageText )
				fDummy = xMessageBox ( MyWindowCaption , MessageText , MSGBOX_ICON_FATAL_P6C )
				if hLogFile > 0
					varTimeNow = TimeYmdHms ()
					FileWrite ( hLogFile , "%varTimeNow%" )
					FileWrite ( hLogFile , "%varTimeNow% - ABORTING: Unable to delete shortcut on Start Menu for HealthStar in Windows." )
					FileWrite ( hLogFile , "%varTimeNow% -           Name of shortcut is for Add MSDS User to HealthStar.LNK" )
					FileWrite ( hLogFile , "%varTimeNow% - If this problem persists, please send this file to EHS SERVICES." )
					FileWrite ( hLogFile , "%varTimeNow%" )
				endif
				goto MainEnd
			endif
		endif
		if FileExist ( StrCat ( HealthStarMenu , "HealthStar in Windows.lnk" ) )
			fResult = FileDelete ( StrCat ( HealthStarMenu , "HealthStar in Windows.lnk" ) )
			if fResult
				varTimeNow = TimeYmdHms ()
				FileWrite ( hLogFile , "%varTimeNow% - Program icon HealthStar in Windows.lnk exists, removed" )
			else
				fAbort = @true
				MessageText = StrCat ( "Unable to delete shortcut on Start Menu for HealthStar in Windows." , @crlf )
				MessageText = StrCat ( MessageText , "for HealthStar in Windows program." , @crlf )
				MessageText = StrCat ( MessageText , "Please contact EHS Services for instructions." )
				MessageText2 = StrCat ( "ABORTING!" , @crlf , @crlf , MessageText )
				fDummy = xMessageBox ( MyWindowCaption , MessageText , MSGBOX_ICON_FATAL_P6C )
				if hLogFile > 0
					varTimeNow = TimeYmdHms ()
					FileWrite ( hLogFile , "%varTimeNow%" )
					FileWrite ( hLogFile , "%varTimeNow% - ABORTING: Unable to delete shortcut on Start Menu for HealthStar in Windows." )
					FileWrite ( hLogFile , "%varTimeNow% -           Name of shortcut is for HealthStar in Windows.LNK" )
					FileWrite ( hLogFile , "%varTimeNow% - If this problem persists, please send this file to EHS SERVICES." )
					FileWrite ( hLogFile , "%varTimeNow%" )
				endif
				goto MainEnd
			endif
		endif
	else
		fResult = DirMake ( HealthStarMenu )
		if fResult
			varTimeNow = TimeYmdHms ()
			FileWrite ( hLogFile , StrCat ( "%varTimeNow% - Program folder " , HealthStarMenu , " created." ) )
		else
			fAbort = @true
			MessageText = StrCat ( "Unable to create folder on Start Menu for HealthStar in Windows." , @crlf )
			MessageText = StrCat ( MessageText , "Please contact EHS Services for instructions." )
			MessageText2 = StrCat ( "ABORTING!" , @crlf , @crlf , MessageText )
			fDummy = xMessageBox ( MyWindowCaption , MessageText , MSGBOX_ICON_FATAL_P6C )
			if hLogFile > 0
				varTimeNow = TimeYmdHms ()
				FileWrite ( hLogFile , "%varTimeNow%" )
				FileWrite ( hLogFile , "%varTimeNow% - ABORTING: Unable to create folder on Start Menu for HealthStar in Windows." )
				FileWrite ( hLogFile , "%varTimeNow% -           Name of folder should be HealthStarMenu"
				FileWrite ( hLogFile , "%varTimeNow% - If this problem persists, please send this file to EHS SERVICES." )
				FileWrite ( hLogFile , "%varTimeNow%" )
			endif
			goto MainEnd
		endif
	endif

	; Create icon for Add MSDS User to HealthStar.

	LinkName = StrCat ( HealthStarMenu , "Add MSDS User to HealthStar.LNK" )
	Target = StrCat ( ProgramPath , "RTS\SBRTS.EXE" )
	ProgramParams = StrCat ( ProgramPath , "home\ADDMSDS.SBP" )
	StartDir = StrCat ( ProgramPath , "RTS" )
	ShowMode = @normal
	fResult = ShortcutMake ( LinkName , Target , ProgramParams , StartDir , ShowMode )
	if fResult
		varTimeNow = TimeYmdHms ()
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% - Program item " , LinkName , " created." ) )
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% -           Settings: LinkName      = " , LinkName ) )
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% -                     Target        = " , Target ) )
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% -                     ProgramParams = " , ProgramParams ) )
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% -                     StartDir      = " , StartDir ) )
		FileWrite ( hLogFile , "%varTimeNow% -                     ShowMode      = NORMAL" )
	else
		fAbort = @true
		MessageText = StrCat ( "Unable to create Program Item for Add MSDS User to HealthStar." , @crlf )
		MessageText = StrCat ( MessageText , "Please contact EHS Services for instructions." )
		MessageText2 = StrCat ( "ABORTING!" , @crlf , @crlf , MessageText )
		fDummy = xMessageBox ( MyWindowCaption , MessageText , MSGBOX_ICON_FATAL_P6C )
		if hLogFile > 0
			varTimeNow = TimeYmdHms ()
			FileWrite ( hLogFile , "%varTimeNow%" )
			FileWrite ( hLogFile , "%varTimeNow% - ABORTING: Unable to create Program Item for Add MSDS User to HealthStar." )
			FileWrite ( hLogFile , StrCat ( "%varTimeNow% -           Required Settings: LinkName      = " , LinkName ) )
			FileWrite ( hLogFile , StrCat ( "%varTimeNow% -                              Target        = " , Target ) )
			FileWrite ( hLogFile , StrCat ( "%varTimeNow% -                              ProgramParams = " , ProgramParams ) )
			FileWrite ( hLogFile , StrCat ( "%varTimeNow% -                              StartDir      = " , StartDir ) )
			FileWrite ( hLogFile , "%varTimeNow% -                              ShowMode      = NORMAL" )
			FileWrite ( hLogFile , "%varTimeNow% - If this problem persists, please send this file to EHS SERVICES." )
			FileWrite ( hLogFile , "%varTimeNow%" )
		endif
		goto MainEnd
	endif

	; Create icon for HealthStar in Windows.

	LinkName = StrCat ( HealthStarMenu , "HealthStar in Windows.LNK" )
	Target = StrCat ( ProgramPath , "RTS\SBRTS.EXE" )
	ProgramParams = StrCat ( ProgramPath , "home\start.sbp" )
	StartDir = StrCat ( ProgramPath , "RTS" )
	ShowMode = @normal
	fResult = ShortcutMake ( LinkName , Target , ProgramParams , StartDir , ShowMode )
	if fResult
		varTimeNow = TimeYmdHms ()
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% - Program item " , LinkName , " created." ) )
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% -           Settings: LinkName      = " , LinkName ) )
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% -                     Target        = " , Target ) )
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% -                     ProgramParams = " , ProgramParams ) )
		FileWrite ( hLogFile , StrCat ( "%varTimeNow% -                     StartDir      = " , StartDir ) )
		FileWrite ( hLogFile , "%varTimeNow% -                     ShowMode      = NORMAL" )
	else
		fAbort = @true
		MessageText = StrCat ( "Unable to create Program Item for HealthStar in Windows." , @crlf )
		MessageText = StrCat ( MessageText , "Please contact EHS Services for instructions." )
		MessageText2 = StrCat ( "ABORTING!" , @crlf , @crlf , MessageText )
		fDummy = xMessageBox ( MyWindowCaption , MessageText , MSGBOX_ICON_FATAL_P6C )
		if hLogFile > 0
			varTimeNow = TimeYmdHms ()
			FileWrite ( hLogFile , "%varTimeNow%" )
			FileWrite ( hLogFile , "%varTimeNow% - ABORTING: Unable to create Program Item for HealthStar in Windows." )
			FileWrite ( hLogFile , StrCat ( "%varTimeNow% -           Required Settings: LinkName      = " , LinkName ) )
			FileWrite ( hLogFile , StrCat ( "%varTimeNow% -                              Target        = " , Target ) )
			FileWrite ( hLogFile , StrCat ( "%varTimeNow% -                              ProgramParams = " , ProgramParams ) )
			FileWrite ( hLogFile , StrCat ( "%varTimeNow% -                              StartDir      = " , StartDir ) )
			FileWrite ( hLogFile , "%varTimeNow% -                              ShowMode      = NORMAL" )
			FileWrite ( hLogFile , "%varTimeNow% - If this problem persists, please send this file to EHS SERVICES." )
			FileWrite ( hLogFile , "%varTimeNow%" )
		endif
		goto MainEnd
	endif

	varTimeNow = TimeYmdHms ()
	FileWrite ( hLogFile , "%varTimeNow%" )
	FileWrite ( hLogFile , "%varTimeNow% - This workstation is ready to run HealthStar." )
	goto MainEnd
	
:wberrorhandler

	fAbort = @true
	if IsDefined ( hLogFile )
		if hLogFile > 0
			varTimeNow = TimeYmdHms ()
			MessageText = StrCat ( "%varTimeNow% - Program error occurred at line " , wberrorhandlerline )
			FileWrite ( hLogFile , MessageText )
		endif
	endif
	goto MainEnd

; New IntControl:
;
;    IntControl(79, p1, p2, p3, 0)
;      Causes a user-defined error.
;
;        P1 = severity, which can be one of the following:
;
;          -1  minor error
;          -2  moderate error
;          -3  severe error
;
;        P2 = error code, which must be a number between 7000 and 7999.
;
;        P3 = error message, which is a string describing the error.
;
;      Returns 1.

:MainEnd

	; Report completion using a message box with an Information icon unless running silently.

	if IsDefined ( hLogFile )
		if hLogFile > 0
			varTimeNow = TimeYmdHms ()
			MessageText = StrCat ( varTimeNow , @crlf , "%varTimeNow% - HStarWSConfig version 1.0 - End" , @crlf )
			FileWrite ( hLogFile , MessageText )
			FileClose ( hLogFile )
			if fAbort == @true || fWarning == @true
				fResult = RunShell ( "NOTEPAD.EXE" , LogFileName , ProgramPath , @normal , @nowait )
			endif
		endif
	endif
	if fAbort == @false && fWarning == @false
		MessageText = "This workstation is configured to run HealthStar."
		MessageText2 = StrCat ( "SUCCESS!" , @crlf , @crlf , MessageText )
		fDummy = xMessageBox ( MyWindowCaption , MessageText , MSGBOX_ICON_INFO_P6C )
	endif

    ; This is the common exit point for the mainline routine.

    exit


; +-------------------------------------------------------------------+
; |                                                                   |
; | This label is a reserved word in WIL. Its presence creates an     |
; | event handler. The program transfers here whenever a CANCEL event |
; | occurs. This usually means that the user clicked the Cancel       |
; | button on a message box. The MSGBOX_ICON_INFO_P6C puts an         |
; | Information icon and an OK button in the message box.             |
; |                                                                   |
; +-------------------------------------------------------------------+

:cancel

    fResult = xMessageBox ( MyWindowCaption , StrCat ( CopyrightNotice , "You cancelled the program. Bye-bye!" ) , MSGBOX_ICON_INFO_P6C )
    exit

Article ID:   W15507
File Created: 2003:05:13:11:28:26
Last Updated: 2003:05:13:11:28:26