Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Problem remotely shutting down a windows computer with python

Reply
Thread Tools

Problem remotely shutting down a windows computer with python

 
 
EW
Guest
Posts: n/a
 
      01-03-2005
I have a problem when using the python script found here:

http://aspn.activestate.com/ASPN/Coo.../Recipe/360649

It is a script to remotely shutdown a windows computer. When I use it,
the computer shuts down, but doesn't power off like with a regular
shutdown. It stays on the "Safe to power off" screen and I have to push
the power button to actually power off. Anyone know why this happens
with this script? Thanks for any help.

Eric

 
Reply With Quote
 
 
 
 
Daniel Bickett
Guest
Posts: n/a
 
      01-03-2005
While I have no solution for the recipe you cited, it seems like alot
of trouble could be avoided by simply importing the os module and
running the following command using os.system:

shutdown -s

Daniel Bickett


On 2 Jan 2005 20:13:35 -0800, EW <> wrote:
> I have a problem when using the python script found here:
>
> http://aspn.activestate.com/ASPN/Coo.../Recipe/360649
>
> It is a script to remotely shutdown a windows computer. When I use it,
> the computer shuts down, but doesn't power off like with a regular
> shutdown. It stays on the "Safe to power off" screen and I have to push
> the power button to actually power off. Anyone know why this happens
> with this script? Thanks for any help.
>
> Eric
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

 
Reply With Quote
 
 
 
 
EW
Guest
Posts: n/a
 
      01-03-2005
I believe that would shutdown the computer you were physically at, but
it wouldn't shutdown the computer down the hall over the LAN like this
script was meant to do.

 
Reply With Quote
 
Kartic
Guest
Posts: n/a
 
      01-03-2005
Hi,

According to the online docs for InitiateSystemShutdown() at
http://aspn.activestate.com/ASPN/doc...down_meth.html


bRebootAfterShutdown : int

Specifies whether the computer is to restart immediately after
shutting down. If this parameter is TRUE, the computer is to restart.
If this parameter is FALSE, the system flushes all caches to disk,
clears the screen, and displays a message indicating that it is safe to
power down.


Same at Microsoft for the Win32 API Call -
http://msdn.microsoft.com/library/de...emshutdown.asp

Looks like this is the documented outcome. You could alternatively try
setting a little XML-RPC app to invoke 'shutdown -s' on the remote PC
from your PC (e.g. using Twisted Python).

Thanks,
--Kartic

 
Reply With Quote
 
Duncan Booth
Guest
Posts: n/a
 
      01-03-2005
Kartic wrote:

> Looks like this is the documented outcome. You could alternatively try
> setting a little XML-RPC app to invoke 'shutdown -s' on the remote PC
> from your PC (e.g. using Twisted Python).
>


Or invoke 'shutdown -s -m \\machinename' on the local machine to shutdown a
remote machine.

 
Reply With Quote
 
Tim G
Guest
Posts: n/a
 
      01-04-2005
> I have a problem when using the python script found here:
>
> http://aspn.activestate.com/ASPN/Coo.../Recipe/360649
>
> It is a script to remotely shutdown a windows computer. When I use

it,
> the computer shuts down, but doesn't power off like with a regular
> shutdown. It stays on the "Safe to power off" screen and I have to

push
> the power button to actually power off. Anyone know why this happens
> with this script? Thanks for any help.
>
> Eric


I see that others have answered the question
pretty completely, but just to add the obligatory
WMI solution:
[ assumes you're using the wmi module from
http://tgolden.sc.sabren.com/python/wmi.html ]

<code>

import wmi
c = wmi.WMI (computer="other_machine", privileges=["RemoteShutdown"])
os = c.Win32_OperatingSystem (Primary=1)[0]
os.Win32Shutdown (Flags=12)
</code>

The Flags=12 bit should shut down all the way.

TJG

 
Reply With Quote
 
EW
Guest
Posts: n/a
 
      01-07-2005
This does exactly what I needed! Thanks! Not sure what Windows
Management Instrumentation is, but I'll look into it now.

Eric

 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Computer hangs forever at Windows is Shutting Down screen Lady Rhyanon Computer Support 24 04-19-2011 10:44 PM
Windows XP SP2 - my computer keeps shutting down Rigo Windows 64bit 6 02-16-2008 03:29 AM
Event message: Application is shutting down. Reason: Hosting environment is shutting down. Jack ASP .Net 2 07-18-2007 01:27 PM
shutting down windows XP Remotely The Wolfmare Computer Support 4 09-12-2006 05:52 PM
Python script for remotely shutting down Windows PC from Linux ? diffuser78@gmail.com Python 3 05-16-2006 02:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57