Assembly: Microsoft.ComponentStudio.ComponentPlatformInterface (in microsoft.componentstudio.componentplatforminterface.dll)
Usage
Visual Basic |
---|
Dim runOnceCommand1 As RunOnceCommand |
Syntax
Visual Basic |
---|
Public Class RunOnceCommand Inherits AnswerFileSettingOverride |
C# |
---|
public class RunOnceCommand : AnswerFileSettingOverride |
C++ |
---|
public ref class RunOnceCommand : AnswerFileSettingOverride |
J# |
---|
public class RunOnceCommand extends AnswerFileSettingOverride |
JScript |
---|
public class RunOnceCommand extends AnswerFileSettingOverride |
Example
This example demonstrates how to create a run-once command and add it to an answer file.
Note: |
---|
To run this example, you must change the value of the constant
wimFile to match the path that contains the .wim file
on your machine. You also must change the value of the variable
ansFile to match the name of an answer file on your
machine. |
// RunOnceCommand.cs using System; using System.Collections.Generic; using System.Text; using Microsoft.ComponentStudio.ComponentPlatformInterface; namespace MyROCNameSapce { public class MyRunOnceCommand { private const string ansFile = @"C:\myWorkingFolder\MyNewUnattend.xml"; private const string wimFile = @"C:\myWorkingFolder\install.wim"; static void Main() { CreateRunOnceCommand(); Console.WriteLine( "The RunOnceCommand has been added to the answer file"); } public static void CreateRunOnceCommand() { RunOnceCommand command1; // 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 image = n.OpenOfflineImage(wimInfo.Images[0]); // Create an answer file: AnswerFile unattend = Cpi.Instance.CreateAnswerFile(image); // Add a run-once command: RunOnceCommandCollection runOnceCollection = unattend.GetRunOnceCommands( ConfigurationPass.oobeSystem); command1 = runOnceCollection.Create(1, CreateOptions.FailIfExists); command1.CommandLine = "SomeName.exe"; command1.Description = "Run a command"; // Save the answer file: unattend.SaveAs(ansFile); } } } /* Output: The RunOnceCommand has been added to the answer file. */ |
Inheritance Hierarchy
System.Object
Microsoft.ComponentStudio.Common.ObjectBase
Microsoft.ComponentStudio.ComponentPlatformInterface.SettingOverride
Microsoft.ComponentStudio.ComponentPlatformInterface.AnswerFileSettingOverride
Microsoft.ComponentStudio.ComponentPlatformInterface.RunOnceCommand
Microsoft.ComponentStudio.Common.ObjectBase
Microsoft.ComponentStudio.ComponentPlatformInterface.SettingOverride
Microsoft.ComponentStudio.ComponentPlatformInterface.AnswerFileSettingOverride
Microsoft.ComponentStudio.ComponentPlatformInterface.RunOnceCommand
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.