Dan.Rolander at marriott
Mar 2, 2001, 6:11 AM
Post #2 of 5
It's pretty easy to use Python with WSH. Install the win32all extensions,
How can I get the logged in users username on Win32?
[In reply to]
which will register the ActiveX scripting engine. Then just create a python
script with a .pys extension. Here's an example that will display the
machine name and currently logged on user:
# A Windows Scripting Host file that uses Python
objNet = WScript.CreateObject("WScript.Network")
WScript.Echo(objNet.ComputerName + " - " + objNet.UserName)
To run it use the command: wscript "W:\My Documents\Source
There is a chapter on Active Scripting in the book Python Programming on
Win32 by Mark Hammond & Andy Robinson. I highly recommend you get it.
Sent: Friday, March 02, 2001 2:56 AM
To: python-list [at] python
Subject: [Q]: How can I get the logged in users username on Win32?
After searching through the Python Docs, I found that on Un*x I could
use getpass.getuser(), but there is no equivalent for the Win32
In other words, how can I get the username in Windows?
As a side note, how can I enable Windows Scripting Host support for
python - there is mention of python in the original WSH docs - and if
I can use python scripts in WSH how would I call the built-in