John,
I have done this kind of thing using WMI calls to a machine. This will
work on any machine that can support WMI. Microsoft has a downloadable
update on the MSDN site to allow Win 95/98/NT 4.0 machines to handle most of
the WMI calls. I have had incredibly poor luck getting 9x machines to
handle WMI calls over a network but they do work great when the script runs
local. Here is a very small code snippet along with a couple of links.
Sean
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnclinic/html/s
cripting06112002.asp
Option Explicit
'Very simply script to force a restart of a Winodows based machine using
WMI.
'This is only supported on Windows NT 4.0 SP4, Windows 2000,XP,2003
' Globals
Dim ManagedHost, Hmmm, i
'This is where you attach to a given machine.
Set ManagedHost = GetObject("winmgmts:\\" & "name of machine to shutdown" &
"\root\cimv2")
Set Hmmm = ManagedHost.ExecQuery("SELECT * FROM Win32_OperatingSystem")
For Each i in hmmm
i.Win32Shutdown(6)
Next
Hello,
I need to know from my VBS script if the computer where it
runs supports power-off feature. I think that's available
through IsPwrShutdownAllowed API call.
?Is it possible to make such a call from a VBS script?
?Is there any other way to know this?
Thank you
John S. - 22 Oct 2003 23:17 GMT
Hi Sean,
I've read your answer but I am afraid I didn't explain my
answer correctly.
What I want to know is if the computer where the script
runs supports the power-off feature, this is, if when
switching it off normally, it shuts down completely or if
you need to press the power button (the computer says
something like "now it is safe to turn off the computer").
I need it in order to use the correct parameter form the
Win32Shutdown method.
Thank you any way
Sean - 23 Oct 2003 06:33 GMT
Sorry, now I understand what you meant. I can at least give you a point
to look towards. If it is a Windows 2000 or XP machine it will have to
support ACPI in order to power down after the OS shuts down. I do not know
off the top of my head if WMI has this information but I would bet that it
does. Maybe someone else can fill in some more details.
> Hi Sean,
>
[quoted text clipped - 11 lines]
>
> Thank you any way
John - 25 Oct 2003 08:52 GMT
OK, I'll follow that "thread" about ACPI.
Thank you very much