Work with your network/admin folks. If there's some company policy that says the computers must be locked, and you go about putting in a script to prevent it you'll just be violating your company policy.
we use a vm (virtual machine) system to maintain security while still being able to run tests over an extended period of time. we have a special domain account configured to not lock up a computer. the account is only enabled for our vm's. when a qtp test is running on the vm, it doesn't matter if the physical box is locked or not. so, i can initiate an extended run of tests, have my workstation lock up later, but the vm remains unlocked and the tests can run all night.