My friend had the following idea that I am now using. Ive tested it only on Windows XP and OS X, where it works fine. Admittedly, a little contrived, but in principle it should work well almost anywhere.
\newif\ifwindows \immediate\write18{echo $SHELL > \jobname.os} \newread\@whichos \immediate\openin\@whichos\jobname.os \read\@whichos to \@whichosshell \ifthenelse{\equal{\@whichosshell}{$SHELL }} {\windowstrue} {\windowsfalse} \closein\@whichos \ifwindows \typeout{System detected: Windows} \newcommand\DeleteFile[1]{\immediate\write18{del
The key point here is that Windows will not expand the $SHELL environment variable (any other variable is done, really), so it will literally write the $SHELL line to the file.
source share