PC Review


Reply
Thread Tools Rate Thread

auto shutdown

 
 
sam
Guest
Posts: n/a
 
      13th Aug 2004
i want to set a scheduled task to shut down my computer.
i've gotten some previous help, and was told to run the
command "rundll32 shell32,SHExitWindowsEx 0" when I try
to run this command i get the error message: Error in
shell32 Missing entry:SHExitWindowsEx how
can i fix this, or what do i need to run to shut it
down? also, how do i run a command through scheduled
tasks? thanks

 
Reply With Quote
 
 
 
 
Zagan
Guest
Posts: n/a
 
      13th Aug 2004
http://www.budja.com/shutdown/




>-----Original Message-----
>i want to set a scheduled task to shut down my

computer.
>i've gotten some previous help, and was told to run the
>command "rundll32 shell32,SHExitWindowsEx 0" when I try
>to run this command i get the error message: Error in
>shell32 Missing entry:SHExitWindowsEx how
>can i fix this, or what do i need to run to shut it
>down? also, how do i run a command through scheduled
>tasks? thanks
>
>.
>

 
Reply With Quote
 
Carrie Garth
Guest
Posts: n/a
 
      13th Aug 2004
| "sam" <(E-Mail Removed)>
| Message news:530701c480fa$e4478c10$(E-Mail Removed)...
| i want to set a scheduled task to shut down my computer.
| i've gotten some previous help, and was told to run the
| command "rundll32 shell32,SHExitWindowsEx 0" when I try
| to run this command i get the error message: Error in
| shell32 Missing entry:SHExitWindowsEx how
| can i fix this, or what do i need to run to shut it
| down? also, how do i run a command through scheduled
| tasks? thanks

I am not an expert in scripting, but I can lead you to one...

----- Begin Original Message -----
Date: Tue, 08 Jun 2004 23:53:56 +0200
From: "Torgeir Bakken \(MVP\)" <Torgeir.Bakken-(E-Mail Removed)>
Subject: Re: Shutdown remote server
Message-ID: <(E-Mail Removed)>
Newsgroups: microsoft.public.scripting.vbscript

| Paul E. Surette wrote:
| How can I do a clean shut down of a remote server with
| VBScript?

Hi

Alt. 1

PsShutdown.exe in the free PsTools suite (command line)
http://www.sysinternals.com/ntw2k/fr.../pstools.shtml

Alt. 2

Using VBScript/WMI usually works very well also. WMI comes
default with WinME, Win2k and WinXP. Put the following code into
a file called e.g. shutdwn.vbs. If you run it without any input
arguments, it will reboot the local computer. If you add one or
more remote computer names/ip addresses on the command line, the
script will do a reboot of the remote computer(s).


If you want a forced shutdown, change
ShutDown oArgs(i), "Shutdown"
to
ShutDown oArgs(i), "Shutdown_Force"


' script start
Set oArgs = WScript.Arguments

If oArgs.Count = 0 Then
' local computer
ShutDown ".", "Shutdown"
Else
For i = 0 to oArgs.Count - 1
ShutDown oArgs(i), "Shutdown"
Next
End If



Sub ShutDown(sNode, sAction)

' First parameter:
' use "." for local computer

' Second parameter:
' Use "PowerOff" for a poweroff
' Use "PowerOff_Force" for a forced poweroff
' Use "Shutdown" for a shutdown
' Use "Shutdown_Force" for a forced shutdown
' Use "Reboot" for a reboot
' Use "Reboot_Force" for a forced reboot
' Use "LogOff" for a logoff
' Use "LogOff_Force" for a forced logoff

Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Const EWX_POWEROFF = 8

On Error Resume Next
Set oWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" _
& sNode & "\root\cimv2")

Set colOperatingSystems = oWMI.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each obj in colOperatingSystems
Set oOS = obj : Exit For
Next
If Err.Number <> 0 Then
WScript.Echo "Could not connect to " & sNode
Exit Sub
End If

sAction = LCase(sAction)

Select Case sAction
Case "logoff"
iCmd = EWX_LOGOFF
Case "logoff_force"
iCmd = EWX_LOGOFF + EWX_FORCE
Case "shutdown"
iCmd = EWX_SHUTDOWN
Case "shutdown_force"
iCmd = EWX_SHUTDOWN + EWX_FORCE
Case "reboot"
iCmd = EWX_REBOOT
Case "reboot_force"
iCmd = EWX_REBOOT + EWX_FORCE
Case "poweroff"
iCmd = EWX_POWEROFF
Case "poweroff_force"
iCmd = EWX_POWEROFF + EWX_FORCE
Case Else
' Default value
iCmd = EWX_POWEROFF
End Select

oOS.Win32shutdown iCmd

End Sub


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/com...r/default.mspx

----- End Original Message -----

You can find peer-to-peer support for Scripting technologies in
the Windows Server Scripting newsgroup. The following page has
links you can click to access the newsgroup with your Web
browser, or with a Network News Transfer Protocol (NNTP)-based
newsreader such as Outlook Express.

Microsoft Windows Server 2003
Management Technologies Newsgroups
Windows Server Scripting
http://www.microsoft.com/windowsserv...t/default.mspx

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IE Auto Shutdown Audison.Athena@gmail.com Anti-Virus 0 27th Oct 2007 09:42 AM
Auto shutdown Rithy Chhan Windows XP General 7 11th Apr 2006 08:01 AM
auto shutdown? Linn Kubler Microsoft Windows 2000 Setup 0 25th Aug 2005 10:36 PM
recurring auto shutdown and auto startup Roslan B Taib Windows XP Photos 0 13th Dec 2003 09:47 AM
recurring auto shutdown and auto startup Roslan B Taib Windows XP Photos 0 13th Dec 2003 09:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:21 PM.