Configuring Computer Startup Options

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

Administrators can control both the default operating system loaded by a computer and the amount of time that users are given to choose an alternate operating system when the computer starts. This allows administrators to:

  • Specify the default operating system on computers that have multiple operating systems installed.
  • Minimize (or maximize) the amount of time it takes for a computer to start.

    If the operating system wait time is set to 0 seconds, the computer automatically loads the default operating system without giving the user an opportunity to choose an alternate system. This can help prevent users from choosing a valid but typically inappropriate operating system such as the Windows 2000 Recovery Console. It also helps the computer start faster because the computer does not have to wait for 30 seconds before it begins to load the operating system.

The selection of the operating system to be loaded when a computer starts is based on the information stored in the Boot.ini file. The Boot.ini file includes two sections:

  • Boot loader. Specifies the default operating system and the number of seconds NTLDR will wait before loading the default system.

    On a typical Windows-based computer, the Boot loader section looks similar to the following:

    [boot loader] timeout=30 default=multi(0)disk(0)rdisk(0)partition(1)\WINNT 
  • Operating systems. Specifies the operating systems that can be loaded.

    On a server running Windows 2000, the Operating systems section might look similar to the following:

    [operating systems] multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft Windows 2000 Server" /fastdetect 

The Win32_ComputerSystem class allows you to programmatically configure the time-out value or the default operating system by setting the properties shown in Table 8.17.

Table 8.17   Win32_ComputerSystem Properties for Configuring Startup Options

PropertyDescription
SystemStartupDelaySpecifies the number of seconds to wait before NTLDR loads the default operating system.
SystemStartupSettingSpecifies the index value of the operating system to be set as the default. The first operating system listed is item 0, with additional operating systems numbered consecutively.

For example, in the following Boot.ini, there are two operating systems: Microsoft Windows XP Professional (with the index value 0), and Microsoft Windows 2000 Professional (with the index value 1).

[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional"/fastdetect
C:\WINNT="Microsoft Windows 2000 Professional"

If you specify an incorrect value (for example, if you specify index 4 when only two operating systems are included), the script will fail with an out-of-range error.

The relationship between the Win32_ComputerSystem properties and the Windows graphical user interface are shown in Figure 8.4.

Figure 8.4   Startup Options and the Startup and Recovery Page

Startup Options and the Startup and Recovery Page

Note

  • You cannot use WMI to add or remove items to or from the Operating Systems portion of Boot.ini. This must be done by directly editing Boot.ini.

Scripting Steps

Listing 8.19 contains a script that configures the system startup delay on a computer. To carry out this task, the script must perform the following steps:

  1. Create a variable to specify the computer name.
  2. Use a GetObject call to connect to the WMI namespace root\cimv2, and set the impersonation level to "impersonate."
  3. Use the ExecQuery method to query the Win32_ComputerSystem class.
  4. For each computer in the collection, set the SystemStartupDelay to 10 seconds.
  5. Use the Put_ method to apply the changes.

Listing 8.19   Configuring the System Startup Delay

1 2 3 4 5 6 7 8 9 
strComputer = "." Set objWMIService = GetObject("winmgmts:" _     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colStartupCommands = objWMIService.ExecQuery _     ("SELECT * FROM Win32_ComputerSystem") For Each objStartupCommand in colStartupCommands     objStartupCommand.SystemStartupDelay = 10     objStartupCommand.Put_ Next

After running this script, the Boot.ini will look similar to the following:

[boot loader] timeout=10 default=multi(0)disk(0)rdisk(0)partition(1)\WINNT 

send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net