Enumerating Computer Startup Options

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

The computer startup options include such key items as:

  • The default operating system to be loaded by a computer.
  • Alternate operating systems installed on a computer.
  • The time-out period during which a user can select an alternate operating system.

The Win32_ComputerSystem class can be used to enumerate the startup properties for a computer. The properties available through this class are shown in Table 8.16.

Table 8.16   Win32_ComputerSystem Properties for Enumerating Startup Options

PropertyDescription
AutomaticResetBootOptionBoolean value indicating whether the automatic restart option is enabled.
AutomaticResetCapabilityBoolean value indicating whether the computer is capable of automatic restart.
BootupStateValue indicating the current startup mode of the computer. Fail-safe boot (also called SafeBoot) bypasses the user's startup files. This property must have a value.

Values are:

  • Normal boot
  • Safe mode
  • Safe mode with network support
SystemStartupDelayTime to delay (in seconds) before starting the operating system.
SystemStartupOptionsArray containing the options for starting up the Win32® computer system. On a multiple-boot computer with both Windows XP and Windows 2000 Advanced Server installed, the SystemStartupOptions might look like this:
"\"Microsoft Windows XP Professional\"/fastdetect","\"Microsoft Windows 2000 Advanced Server\"/fastdetect"
SystemStartupSettingIndex of the default operating system, as determined by the Boot.ini file. This value is calculated so that it usually returns 0 because during startup the selected operating system is physically moved to the top of the list. (This is how the computer determines which value is the default.)

Scripting Steps

Listing 8.18 contains a script that enumerates the startup options 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. Echo the value of each startup option in the collection.

Listing 8.18   Enumerating Startup Options

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 
strComputer = "." Set objWMIService = GetObject("winmgmts:" _     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colStartupCommands = objWMIService.ExecQuery _     ("SELECT * FROM Win32_ComputerSystem") For Each objStartupCommand in colStartupCommands     Wscript.Echo "Reset Boot Enabled: " & _         objStartupCommand.AutomaticResetBootOption     Wscript.Echo "Reset Boot Possible: " & _         objStartupCommand.AutomaticResetCapability     Wscript.Echo "Boot State: " & objStartupCommand.BootupState     Wscript.Echo "Startup Delay: " & objStartupCommand.SystemStartupDelay     For Each strOption in objStartupCommand.SystemStartupOptions         Wscript.Echo "Startup Options: " & strOption     Next     Wscript.Echo "Startup Setting: " & _         objStartupCommand.SystemStartupSetting Next

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