Using special characters in C$SYSTEM command line
A call to C$SYSTEM fails when the command contains special characters like ‘&’:
CALL "C$SYSTEM" USING "START C:\TEMP\MF&2019.XLSX" 225 GIVING RETURN-VAL
The following error is recieved. Only part of the command is recognized so the file cannot be found.
Windows command shell will recognise the ampersand as a special character. An escape character is needed in the command line to enable it to work. For example using the previous command with the escape character will look like this:
CALL "C$SYSTEM" USING "START C:\TEMP\MF^&2019.XLSX" 96 GIVING RETURN-VAL
Adding the escape character before a command symbol allows it to be treated as ordinary text. This applies to the following characters also:
^ & < > | ‘ ` , ; = ( )
Other characters may require a different escape character, like a backslash, depending on the command line you are executing.