Thanks for the reply Victor,
I was able to run the code you provided if I used just test.txt instead of c:\test.txt.
The file then appeared in the C:\netxms\var directory.
I then copied my batch file to this directory and it was able to be run using the following command - file.cmd "%m"
I am running the netxms service as the local admin so I am not sure if it was a permission error?
Thanks