import sys
import os.path

dirname = os.path.dirname(sys.argv[0])
basename = os.path.basename(sys.argv[0])

if dirname:
    try:
        os.chdir(dirname)
    except:
        import EasyDialogs
        EasyDialogs.Message("Couldn't change into directory: " + dirname)
        raise

script = basename[:-1]

try:
    os.execlp("pythonw", "pythonw", script)
finally:
    import EasyDialogs
    EasyDialogs.Message(sys.argv[0] + " couldn't launch " + script)


