If I run a script, timestamp.cmd, with code below, on the command line on Windows 7 (cmd.exe):
@echo off
echo generating timestamp file >>timestamp.txt
for /f "tokens=1-3 delims=/ " %%a in ('date /t') do (set mydate=%%a%%b%%c)
for /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
echo %mydate% > timestamp.txt
echo %mytime%00 >> timestamp.txt
Then I get output:
31012017
084300
But if I run it as a command from a service then the output is:
Tue0131
0941 AM00
Firstly, I don't understand why I would get such output. And secondly, how do I fix it?