[python-win32] Window Location & Logout

Tim Golden tim.golden at viacom-outdoor.co.uk
Thu Jan 8 03:55:52 EST 2004

>-----Original Message-----
>From: Steven M. Faulconer [mailto:geek at cfl.rr.com]
> I've written a login script for our systems that do 
> various tasks, some of them are interactive. 

First of all, a warning. If you're talking here about
the logon to an NT domain and its corresponding logon
script, be aware that some slightly unexpected things
can happen because there's no guarantee of what is and
what isn't set up while the script is running. This
warning is very vague and woolly, but is down to my own
moderate experience at getting NT logon scripts running 
with and without Python.

If you're talking about some other kind of logon, eg to
an application, then ignore that last paragraph. Well,
don't ignore it completely; it might come in useful some day!

> It works very well, except when the script runs at logon, 
> the window is minimized. Is there a programatic way to tell 
> the window to 'unminimize' itself?

Can you be more specific? Which bit is calling which bit and
how? Which window is minimized? etc. I can't quite get a clear
picture of what's happening.

> Also, is there a programatic (through win32api or com) to tell 
> a system to logout?

OK; here I can help. If you want to do *any* work on Python/Win32,
I *strongly* recommend Mark Hammond / Andy Robinson's book on the
subject: Python Programming on Win32: 
You can get to it via O'Reilly's Safari, which I also recommend:

In Chapter 16, on page 305 in my edition, there's a description of
how to reboot a machine, which uses the win32api.InitiateSystemShutdown
function. I think it's already been discussed on this list; check
the archives:

I don't have any experience myself of that particular approach, 
so I'll leave others to follow up on that. 
What I do have experience of is WMI. As you're using
W2000, you've got everything you need, so try the following:

1) Download and install the WMI module from here:

2) Check out the similar example here:

3) Try the following code:
import wmi
c = wmi.WMI (privileges=["Shutdown"])
for os in c.Win32_OperatingSystem ():
  os.Win32Shutdown (Flags=0)


Flags=0 is a logoff. The Win32Shutdown method is documented on MSDN: 


This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

More information about the Python-win32 mailing list