| 22 |
|
self.handle.Close() # Guarantees cleanup |
| 23 |
|
|
| 24 |
|
if __name__=='__main__': |
| 25 |
< |
print "Right now I'm %s" % win32api.GetUserName() |
| 25 |
> |
print("Right now I'm %s" % win32api.GetUserName()) |
| 26 |
|
a = Impersonate("wsburrou", "/.,zxc';lasdkf") |
| 27 |
|
try: |
| 28 |
|
a.logon() #become the user |
| 29 |
|
try: |
| 30 |
|
# Do whatever you need to do |
| 31 |
< |
print "Now I'm %s"% win32api.GetUserName() # show that I'm someone else |
| 31 |
> |
print("Now I'm %s"% win32api.GetUserName()) # show that I'm someone else |
| 32 |
|
finally: |
| 33 |
|
a.logoff() # Ensure return-to-normal no matter what |
| 34 |
|
except: |
| 35 |
< |
print 'Exception:', sys.exc_type, sys.exc_value |
| 36 |
< |
print "I'm now exiting as %s" % win32api.GetUserName() |
| 35 |
> |
print('Exception:', sys.exc_info()[0], sys.exc_info()[1]) |
| 36 |
> |
print("I'm now exiting as %s" % win32api.GetUserName()) |