Kaseya Community

Reboot to Safe Mode Script

  • Hi folks,

    I know lots of these have existed

    Does anybody have a Reboot to Safe Mode script that works with Vista / Windows 7 / XP or variations of the scripts.

    Thanks


    Michael

  • For XP, you'd probably have to add and remove "/safeboot:network" from the boot.ini file in the correct place.  Kinda a pain.

     

    For Vista and up, this gets way easier:

     

    To reboot into safe mode with networking:

    # bcdedit /set {current} safeboot network
    # shutdown /r /c "Rebooting to safe mode with networking"

    To revert back to normal boot:

    # bcdedit /deletevalue {current} safeboot
    # shutdown /r /c "Rebooting to normal mode"

     

    Now, the big question:  does Kaseya agent work in safe mode with networking yet?

     

     

  • you would need to make changes to the kaseya agent service to ensure it starts up in safe mode I know some of the older scripts used to do this... I wil have a look at that bcedit thanks.

  • safemode_reboot.zip

    I found the old scripts in the old forum...

  • this is more for XP and also there is the reg changes needed - there is a thread in the old forum about the reg changes need for K2 also as the Service has change.

  • Reboot to Safe Mode.zip

    Hey Mate,

    Complete reboot to safe mode script.
    Works on 2000, XP, 2003, Vista, 7, 2008


    Dave

  • 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:24 AM (GMT -8) on 12-22-2010] Updated formatting of post
  • @Markavillareal

    Thanks for sharing youre scripts! But when i try to import the Reboot to Safe Mode script i get an error message saying:

    ■The file you are trying to import is not formatted correctly. It contains invalid XML.

    ■Name cannot begin with the '#' character, hexadecimal value 0x23. Line 56, position 79

    Do you happen to now what's wrong?

  • @dguertsen

    I believe I have resolved the issue by reformatting my post.  Please try again and let me know if you continue to run into issues.

  • If that doesn't work Mark, try posting the script in the resources section and putting a link here. I'm making a habit of doing this with scripts now which gives us two advantages. One, scripts work. Two, they're all in one place.

    I know I sound like a sales rep blabbing on but once you start doing this as a practice, this new forum starts to make more sense.

    Cheers,

    GM

  • @ghettomaster

    I think I will try that.  I am new to these forums so any advice is greatly appreciated.

    Thanks again!

  • Man, that code tag would have been nice for Marks post... Anyone try Daves script?

  • Daves script works for me :-P

  • @Dave_Browning

    Ya, I used Daves but added some lines for 64-Bit versions of Windows 2003, 2008, & 7.  Dave's original recipe wouldn't work for 64-Bit flavors.  Props to Dave.

  • @thirteentwenty

    Sorry, I'm a n00b to these forums.