Contains information that describes a Windows unattended Setup answer file. The answer file is typically called Unattend.xml. Namespace: Microsoft.ComponentStudio.ComponentPlatformInterface
Assembly: Microsoft.ComponentStudio.ComponentPlatformInterface (in microsoft.componentstudio.componentplatforminterface.dll)

Usage

Visual Basic
Dim answerFile1 As AnswerFile

Syntax

Visual Basic
Public Class AnswerFile
		Inherits ObjectBase
		Implements IDocument, IPropertyChange
C#
public class AnswerFile : ObjectBase, IDocument, IPropertyChange
C++
public ref class AnswerFile : ObjectBase, IDocument, IPropertyChange
J#
public class AnswerFile extends ObjectBase implements IDocument, IPropertyChange
JScript
public class AnswerFile extends ObjectBase implements IDocument, , IPropertyChange

Example

In this example, you open an offline image on your hard drive and open an answer file called MyUnattend.xml from a specified path. Next, you find the IE component in the offline image, create an override setting for the home page, and then save the answer file under a new name, My Unattend1.xml. Finally, you display several answer file properties.

noteNote:
To run this example, you must change the value of the variable wimPath to the path name that contains the .wim file on your machine. You must also change the value of the variable ansFile to the name of an existing answer file on your machine.
// AnswerFile.cs

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.ComponentStudio.ComponentPlatformInterface;

namespace CpiExample
{
	class Program
	{
		static void Main(string[] args)
		{
			string wimPath = @"C:\myWorkingFolder";
			string wimFile = wimPath + @"\install.wim";
			string ansFile = wimPath + @"\MyUnattend.xml";

			// Create a Cpi instance:
			Cpi n = Cpi.Instance;

			// Check if the catalog file is created:
			WimInfo wimInfo = n.OpenWim(wimFile);
			wimInfo.Images[0].CreateCatalog();

			// Open the offline image:
			OfflineImage img = n.OpenOfflineImage(wimInfo.Images[0]);
			Console.WriteLine("The image file: {0}", img.ToString());

			// Get the answer file:
			AnswerFile an = n.OpenAnswerFile(ansFile);
			Console.WriteLine("The answer file: {0}", an.ToString());

			// Get the hash code:
			System.Console.WriteLine("The hash code: {0}",
			 n.GetHashCode());

			// Find the IE component in the offline image:
			Identity id = img.FindComponentIdentity(
				"Microsoft-Windows-IE-InternetExplorer");

			// Create a setting override for Home_Page:
			AnswerFileSettingOverride homePage =
			 an.SettingOverrides.Create(id, "Home_Page",
			 ConfigurationPass.specialize,
			 CreateOptions.ReturnExisting);

			// Change the Home_Page value:
			homePage.Value = "www.microsoft.com";
			System.Console.WriteLine("New home page: {0}",
				homePage.Value);

			// Save the file:
			an.SaveAs(wimPath+@"\MyUnattend.xml");

			// Print some properties:
			Console.WriteLine("validation succeeded: {0}",
				an.Validate().Succeeded);
			Console.WriteLine("App. title: {0}",
				an.ApplicationTitle);
			Console.WriteLine("Document state: {0}",
				an.DocumentState);
			Console.WriteLine("Is source read-only?: {0}",
				an.SourceIsReadOnly);
			Console.WriteLine("Path: {0}", an.Path);
	}
}
}
/* Output:
The image file: Microsoft.ComponentStudio.ComponentPlatformInterface.OfflineImag
eImpl
The answer file: Microsoft.ComponentStudio.ComponentPlatformInterface.AnswerFile

The hash code: 57173219
New home page: www.microsoft.com
validation succeeded: True
App. title: MyUnattend1.xml
Document state: Loaded
Is source read-only?: False
Path: C:\myWorkingFolder\MyUnattend.xml
*/

Inheritance Hierarchy

System.Object
   Microsoft.ComponentStudio.Common.ObjectBase
    Microsoft.ComponentStudio.ComponentPlatformInterface.AnswerFile

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Vista, and Windows 2000

Target Platforms

See Also

[an error occurred while processing this directive]