[問題] 再請教一個關於python做類似runas功能的問題

看板Python作者 (1985)時間16年前 (2009/02/20 17:03), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
我裝了win32套件後 想試著在python下更換使用者呼叫程式 程式碼如下 import os, sys, win32con, win32security, win32api class Impersonate: def __init__(self,login,password): self.domain='bedrock' self.login=login self.password=password def logon(self): self.handel=win32security.LogonUser(self.login,self.domain,self.password,win32con.LOGON32_LOGON_INTERACTIVE,win32con.LOGON32_PROVIDER_DEFAULT) win32security.ImpersonateLoggedOnUser(self.handel) def logoff(self): win32security.RevertToSelf() self.handel.Close() i=Impersonate('test','1234') try: print win32api.GetUserName() i.logon() print win32api.GetUserName() os.spawnl(os.P_WAIT, 'C:\Python25\putty.exe') a.logoff() 第一次印出來的使用者即是我當前登入的使用者 cHRIs 第二次印出來的使用者即是我欲改登入的使用者 test putty.exe也順利的call出來了 可是我開工作管理員 發現putty.exe程序的使用者名稱還是 cHRIs 咕狗了半天 似乎是windows XP環境需要做設定 但是怎麼試也試不出來 請各位前輩指點一條明路吧!!! 使用python 2.5 os是 windows XP -- 這孩子真是的,桌子翻完要收整齊啊… http://csdeck.blogspot.com/ 你…還在用無名嗎? ╤═╤ ╤═╤ ╤═╤ ╤═╤ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.32.68.165
文章代碼(AID): #19dd7a9d (Python)
文章代碼(AID): #19dd7a9d (Python)