It's a case of not doing your homework. SORT.EXE is in C:\WINNT\system32\ if install is to default location. Of course, you should never trust that and use the %systemroot% var instead. You cannot be certain of the temp folder location either and should use %temp% for it. Also you do not disclose the value of $CommandOption so must assume it is "/c".

Anyway, the command works with the aforementioned mods.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.