I recommend you register. Registered users can edit their posts, preventing your 3 in a row.
Sorry, but I think I finally sorted everything out.
This forum does not have a "mark solved" button, but registered users sometimes edit their OP (original post) to change the subject title to contain "[solved]".
This thread can be marked as solved as far as I am concerned.
Thanks for all the help.
For anyone who may stumble upon this thread later on, the solution is to move all lines which must be in the Auto-Execute section, such as these three:
SetWorkingDir %A_ScriptDir% GroupAdd, Explore, ahk_class CabinetWClass GroupAdd, Explore, ahk_class ExploreWClassto the top of the script.