Pass strings with special characters like %date as string without executing as a command

how to escape in mcd %
echo “Hello” >> filename_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.txt

the fileis created with command as “filename_08202017_1005050.txt”

I am expecting the fileto be created with the command as “filename_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.txt”

Hi @kansat

The windows_task resource utilizes the schtasks command in cmd. If you issue the following command in cmd: schtasks /Create /SC DAILY /TN test /TR filename_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.txt
the schtasks.exe will evaulate the date and time values.
So the question is not on chef side I think, but on how to escape it for schtasks.exe.

BTW I do not understand why are you giving a text file as a command

Thanks for the reply simark…