Improve script handling for Windows