Windows 7 safe mode script

  • Anyone have a solutions for Windows 7? I know in Vista people were using "bcdedit /set safeboot network", but on the 6 windows 7 machines i attempted this command (even manually with UAC off and Administrative command line) it says these options for /set are not valid. Only way i can see to get Windows 7 into safemode currently is by using "msconfig" but no command line options are available.

    Legacy Forum Name: Windows 7 safe mode script,
    Legacy Posted By Username: djennings
  • I can see the option is there just cant figure out the command. If you run

    bcdedit /? types osloader

    you can see it has the option for

    Boot
    ====
    BOOTLOG (bool) Enables the system initialization log.
    BOOTSTATUSPOLICY Can be DisplayAllFailures, IgnoreAllFailures,
    IgnoreShutdownFailures or IgnoreBootFailures.
    LASTKNOWNGOOD (bool) Enables boot to last known good configuration.
    NOCRASHAUTOREBOOT (bool) Disables automatic restart on crash.
    RESUMEOBJECT (id) Defines the identifier of the resume object that
    is associated with this operating system object.
    SAFEBOOT Can be Minimal, Network or DsRepair
    SAFEBOOTALTERNATESHELL (bool) Uses the alternate shell when booted into
    Safe mode.
    STAMPDISKS (bool) Enables stamping of RAW disks during Windows PE.
    SOS (bool) Displays additional boot information.
    WINPE (bool) Enables the computer to boot to Windows PE.


    Just can't figure out the command string

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: djennings
  • Hi Daryl,

    Just tested the bcdedit on a VM Win7 ult. x64

    Opened a command prompt as administrator.
    with the command: bcdedit /set {current} safeboot network
    it booted in safemode

    the command: bcdedit /deletevalue {current} safeboot
    flipped the machine back to normal mode

    haven't put it in a script yet, just testedit to know if it would work

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Martijn Frickel
  • The following two scripts will work on the following Operating Systems:

    • ·         Windows XP
    • ·         Windows XP 64-Bit
    • ·         Windows Vista
    • ·         Windows Vista 64-Bit
    • ·         Windows 7
    • ·         Windows 7 64-Bit
    • ·         Windows Server 2003
    • ·         Windows Server 2003 64-Bit
    • ·         Windows Server 2008
    • ·         Windows Server 2008 64-Bit
    • ·         Windows Server 2003 R2
    • ·         Windows Server 2003 64-Bit R2
    • ·         Windows Server 2008 R2
    • ·         Windows Server 2008 64-Bit R2


    Reboot to Safe Mode - Script to be imported as XML file

    <?xml version="1.0" encoding="utf-8"?>
    <ScriptExport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.kaseya.com/vsa/2008/12/Scripting">
      <Procedure name="Reboot to Safe Mode" treePres="3">
        <Body description="Can only VNC to machine when in safe mode RDP will not work.&#xD;&#xA;Be sure to use the 'Reboot to Normal Mode' script to come out of Safe Mode.&#xD;&#xA;">
          <If description="Can only VNC to machine when in safe mode RDP will not work.&#xD;&#xA;Be sure to use the 'Reboot to Normal Mode' script to come out of Safe Mode.&#xD;&#xA;">
            <Condition name="True" />
            <Then>
              <Statement description="" name="GetVariable" continueOnFail="false">
                <Parameter xsi:type="EnumParameter" name="VariableType" value="AgentTempDirectory" />
                <Parameter xsi:type="StringParameter" name="SourceContent" value="" />
                <Parameter xsi:type="StringParameter" name="VariableName" value="temp" />
              </Statement>
              <Statement description="" name="GetVariable" continueOnFail="false">
                <Parameter xsi:type="EnumParameter" name="VariableType" value="RegistryValue" />
                <Parameter xsi:type="StringParameter" name="SourceContent" value="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AgentMon.Exe\Path" />
                <Parameter xsi:type="StringParameter" name="VariableName" value="installpath" />
              </Statement>
              <Statement description="" name="WriteFile" continueOnFail="false" osType="XP">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\SafeModeBootAdjust.vbs" />
                <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\SafeModeBootAdjust.vbs" />
              </Statement>
              <Statement description="" name="WriteFile" continueOnFail="false" osType="XP">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\safemode_reboot_kausrtsk.reg" />
                <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\safemode_reboot_kausrtsk.reg" />
              </Statement>
              <Statement description="" name="WriteFile" continueOnFail="false" osType="2003">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\SafeModeBootAdjust.vbs" />
                <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\SafeModeBootAdjust.vbs" />
              </Statement>
              <Statement description="" name="WriteFile" continueOnFail="false" osType="2003">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\safemode_reboot_kausrtsk.reg" />
                <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\safemode_reboot_kausrtsk.reg" />
              </Statement>
              <Statement description="" name="WriteFile" continueOnFail="false" osType="2000">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\safemode_reboot_kausrtskwin2k.reg" />
                <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\safemode_reboot_kausrtskwin2k.reg" />
              </Statement>
              <Statement description="" name="WriteFile" continueOnFail="false" osType="XP">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\instsrv.exe" />
                <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\instsrv.exe" />
              </Statement>
              <Statement description="" name="WriteFile" continueOnFail="false" osType="2003">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\instsrv.exe" />
                <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\instsrv.exe" />
              </Statement>
              <Statement description="" name="PauseScript" continueOnFail="false" osType="XP">
                <Parameter xsi:type="IntegerParameter" name="Seconds" value="30" />
              </Statement>
              <Statement description="" name="PauseScript" continueOnFail="false" osType="2000">
                <Parameter xsi:type="IntegerParameter" name="Seconds" value="30" />
              </Statement>
              <Statement description="" name="PauseScript" continueOnFail="false" osType="2003">
                <Parameter xsi:type="IntegerParameter" name="Seconds" value="30" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="XP">
                <Parameter xsi:type="StringParameter" name="Command" value="regedit.exe /s &quot;#temp#\safemode_reboot_kausrtsk.reg&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="XP">
                <Parameter xsi:type="StringParameter" name="Command" value="regedit.exe /s &quot;#temp#\safemode_reboot_kausrtsk.reg&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="True" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="2003">
                <Parameter xsi:type="StringParameter" name="Command" value="regedit.exe /s &quot;#temp#\safemode_reboot_kausrtsk.reg&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="2003">
                <Parameter xsi:type="StringParameter" name="Command" value="regedit.exe /s &quot;#temp#\safemode_reboot_kausrtsk.reg&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="True" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="2000">
                <Parameter xsi:type="StringParameter" name="Command" value="regedit.exe /s &quot;#temp#\safemode_reboot_kausrtskwin2k.reg&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="2000">
                <Parameter xsi:type="StringParameter" name="Command" value="regedit.exe /s &quot;#temp#\safemode_reboot_kausrtskwin2k.reg&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="True" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="XP">
                <Parameter xsi:type="StringParameter" name="Command" value="wscript &quot;#temp#\SafeModeBootAdjust.vbs&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="XP">
                <Parameter xsi:type="StringParameter" name="Command" value="wscript &quot;#temp#\SafeModeBootAdjust.vbs&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="True" />
              </Statement>
              <Statement description="" name="DeleteFile" continueOnFail="false" osType="XP">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\safemode_reboot_kausrtsk.reg" />
              </Statement>
              <Statement description="" name="DeleteFile" continueOnFail="false" osType="XP">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#safemode_reboot_kausrtskwin2k.reg" />
              </Statement>
              <Statement description="" name="DeleteFile" continueOnFail="false" osType="XP">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\SafeModeBootAdjust.vbs" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="2003">
                <Parameter xsi:type="StringParameter" name="Command" value="wscript &quot;#temp#\SafeModeBootAdjust.vbs&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="2003">
                <Parameter xsi:type="StringParameter" name="Command" value="wscript &quot;#temp#\SafeModeBootAdjust.vbs&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="True" />
              </Statement>
              <Statement description="" name="DeleteFile" continueOnFail="false" osType="2003">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\safemode_reboot_kausrtsk.reg" />
              </Statement>
              <Statement description="" name="DeleteFile" continueOnFail="false" osType="2003">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#safemode_reboot_kausrtskwin2k.reg" />
              </Statement>
              <Statement description="" name="DeleteFile" continueOnFail="false" osType="2003">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\SafeModeBootAdjust.vbs" />
              </Statement>
              <Statement description="" name="SetRegistryValue" continueOnFail="false" osType="2008">
                <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\KaseyaAgent\" />
                <Parameter xsi:type="StringParameter" name="Value" value="Service" />
                <Parameter xsi:type="EnumParameter" name="DataType" value="String" />
              </Statement>
              <Statement description="" name="SetRegistryValue" continueOnFail="false" osType="Vista">
                <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\KaseyaAgent\" />
                <Parameter xsi:type="StringParameter" name="Value" value="Service" />
                <Parameter xsi:type="EnumParameter" name="DataType" value="String" />
              </Statement>
              <Statement description="" name="SetRegistryValue" continueOnFail="false" osType="7">
                <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\KaseyaAgent\" />
                <Parameter xsi:type="StringParameter" name="Value" value="Service" />
                <Parameter xsi:type="EnumParameter" name="DataType" value="String" />
              </Statement>
              <Statement description="" name="SetRegistryValue" continueOnFail="false" osType="Vista">
                <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\WinVNC4\" />
                <Parameter xsi:type="StringParameter" name="Value" value="Service" />
                <Parameter xsi:type="EnumParameter" name="DataType" value="String" />
              </Statement>
              <Statement description="" name="SetRegistryValue" continueOnFail="false" osType="7">
                <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\WinVNC4\" />
                <Parameter xsi:type="StringParameter" name="Value" value="Service" />
                <Parameter xsi:type="EnumParameter" name="DataType" value="String" />
              </Statement>
              <Statement description="" name="SetRegistryValue" continueOnFail="false" osType="2008">
                <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\WinVNC4\" />
                <Parameter xsi:type="StringParameter" name="Value" value="Service" />
                <Parameter xsi:type="EnumParameter" name="DataType" value="String" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="Vista">
                <Parameter xsi:type="StringParameter" name="Command" value="bcdedit /set {current} safeboot network" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="Vista">
                <Parameter xsi:type="StringParameter" name="Command" value="bcdedit /set {current} safeboot network" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="True" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="2008">
                <Parameter xsi:type="StringParameter" name="Command" value="bcdedit /set {current} safeboot network" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="2008">
                <Parameter xsi:type="StringParameter" name="Command" value="bcdedit /set {current} safeboot network" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="True" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="7">
                <Parameter xsi:type="StringParameter" name="Command" value="bcdedit /set {current} safeboot network" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="7">
                <Parameter xsi:type="StringParameter" name="Command" value="bcdedit /set {current} safeboot network" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="True" />
              </Statement>
              <Statement description="" name="Reboot" continueOnFail="false" />
            </Then>
          </If>
        </Body>
      </Procedure>
    </ScriptExport>


    Reboot to Normal Mode - Script to be imported as XML file

    <?xml version="1.0" encoding="utf-8"?>
    <ScriptExport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.kaseya.com/vsa/2008/12/Scripting">
      <Procedure name="Reboot to Normal Mode" treePres="3">
        <Body description="&#xD;&#xA;">
          <If description="&#xD;&#xA;">
            <Condition name="True" />
            <Then>
              <Statement description="" name="GetVariable" continueOnFail="false">
                <Parameter xsi:type="EnumParameter" name="VariableType" value="AgentTempDirectory" />
                <Parameter xsi:type="StringParameter" name="SourceContent" value="" />
                <Parameter xsi:type="StringParameter" name="VariableName" value="temp" />
              </Statement>
              <Statement description="" name="WriteFile" continueOnFail="false" osType="XP">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\SafeModeNormalAdjust.vbs" />
                <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\SafeModeNormalAdjust.vbs" />
              </Statement>
              <Statement description="" name="PauseScript" continueOnFail="false" osType="XP">
                <Parameter xsi:type="IntegerParameter" name="Seconds" value="30" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="XP">
                <Parameter xsi:type="StringParameter" name="Command" value="wscript &quot;#temp#\SafeModeNormalAdjust.vbs&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="XP">
                <Parameter xsi:type="StringParameter" name="Command" value="wscript &quot;#temp#\SafeModeNormalAdjust.vbs&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="True" />
              </Statement>
              <Statement description="" name="DeleteFile" continueOnFail="false" osType="XP">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\SafeModeNormalAdjust.vbs" />
              </Statement>
              <Statement description="" name="WriteFile" continueOnFail="false" osType="2003">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\SafeModeNormalAdjust.vbs" />
                <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\SafeModeNormalAdjust.vbs" />
              </Statement>
              <Statement description="" name="PauseScript" continueOnFail="false" osType="2003">
                <Parameter xsi:type="IntegerParameter" name="Seconds" value="30" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="2003">
                <Parameter xsi:type="StringParameter" name="Command" value="wscript &quot;#temp#\SafeModeNormalAdjust.vbs&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="2003">
                <Parameter xsi:type="StringParameter" name="Command" value="wscript &quot;#temp#\SafeModeNormalAdjust.vbs&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="True" />
              </Statement>
              <Statement description="" name="DeleteFile" continueOnFail="false" osType="2003">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\SafeModeNormalAdjust.vbs" />
              </Statement>
              <Statement description="" name="WriteFile" continueOnFail="false" osType="2000">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\SafeModeNormalAdjust.vbs" />
                <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\SafeModeNormalAdjust.vbs" />
              </Statement>
              <Statement description="" name="PauseScript" continueOnFail="false" osType="2000">
                <Parameter xsi:type="IntegerParameter" name="Seconds" value="30" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="2000">
                <Parameter xsi:type="StringParameter" name="Command" value="wscript &quot;#temp#\SafeModeNormalAdjust.vbs&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="2000">
                <Parameter xsi:type="StringParameter" name="Command" value="wscript &quot;#temp#\SafeModeNormalAdjust.vbs&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="True" />
              </Statement>
              <Statement description="" name="DeleteFile" continueOnFail="false" osType="2000">
                <Parameter xsi:type="StringParameter" name="Path" value="#temp#\SafeModeNormalAdjust.vbs" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="Vista">
                <Parameter xsi:type="StringParameter" name="Command" value="bcdedit /deletevalue {current} safeboot" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="Vista">
                <Parameter xsi:type="StringParameter" name="Command" value="bcdedit /deletevalue {current} safeboot" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="True" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="7">
                <Parameter xsi:type="StringParameter" name="Command" value="bcdedit /deletevalue {current} safeboot" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="7">
                <Parameter xsi:type="StringParameter" name="Command" value="bcdedit /deletevalue {current} safeboot" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="True" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="2008">
                <Parameter xsi:type="StringParameter" name="Command" value="bcdedit /deletevalue {current} safeboot" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
              </Statement>
              <Statement description="" name="ExecuteShellCommand" continueOnFail="true" osType="2008">
                <Parameter xsi:type="StringParameter" name="Command" value="bcdedit /deletevalue {current} safeboot" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="True" />
              </Statement>
              <Statement description="" name="Reboot" continueOnFail="false" />
            </Then>
          </If>
        </Body>
      </Procedure>
    </ScriptExport>



    You will need to upload the following files to your VSASharedFiles:
    • safemode_reboot_kausrtsk.reg
    • safemode_reboot_kausrtskwin2k.reg
    • SafeModeBootAdjust.vbs
    • SafeModeNormalAdjust.vbs


    Contents of - safemode_reboot_kausrtsk.reg

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\KaUsrTsk]
    @="Service"

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\KaseyaAgent]
    @="Service"

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\WinVNC4]
    @="Service"



    Contents of - safemode_reboot_kausrtskwin2k.reg

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\WinSock]
    @="Service"

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Winsock2]
    @="Service"

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\WS2IFSL]
    @="Service"



    Contents of - SafeModeBootAdjust.vbs

    '==========================================================================
    '
    ' NAME: SafeModeBootAdjust.vbs
    '
    ' AUTHOR: Nicholas M. Zeigler, PMV Technologies
    ' COPYRIGHT (c) 2006 All Rights Reserved
    ' DATE  : 9/6/2006
    '
    '==========================================================================

    Const ForReading = 1, ForWriting = 2, ForAppending = 8

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set WshShell = CreateObject("Wscript.Shell")

    'Find the System Drive where Boot.Ini will be found
    Set env = WshShell.environment("Process")
    SysDrive = env.Item("SystemDrive")
    BootIni =  SysDrive & "\boot.ini"

    'Remove file ReadOnly, Hidden, System File state   
    If objFSO.FileExists(BootIni) Then
        WshShell.Run("cmd /c attrib.exe " & BootIni & " -r -h -s")
    End If

    'Make a backup copy of the boot.ini file
    Dim objFSO, objFileCopy
    Set objFileCopy = objFSO.GetFile(SysDrive & "\boot.ini")
    objFileCopy.Copy (SysDrive & "\bootbackup.ini")
    WScript.Sleep 1000

    Set oTextStream = objFSO.OpenTextFile(SysDrive & "\bootbackup.ini")
    'make an array from the data file
    BootIniTxt = Split(oTextStream.ReadAll, vbNewLine)

    'OK, Now find where the Windows install is located and add the safe mode line.
    For Each line In BootIniTxt
        If InStr(1,line,"timeout") Then
            timeArray = Split(line,"=")
            timeOut = timeArray(0) & "= " & WaitTime
            line = timeOut
        End If
           
        If InStr(1,line,"Microsoft Windows") Then
            lineArray = Split(line,"=")
            SafeModeLine = lineArray(0) & "=" & Chr(34) & "Safe Mode" & Chr(34) _
            & " /fastdetect /safeboot:network /sos /bootlog /noguiboot"
            line = SafeModeLine
        End If
       
        If InStr(1,line,"Windows Server") Then
            lineArray = Split(line,"=")
            SafeModeLine = lineArray(0) & "=" & Chr(34) & "Safe Mode" & Chr(34) _
            & " /fastdetect /safeboot:network /sos /bootlog /noguiboot"
            line = SafeModeLine
        End If
       
        Report = Report & line & vbCrLf
    Next

    'Open Boot.ini for writing and write new text
    Set ts = objFSO.OpenTextFile (BootIni, ForWriting)
    ts.write Report
    ts.close
    WScript.Sleep 300
    LockFile

    Sub LockFile
        'Return file to previous ReadOnly, Hidden, System File state   
        If objFSO.FileExists(BootIni) Then
            WshShell.Run("cmd /c attrib.exe " & BootIni & " +r +h +s")
        End If
    End Sub



    Contents of - SafeModeNormalAdjust.vbs

    '==========================================================================
    '
    ' NAME: SafeModeNormalAdjust.vbs
    '
    ' AUTHOR: Nicholas M. Zeigler, PMV Technologies
    ' COPYRIGHT (c) 2006 All Rights Reserved
    ' DATE  : 9/7/2006
    '
    '==========================================================================

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set WshShell = CreateObject("Wscript.Shell")

    'Find the System Drive where Boot.Ini will be found
    Set env = WshShell.environment("Process")
    SysDrive = env.Item("SystemDrive")
    BootIni =  SysDrive & "\boot.ini"

    'Remove file ReadOnly, Hidden, System File state   
    If objFSO.FileExists(BootIni) Then
        WshShell.Run("cmd /c attrib.exe " & BootIni & " -r -h -s")
    End If

    'Delete temp boot.ini and rename original boot.ini
    WScript.Sleep 1000
    objFSO.DeleteFile BootIni
    objFSO.MoveFile SysDrive & "\bootbackup.ini" , BootIni


    'Return file to previous ReadOnly, Hidden, System File state   
    If objFSO.FileExists(BootIni) Then
        WshShell.Run("cmd /c attrib.exe " & BootIni & " +r +h +s")
    End If



    [edited by: markavillareal at 8:25 AM (GMT -8) on 12-22-2010] Updated formatting.
  • I've uploaded a zip containing all the files:

    community.kaseya.com/.../download.aspx

  • Mark there is no boot.ini in Windows 7, so that vbs script will not work.  Thanks for the effort