Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Scripting / October 2003

Tip: Looking for answers? Try searching our database.

VBS: knowing power-off feature

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John - 15 Oct 2003 18:09 GMT
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
Sean - 22 Oct 2003 08:44 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.