+ Post New Thread
Results 1 to 4 of 4
Scripts Thread, Remote Shutdown in Coding and Web Development; Good shutdown script dependent on the ou you pick OPTION EXPLICIT DIM cn,cmd,rs DIM objRoot DIM strRoot, strFilter, strScope ' ...
  1. #1

    Join Date
    Nov 2009
    Posts
    79
    Thank Post
    3
    Thanked 4 Times in 4 Posts
    Rep Power
    10

    Remote Shutdown

    Good shutdown script dependent on the ou you pick

    OPTION EXPLICIT
    DIM cn,cmd,rs
    DIM objRoot
    DIM strRoot, strFilter, strScope

    ' ************************************************** *****************
    ' * Setup
    ' ************************************************** *****************
    ' Specify OU of computers you want to shutdown
    strRoot = "OU=IT Suites,dc=mine,dc=com"
    ' Default filter for computer objects
    ' You might want to use a different filter. By operating system for example:
    ' (&(objectCategory=Computer)(operatingSystem=Window s XP*))
    strFilter = "(objectCategory=Computer)"
    ' Search child organizational units. Use "onelevel" to search only the specified OU.
    strScope = "subtree"

    ' ************************************************** *****************

    SET cmd = CREATEOBJECT("ADODB.Command")
    SET cn = CREATEOBJECT("ADODB.Connection")
    SET rs = CREATEOBJECT("ADODB.Recordset")

    cn.open "Provider=ADsDSOObject;"
    cmd.activeconnection = cn

    cmd.commandtext = "<LDAP://" & strRoot & ">;" & strFilter & ";" & _
    "name;" & strScope
    '**** Bypass 1000 record limitation ****
    cmd.properties("page size")=1000

    SET rs = cmd.EXECUTE

    WHILE rs.eof <> TRUE AND rs.bof <> TRUE
    wscript.echo "Shutting Down " & rs("name") & "..."
    ShutDownComputer(rs("name"))

    rs.movenext
    WEND

    cn.close

    ' Subroutine to shutdown a computer
    PRIVATE SUB ShutDownComputer(BYVAL strComputer)
    DIM strShutDown,objShell

    ' -s = shutdown, -t 60 = 60 second timeout, -f = force programs to close
    strShutdown = "shutdown.exe -s -t 60 -f -m \\" & strComputer

    SET objShell = CREATEOBJECT("WScript.Shell")

    objShell.Run strShutdown, 0, FALSE

    END SUB

  2. #2
    danrhodes's Avatar
    Join Date
    Sep 2008
    Location
    Wath Upon Dearne
    Posts
    1,513
    Thank Post
    157
    Thanked 181 Times in 150 Posts
    Rep Power
    68
    We use shutdownatron, it integrates with GP and works really well.

  3. #3

    Join Date
    Nov 2009
    Posts
    79
    Thank Post
    3
    Thanked 4 Times in 4 Posts
    Rep Power
    10
    i would rather have one on a scheduled task like you can with the above then if any one needs a computer suite leaving on longer you can change the task quicker than changing a group policy.

  4. #4

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,859
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    At the risk of derailing the thread (so my one and only post to it):

    Quote Originally Posted by Danlewis3 View Post
    i would rather have one on a scheduled task like you can with the above then if any one needs a computer suite leaving on longer you can change the task quicker than changing a group policy.
    Relevant doc: Shutdownertron - Administrator’s Guide. Additionally, Shutdownertron polls policy every minute to collect changes, so the maximum time by default is an hour and a half between updates (the time here is the policy update interval in Windows, 1 hour plus or minus a random offset of 30 minutes).

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 10
    Last Post: 20th August 2009, 12:51 PM
  2. Terminal Client Remote shutdown
    By galetony01 in forum Thin Client and Virtual Machines
    Replies: 2
    Last Post: 3rd July 2008, 09:11 AM
  3. Disabling the remote shutdown command.
    By IT_Man_Dan in forum Windows
    Replies: 15
    Last Post: 15th November 2007, 01:31 PM
  4. Remote shutdown
    By Kained in forum Windows
    Replies: 9
    Last Post: 28th August 2007, 06:44 PM
  5. Remote Shutdown Query
    By Kained in forum How do you do....it?
    Replies: 10
    Last Post: 27th April 2007, 08:57 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •