Jump to content

Shutting Down Server 2003


Recommended Posts


do u get the error of:

"u r not allowed to logon interactively" (or something like that?) when u try to logon using rdp? in that case it is a matter of permission...

if you dont want the guy to logon to a server for example just to shut down the server.... add a service account that can do it for ya and then try to run within that security context from within a script for example.

vbscript would it for u, where u could hide the pwd and user that u r trying to connect with using crypto (.vbe) and distribute the script to the user or run it remotely... or place in scheduler maby, what do I know...

Hmm... something like this maby...

CODE <Begin> :

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

' Purpose: Script for restarting a server (not DC)

' Author: Br4tt3

' Date: 2004-09-22

' Company: XXXXXXXXXXXXXXXXXXX

' Version: 0.1

'

' Requirement: Obtain RunAsPwd.exe (freeware) and place in system32.

' Also create an account with appropiate permission in correct

' OU structure. Must be run locally on machine. Remote exec

' not supported.

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

Option Explicit

Const DomainAccount="ShutdwnAdmin@company.com"

Const DomainPassword="ShutdwnAdminpwd"

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

' Adding User "ShutdwnAdmin" from AD to

' local Administrator group of computer.

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

Dim objInfo, objGroup, objUser, strComputer

Set objInfo = CreateObject("ADSystemInfo")

strComputer = "."

Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")

Set objUser = GetObject("WinNT://" & objInfo.DomainShortName & "/ShutdwnAdmin,user")

objGroup.Add(objUser.ADsPath)

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

' Mark: Using RunAsPwd to run the .exe in another security context

' than logged on user. Obtain the .exe from inet as it is

' freeware.

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

Dim WshShell, objSys, WshNetwork, Command

Set WshShell = WScript.CreateObject("WScript.Shell")

Set objSys = CreateObject("ADSystemInfo")

Set WshNetwork = WScript.CreateObject("WScript.Network")

Command = "%WINDIR%\system32\runaspwd.exe -u:" & DomainAccount & " -p:" & DomainPassword & " -e:" & "%WINDIR%\system32\shutdown.exe -r"

WshShell.Run Command, 0, True

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

' Remove Global Account "ShutdwnAdmin"

' from local Administrators group

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

Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")

Set objUser = GetObject("WinNT://" & objInfo.DomainShortName & "/ShutdwnAdmin,user")

objGroup.Remove(objUser.ADsPath)

Tried it once here, atleast the machine rebooted... hopes this can solve it for u..

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...