본문 바로가기

Programming/VC++

[VC++] InstallShield - 보이지 않게 인스톨하는 방법

출처 카페 > C++ 노트 / sobahoko
원본 http://cafe.naver.com/cnote/89

인스톨프로그램을 만들때 InstallShield를 많이 쓴다.


그런데, InstallShield에는 보이지 않게 인스톨하는 silent install 옵션이 있다.


그 방법은 다음과 같다.


InstallShield로 정상적인 setup 프로그램을 만들고 dos commend line에서
다음과 같이 입력하고 프로그램을 인스톨한다.


setup /r


그러면 사용자가 setup과정에 입력한 사항들이 setup.iss라는 파일에 기록된다.

setup.iss 파일은 Windows 폴더에 생긴다.


안보이게 인스톨하려면,
setup.iss를 setup.exe 파일과 같은 디렉토리에 넣어주고,
command line 에 다음과 같이 입력한다.


setup /s


Windows 환경에서는 바로가기를 만들고
등록정보에서 /s 옵션을 주면 된다.


다음은 InstallShield 도움말 중에서 silent install부분이다.
읽지 않기를 바란다. 머리 아프다.




------------------------------------------------------------------------------

InstallShield Silent


InstallShield Silent allows automated electronic software distribution, also known as silent setup. With InstallShield Silent, there is no need for a user to monitor the setup and provide input via dialog boxes. An InstallShield Silent setup runs on its own, without any end-user intervention.
You must launch InstallShield Silent with the Setup.exe -s command line parameter. To comply with Windows 95 logo requirements, a silent setup must create a response file in which the default setup options are selected.

You can run your setup with the Setup.exe -r parameter to select setup options and automatically record the InstallShield Silent response file, or you can create your own from scratch. To view a real world example of a response file, refer to the Setup.iss file located on InstallShield installation's Disk1. In addition, a description of the response file format is provided in Create the response file.

Steps to create a silent setup

Follow these steps to create a silent setup:

1. Create the setup
2. Create the response file
3. Play back the silent setup
4. Check for errors


<> Feedback
--------------------------------------
Syntax

Setup [switches]

Switches

/s or -s

Runs InstallShield Silent to execute a silent setup .

---------------------------------------
Create the setup

Create the setup program in a typical manner, either by modifying an InstallShield template project or by creating a setup with the Project Wizard. Compile and test the script in the normal (non-silent) manner.
You can easily modify your setup script logic to include flow control based on whether or not InstallShield Silent is running. InstallShield provides a system variable called MODE which contains the setup's current mode. The MODE variable will contain one of the following constants:

 SILENTMODE indicates the setup is running in silent mode.

 NORMALMODE indicates the setup is running in normal mode.

You can use the MODE system variable in if statements to control the flow of your script based on mode, as shown below.

   if (MODE = SILENTMODE) then
      // Perform silent setup actions and events.  .  . ;
   else
      // Perform normal setup actions and events. . . ;

   endif;

All InstallShield built-in and Sd dialog boxes automatically handle the values stored in the InstallShield Silent response file (.iss file). If you are creating custom dialog boxes, you will need to call SilentReadData to handle the dialog box's return values in silent mode.
After you have created or modified the setup program, the next step in creating a silent setup is to create the response file.

----------------------------------
Create the response file

A normal (non-silent) setup receives the necessary input from the user in the form of responses to dialog boxes. However, a silent setup does not prompt the user for input. A silent setup must get its user input from a different source. That source is the InstallShield Silent response file (.iss file).
A response file contains information similar to that which an end user would enter as responses to dialog boxes when running a normal setup. InstallShield Silent reads the necessary input from the response file at run time.

The format of response files resembles that of an .ini file, but response files have .iss extensions. A response file is a plain text file consisting of sections containing data entries.

There are two ways in which you can create an InstallShield Silent response file:     1. you can run the setup and have InstallShield record and create the response file for you, or
  2. you can write the response file from scratch.

Recording a response file

You have the option of letting InstallShield create the response file for you. Simply run your setup with the Setup.exe -r command line parameter. InstallShield will record all your setup choices in Setup.iss and place the file in the Windows folder.
All InstallShield built-in and Sd dialog box functions are designed to write values into the Setup.iss file when InstallShield runs in record mode (Setup -r). If you are creating custom dialog boxes, you will need to call SdMakeName and SilentWriteData to add sections and dialog box data to the response file when setup runs in record mode. Refer to the Sd dialogs' source code in the <InstallShield location>\Include folder for examples of using these functions to write to Setup.iss. Please read the following section for more information about what data to add to Setup.iss when calling SdMakeName and SilentWriteData.

Manually creating a response file

You can also create the response file completely by hand. As mentioned, the Setup.iss file is similar to an .ini file. The sections of an InstallShield response file must be in the following order:

1. Silent Header Section
2. Application Header Section
3. Dialog Sequence Section
4. Dialog Data Sections (one per dialog box)

Section names are contained in square brackets, as in [InstallShield Silent].
Data entries follow their section names, and consist of <name=value> pairs, as in Dlg0=Welcome-0.
Follow these steps to create the response file:

1. Create a text file named Setup.iss using any text editor.
2. Enter the silent header into Setup.iss.
3. Enter the application header into Setup.iss.
4. Enter the dialog box sequence into Setup.iss.
5. Enter the dialog box data into Setup.iss.
6. Save and close Setup.iss.

A sample response file is included to help familiarize you with the format.

-------------------------------------------
Play back the silent setup

After you have created the setup and the response file, you are ready to run the setup in silent mode using InstallShield Silent. When running an setup in silent mode, be aware that no messages are displayed. Instead, a log file named Setup.log captures setup information, including whether the setup was successful. You can review the log file and determine the result of the setup.
To launch InstallShield Silent, run Setup.exe with the -s option.

InstallShield also provides the -f1 and -f2 switches so you can specify the name and location of the response file and the location of the log file. See the examples under Setup usage examples.
To verify if a silent setup succeeded, look at the ResultCode value in the [ResponseResult] section of Setup.log. InstallShield writes an appropriate return value after the ResultCode keyname.

---------------------------------------------
Check for errors - Setup.log

Setup.log is the default name for the silent setup log file, and its default location is Disk1 (in the same folder as Setup.ins). You can specify a different name and location for Setup.log using the -f1 and -f2 switches with Setup.exe .
The Setup.log file contains three sections. The first section, [InstallShield Silent], identifies the version of InstallShield Silent used in the silent setup. It also identifies the file as a log file.
The second section, [Application], identifies the installed application's name and version, and the company name.

The third section, [ResponseResult], contains the result code indicating whether or not the silent setup succeeded. An integer value is assigned to the ResultCode keyname in the [ResponseResult] section. InstallShield places one of the following return values after the ResultCode keyname:

  0 Success.
 -1 General error.
 -2 Invalid mode.
 -3 Required data not found in the Setup.iss file.
 -4 Not enough memory available.
 -5 File does not exist.
 -6 Cannot write to the response file.
 -7 Unable to write to the log file.
 -8 Invalid path to the InstallShield Silent response file.
 -9 Not a valid list type (string or number).
 -10 Data type is invalid.
 -11 Unknown error during setup.
 -12 Dialog boxes are out of order.
 -51 Cannot create the specified folder.
 -52 Cannot access the specified file or folder.
 -53 Invalid option selected.

The Setup.log file for a successful silent setup of InstallShield is shown below.

[InstallShield Silent]
Version=v5.00.000
File=Log File

[Application]
Name=InstallShield5
Version=5.00.000
Company=InstallShield

[ResponseResult]

ResultCode=0

---------------------------------------------