[python-win32] rebooting windows from Python?

Wesley Brooks wesbrooks at gmail.com
Thu Dec 4 21:16:57 CET 2008


To restart I use:

outFileObject = os.popen("shutdown -r -t 05", 'r')

To shutdown swap -r for -s. This is the same as running the "shutdown -r -t
05" on the command prompt.

The number is the delay and the outFileObject catches any messages that
would be printed out to the command prompt window.

Wes.

2008/12/4 Alec Bennett <whatyoulookin at yahoo.com>

> I'm wondering if there's some way to reboot or shutdown Windows from within
> Python?
>
> I can log out like this:
>
> win32api.ExitWindowsEx(4)
>
> And according to the documentation, I should be able to shutdown like this:
>
> win32api.ExitWindowsEx(2)
>
> But that returns the following error:
>
> 'A required privilege is not held by the client.'
>
> Is there some way to do this? Currently I'm running shutdown.exe, which
> works, but I'd rather do it directly if possible.
>
> Thanks for any help.
>
>
>
>
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20081204/b1355f3f/attachment.htm>


More information about the python-win32 mailing list