Python Crew

Discussion in 'OT Technology' started by Seeders, Oct 2, 2008.

  1. Seeders

    Seeders OT Supporter

    Joined:
    Jul 10, 2007
    Messages:
    3,750
    Likes Received:
    0
    Im running a python script as a service in windows (we just got SP3 and Python 2.5.2).

    Before (while running SP2 and python 2.0), our script had a thread that would force windows to logout and log back in again if our group policy scripts had not yet finished. This was all fine and still works.

    However, now that we have upgraded, whenever the python script tells windows to log out, instead of just the thread closing, the whole script gets stopped. When the machine logs back in, the service for our python script is still running, but the script itself is not.

    I made a test script that just prints a timestamp to a file every 2 seconds while the thread that causes windows to logoff runs. It prints out for a few seconds, but whenever windows logs off the timestamps stop and do not resume when windows logs back in.

    Anyone know why?

    Code:
    def GPVerifyThread():
        time.sleep(5)
        os.spawnv(os.P_NOWAIT, r"c:\windows\system32\cmd.exe", [r"c:\windows\system32\cmd.exe", r"/c", r"c:\windows\scripts\ssglogin.vbs"])
        thread.exit()    
        
    thread.start_new_thread(GPVerifyThread, ())
    while 1:
        time.sleep(2)
        log_file = open("C:\pyscripts\iKiller.log" , 'a')
        log_file.write("\r\n"+time.asctime(time.localtime(time.time())))
        log_file.close()
    
     

Share This Page