/haltdef being the first command was not the problem. /haltdef can be placed anywhere in the script, unlike /halt. The problem was that you were missing the ^ prefix.