On Thu, Oct 14, 2010, Bill Janssen wrote: > > try: > import win32api, win32security > > username = win32api.GetUserNameEx(win32api.NameSamCompatible) > print 'granting "logon as a service" rights to ' + username > policy_handle = win32security.LsaOpenPolicy(None, > win32security.POLICY_ALL_ACCESS) > sid_obj, domain, tmp = win32security.LookupAccountName(None, username) > win32security.LsaAddAccountRights( policy_handle, sid_obj, > ('SeServiceLogonRight',) ) > win32security.LsaClose( policy_handle ) > except: > print 'Exception granting user the SeServiceLogonRight:' > print ''.join(traceback.format_exception(*sys.exc_info()))
Bill, I know you know this and are just being sloppy in a test script, but I figure we probably have some Python newcomers on this list: Do *NOT* use bare except: clauses. At the very least, that means you won't properly handle KeyboardInterrupt. Always try to catch the specific exceptions you're expecting. For more info, see http://docs.python.org/howto/doanddont.html It also would have been easier to just use traceback.format_exc() unless you're stuck with Python less than 2.4. -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." --Red Adair _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32