Fix for script execution - the original state is restored if an exception occurs.
The original working directory is restored and the script path is removed in all cases by using a try-finally setup.
Authored by: bugman 2010-12-17
Parent: [r11872]
Child: [r11874]