Monday, May 06, 2013

Auto Reboot Server 2012

http://www.servicefirst.com/KB/a156/how-do-i-schedule-my-server-to-automatically-reboot.aspx

Windows Server 2003

Navigate to Start -> All Programs -> Accessories -> System Tools -> Scheduled Tasks.

Click on "Add Scheduled Task".

You should now see the Add Scheduled Task Wizard. Click Next.

Disregard the list of programs, and click the Browse button.

By default, the browse button will bring you to the root of the C: drive. Navigate to WINDOWS -> system32 and locate the file named ‘shutdown.exe’. Highlight it, and click Open.

Enter your desired name for this task (such as "Auto Reboot"). Next, choose how often you would like your server to reboot, whether it is daily, weekly, or monthly.

Next you can select the time and date of the month you would like the server to automatically reboot.  Click Next

Type in the password for the user you would like this task to run under. If you are setting this task to run under your ‘ServerAdmin’ login, enter the ‘ServerAdmin’ password. Once entered, click Next.

Place a check-mark in the option for 'Open advanced properties for this task when I click Finish'.  Click Finish.

Add the following line in the Run field:

C:\windows\system32\shutdown.exe -r -t 00

You will need to enter your ‘ServerAdmin’ password to confirm the changes. Once entered, click OK.

You have now set Windows to automatically reboot as the time you have specified.

Windows 2008

Navigate to Start > Administrative Tools > Task Scheduler

Name the task to reflect the nature of the request.  Click Next

The next two screens will allow you to set the frequency of the task.  Do so then click Next as you are ready

Select "Start a program", then click Next

In the "Program/Script" box enter in "C:\Windows\system32\shutdown.exe."  If this is a x64 bit operating system, you will want to use "C:\Windows\SysWOW64\shutdown.exe".  Click Next when finished

The last screen will allow you to view the settings before creating the task.  When ready, click Finish.

Map Drive with Domain Password Masked (Windows XP)

'#############################################################
'Author: Scot Geer //
'Script Purpose: Script to map a drive
'Script Reason: Issue with end-users connecting to VPN that
'               cannot connect to an "already" mapped drive
'               on an active directory domain. The fix is
'               to manually map the drive (issue with cached
'               credentials?)
'Script Date: Aug 2006
'Script Updated: April 2008
'Script Actions: Prompts user for username/password, then
'                maps the drive to the domain share. It also
'                has error-handling built-in (checks for
'                network, bad password, etc.) and informs the
'                user as such.
'                *Observe the password is masked when the
'                user types it in*
'Script Requirements:
'         1. XP or above is required (thanks to
'            "ScriptPW.Password", it will *not* work
'            on Win2k or below). FYI, this does *not* work in Vista

'            or Windows 7 due to the lack of the scriptpw.dll file.
'            It *might* work if you copy over that file from an XP
'            machine
'         2. This script must be run in a command line
'            window (with the 'cscript' parameter):
'            "cscript scriptName.vbs"
'         3. To automate this script, create a batch
'            file with the line:
'            "start cmd /k cscript /nologo scriptName.vbs"
'            Batch file and vbs script should reside
'            in the same folder
'         4. Technician will have to edit parameters
'            "drvLetter", "ShareDir", & "domain" in
'            order for this script to work
'

'#############################################################
Option Explicit

Dim objShell,objNetwork,objPassword
Dim drvLetter,shareDir,domain,userName,userPswd
Dim driveAlreadyMapped,errorNOS
Dim error001,error002,error003

Set objShell = WScript.CreateObject("Wscript.Shell")
Set objNetwork = WScript.CreateObject("WScript.Network")
Set objPassword = CreateObject("ScriptPW.Password")

driveAlreadyMapped = False
errorNOS = False

drvLetter = "S:"    'change to any drive letter desire
shareDir = "\\serverName\shareName"   'change to your server share
domain = "domainName\"            'keep the backslash

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WScript.StdOut.Write "Please enter your username:"
userName = WScript.StdIn.ReadLine
WScript.Echo

If userName = "" Then
    WScript.Echo
    Wscript.StdOut.WriteLine String(60, "#")
    Wscript.Echo "No Username Entered or User Cancelled"
    quitscript
End If

Wscript.StdOut.Write "Please enter your password:"
userPswd = objPassword.GetPassword()
Wscript.Echo
WScript.Echo

mapDrive drvLetter,shareDir,domain,userName,userPswd
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


'Maps drive w/username, pswd. Invokes error handler if drive is already mapped
'******************************************************************************
Sub mapDrive(drv,share,dom,usr,pswd)

    On Error Resume Next

    objNetwork.MapNetworkDrive drv, share, "false", dom & usr, pswd

    errorHandler_mapDrive

    If Not(driveAlreadyMapped) And Not(errorNOS) Then
        WScript.Echo
        Wscript.StdOut.WriteLine String(60, "#")
        Wscript.StdOut.WriteLine "Success!"
        WScript.Echo
        Wscript.StdOut.WriteLine "You may now open your ""Shared"" files"
        Wscript.StdOut.WriteLine String(60, "#")
    End If

End Sub
'*******************************************************************|

'Notifies user if drive is already mapped, bad username/pswd, or off network
'******************************************************************************
Sub errorHandler_mapDrive

    If Err.Number<>0 Then

        error001 = InStr(1,Err.Description,"already",1)
        error002 = InStr(1,Err.Description,"found",1)
        error003 = InStr(1,Err.Description,"password",1)

        If (error001) Then
            driveAlreadyMapped = True
            WScript.Echo
            Wscript.StdOut.WriteLine String(60, "#")
            Wscript.StdOut.WriteLine "Your ""Shared"" drive is already mapped"
            WScript.Echo
                WScript.StdOut.WriteLine "Open your ""Shared"" files as normal"
                WScript.Echo
                WScript.StdOut.WriteLine "Notice001"
                Wscript.StdOut.WriteLine String(60, "#")
        ElseIf (error002) Then
            errorNOS = True
            WScript.Echo
            Wscript.StdOut.WriteLine String(60, "#")
            Wscript.StdOut.WriteLine "The path to the drive could not be found"
            WScript.Echo
            WScript.StdOut.WriteLine "Drive = " & shareDir
            WScript.Echo
            Wscript.StdOut.WriteLine "Check your network connection to ensure " _
                & "you are connected to the Internet"
            WScript.Echo
            Wscript.StdOut.WriteLine "Make sure you are connected to the VPN"
            WScript.Echo
            Wscript.StdOut.WriteLine "Notice002"
            Wscript.StdOut.WriteLine String(60, "#")
        ElseIf (error003) Then
            errorNOS = True
            WScript.Echo
            Wscript.StdOut.WriteLine String(60, "#")
            Wscript.StdOut.WriteLine "Wrong username or password"
            WScript.Echo
            Wscript.StdOut.WriteLine "Run this script again"
            WScript.Echo
            WScript.StdOut.WriteLine "Ensure you are typing your username " _
                & "& password correctly"
            WScript.Echo
            WScript.StdOut.WriteLine "Check your CAPS LOCK"
            WScript.Echo
            Wscript.StdOut.WriteLine "Notice003"
            Wscript.StdOut.WriteLine String(60, "#")
        End If

          Err.Clear

    End If

End Sub
'*******************************************************************|

'Ends Script with a notification to the user
'******************************************************************************
Sub quitscript

    WScript.Echo
    WScript.Echo "Quitting Now"
    Wscript.StdOut.WriteLine String(60, "#")
    Wscript.Quit

End Sub
'*******************************************************************|