I have found the problem....
The kix*.dll files were not in the path when I was executing the script. Other Kix functions were working okay so I did not pick up on the problem initially. When I copied in the relevant DLLs the @HOMESHR function starting working.