I wanted to edit some Registry permissions with the command line utility setacl.exe and wrote a little script to automate this stuff. The name of the registry key is HKEY_LOCAL_MACHINESOFTWAREGeutebrück – yes, with a nasty umlaut. When I used cmd.exe directly I could change the permission without problems, but whenever I started the script with the same content, I received this error message:
C:>setacl.exe -on "hklmsoftwareGeutebrück" -ot reg ..<cut>..
SetACL finished with error(s):
SetACL error message: Opening a registry key failed
Operating system error message: The system cannot find the file specified.
What’s wrong? I tried to save my script as Unicode file (notepad, save as), but then I was unable to run the script. I discovered a nice utility called chcp, this build-in command shows you the active codepage, which was 437 on my system. A quick lookup up at wikipedia (http://en.wikipedia.org/wiki/Codepage_437) showed my that the ü umlaut is 129d. So I edited my script and replaced the correct looking ü with ALT+0129, which was a non-displaying character in Notepad. Well when I run the script, the output was messed up, but the information was correct:
C:>setacl.exe -on "hklmsoftwareGeutebrück" ..<cut>…
Processing ACL of: <machinesoftwareGeutebrnck>
SetACL finished successfully.
If you use special characters (like öäüàéèÄÖÜ…) replace them in a batch file with the corresponding codepage 437 character.