It works, thank you for the hint. I changed the script so that it waits a few seconds until it changes my usermode. Obviously I sometimes wasn't authenticated completely when the script executed. The problem's solved and the topic may be closed.