/*----------------------------------------------------------------------------*\
 *
 *    File Name:  SETUP.RUL
 *
 *  Description:  Shows how to call the "DMI Service Provider Setup Utility
 *                For OEMs".
 *
 *
 *     Comments:  This script calls the oemsetup utility which installs the
 *                Intel DMI Service Provider on a system.
 *     		      
\*----------------------------------------------------------------------------*/

//===============================================
declare

//#include "sddialog.h"   // Include script dialog definitions.



        // Global variable declarations.
        STRING  svTarget, szAppPath,  szAppSharedDir, szAppName;

//===============================================
// Function declarations.
			prototype SetupFinish();
			prototype SetupScreen();
			prototype CallDmiSpSetupUtility( );
//===============================================
program

StartHere:
        Disable( BACKGROUND );

		// Set up the installation screen.
        SetupScreen();
		CallDmiSpSetupUtility();
   exit;
// end of main



//===============================================
// function definitions follow.
//===============================================

/*---------------------------------------------------------------------------*\
 *
 * Function:  SetupScreen
 *
 *  Purpose:  This function will set up the screen look.  This includes
 *            colors, fonts, text to be displayed, etc.
 *
 *
 *    Input:
 *
 *  Returns:
 *
 * Comments:
\*---------------------------------------------------------------------------*/

function SetupScreen()
        STRING szTitleString;
        NUMBER nvDx, nvDy, nFontSize;
	STRING szFile, szPath, szBinPath, szMifsPath;
begin
        GetExtents( nvDx, nvDy );
        Enable( FULLWINDOWMODE );
        Enable( INDVFILESTATUS );
        SetColor( BACKGROUND, BK_BLUE ); // Gradient blue background.
        SetTitle( "Example Of Using The Intel DMI Service Provider Setup Utility For OEMs", 0, BACKGROUNDCAPTION ); // Caption bar text.

        nFontSize = 12;	// Normally 22

        if(nvDx <= 800) then
            nFontSize = 14;
         endif;


        // Set font style to 22-point white Script.

        SetFont(FONT_TITLE, 0, "Script");
	szFile = SRCDIR ^ ".." ^ "disk1" ^ "DMI_SP.ISS";
	if (GetProfString ( szFile , "AskDestPath-0" , "szPath" , szPath ) < 0) then
		szPath = TARGETDISK ^ "DMI" ^ "WIN32";
	endif;
	szBinPath = szPath ^ "BIN";
	szMifsPath = szPath ^ "MIFS";
        szTitleString = "This script is using the DMI Service Provider\n" +
                        "Setup Utility For OEMs to install the Service\n" +
                        "Provider.  After completion, the following \n"   +
                        "DMI Service Provider directory structure will\n" + 
                        "be created:\n\n" +
				szBinPath + "\n" +
				szMifsPath + "\n";

        SetTitle(szTitleString , nFontSize, RGB(255, 255, 255));
        Delay(1);


        Enable( BACKGROUND );

end;



/*---------------------------------------------------------------------------*\
 *
 * Function:  CallDmiSpSetupUtility
 *
 *  Purpose:  This function shows how an InstallShield* script can call the
 *            Intel DMI Service Provider Setup Utility.  This function uses
 *            the IntallShield DoINstall() function to launch the DMI Service
 *            Provider setup utility.  The function copies the DMI_SP.LOG
 *            file to the SUPPORTDIR directory and later examines its
 *            content to see whether the DMI Service Provider installation
 *            was successful.  The DMI_SP.LOG is generated by the DMI_SP
 *            Setup Program and will contain a value of 0 for the ResultCode
 *            variable if the installation of the Service Provider was 
 *            successful.
 *            
 *
 *    Input: None
 *
 *  Returns: TRUE if installation was successful.  FALSE, otherwise.
 *
 * Comments:  The function assumes that the DMI_SP subdirectoy is in the 
 *            root directory of the installation CD.  If the DMI_SP 
 *            subdirectory is under a different directory, replace the "\\" 
 *            path with the path of the parent directory of the 
 *            DMI_SP subdirectory.
\*---------------------------------------------------------------------------*/
function CallDmiSpSetupUtility()
	    STRING szInstFile, szRespFile, szLogFile, szCmdLine, svResult;
		LONG rc;
		BOOL bInstall;
begin

	bInstall = FALSE; // assume installation failed.

	// For this example, SRCDIR will be \WIN32\OEMSETUP\example or \WIN32\OEMSETUP\disk1.
	szInstFile =  SRCDIR ^ ".." ^ "disk1" ^ "DMI_SP.INS";

	szRespFile = SRCDIR ^ ".." ^ "disk1" ^ "DMI_SP.ISS";
	LongPathToQuote (szRespFile, TRUE);
	szLogFile = SUPPORTDIR ^ "DMI_SP.LOG";
	LongPathToQuote (szLogFile, TRUE);
	szCmdLine = " -s  -f1" 	+ szRespFile + " -f2"+ szLogFile;

	// do the silent installation
	rc = DoInstall(szInstFile, szCmdLine,WAIT);

	// Look for success or failure in installation
	GetProfString(szLogFile, "ResponseResult", "ResultCode", svResult);
	if (svResult = "0") then 
		bInstall = TRUE;
		MessageBox("Installation Complete!", INFORMATION);

	else
		MessageBox("Could not install the DMI Service Provider!\n\n" +
				"ResultCode=" + svResult, SEVERE);
		exit;
	endif;

	return (bInstall);
end;


//#include "sddialog.rul"   // Include script dialog definitions.
