[python-win32] Window Location & Logout
Steven Faulconer
sfaulconer at cfl.rr.com
Thu Jan 8 07:12:31 EST 2004
Tim,
Thanks for the response. The logon scripts are actually local to the
system, no domain controllers involved, but I'll keep your warning in
mind. And I plan to purchase the Python Win32 book today. What is
happening is the script is not graphical, but it is interactive, so when
you execute it (standalone, non-login) a console window appears running
python.exe, since the .py files are all associated with python. When the
script is run as a login, the same thing happens, but that console
window is minimized, which is normal for login scripts. My desire is to
have my script force its window to be normal sized (not-minimized).
And thank you for the pointers on the logoff, I'll take a look at WMI.
Thanks again for the response.
Steven Faulconer
Tim Golden wrote:
>>-----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:
>[http://www.oreilly.com/catalog/pythonwin32/]
>You can get to it via O'Reilly's Safari, which I also recommend:
>[http://safari.oreilly.com/1565926218]
>
>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:
>http://aspn.activestate.com/ASPN/Mail/Browse/Threaded/Python-win32
>or
>http://mail.python.org/pipermail/python-win32/
>
>
>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:
>http://tgolden.sc.sabren.com/python/wmi.html
>
>2) Check out the similar example here:
>http://tgolden.sc.sabren.com/python/wmi_cookbook.html#reboot_remote_machine
>
>3) Try the following code:
><code>
>import wmi
>c = wmi.WMI (privileges=["Shutdown"])
>for os in c.Win32_OperatingSystem ():
> os.Win32Shutdown (Flags=0)
>
></code>
>
>Flags=0 is a logoff. The Win32Shutdown method is documented on MSDN:
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/
>win32shutdown_method_in_class_win32_operatingsystem.asp
>
>HTH
>TJG
>
>
>________________________________________________________________________
>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:
>http://www.star.net.uk
>________________________________________________________________________
>
>_______________________________________________
>Python-win32 mailing list
>Python-win32 at python.org
>http://mail.python.org/mailman/listinfo/python-win32
>
>
>
More information about the Python-win32
mailing list