Click to See Complete Forum and Search --> : Using VB Script to shut down a remote PC


anonymous
07-16-2002, 03:51 PM
[Originally posted by jrwolfe@paonline.com]

I'm running Windows XP Pro on a main PC and a second remote computer via a
LAN connection.

Remote Desktop Connection works great but there doesn't seem to be anyway to
shut down my remote system. I'm somewhat familiar with Wakeup On LAN for
turning on a remote system but I don't know if it will also shut down the
system. Appreciate any help or suggestions.

Someone sent me this VBA script which they indicated would do this job but I have been unable to get it to work. I am not very knowledgable when it comes to VBA.
====================================
'Input: sServer a machine name˙ ˙ sServer˙ =""˙  'a machine name
' sUserName in the form of a user name or Domain\Username
' sPassword password of the user

sServer= "Athlon_remote"
sUserName ="abc"˙ 'in the form of a user name or Domain\Username
sPassword˙  ="sam12" 'password of the user

Set oLocator = CreateObject("WbemScripting.SWbemLocator")
oLocator.Security_.Privileges.AddAsString "SeRemoteShutdownPrivilege"

Set oService = oLocator.ConnectServer(sServer, "root\cimv2", _
˙ ˙ ˙ ˙ ˙ ˙ ˙ ˙ ˙ ˙ ˙ ˙ ˙ ˙ ˙ ˙ ˙ ˙ ˙ sUserName, sPassword)
Set oOSSet = oService.InstancesOf("Win32_OperatingSystem")

For Each obj in oOSSet
˙ Set oOS = obj :˙ Exit For
Next

Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Const EWX_POWEROFF = 8
'
'oOS.win32shutdown EWX_blablah
' Power off:
oOS.win32shutdown EWX_POWEROFF

Jim

anonymous
07-16-2002, 08:37 PM
[Originally posted by Nick]

try this to send the shutdown command...

http://www.freevbcode.com/ShowCode.Asp?ID=4246

it will connect, but not sure if the shutdown commands are included.

anonymous
07-29-2002, 07:40 PM
[Originally posted by Landon Winburn]

Click start and then settings. Click on windows security. Its the same as pressing control alt del.

Landon.