JAM
asked on
why does this script work when executed as user, but not when executed as system account
Need to deploy script, which gets deployed with system account.
To test, running the attached code and when executed as a user... works fine.
To further test, running the attached code as SYSTEM account (by running new command prompt via 'at 01:23 /interactive cmd.exe')... does not work. Results in "The syntax of the command is incorrect".
Found out the %today% variable is what's causing the problem. However, it's only a problem when running it as the SYSTEM account. Why is this??
To test, running the attached code and when executed as a user... works fine.
To further test, running the attached code as SYSTEM account (by running new command prompt via 'at 01:23 /interactive cmd.exe')... does not work. Results in "The syntax of the command is incorrect".
Found out the %today% variable is what's causing the problem. However, it's only a problem when running it as the SYSTEM account. Why is this??
@echo off
set today=%date:~-4%%date:~4,2%%date:~7,2%
rename C:\test.log %today%_test.log
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
wait, I may have had a typo, reviewing now and will post back revised results...
ASKER
yep, I had a typo... your solution worked like a charm, thanks!
Glad it helped... not sure how if the system cmd.exe returned date with DDD dd/mm/yyyy etc. but heh as long as it works for you!
Steve
Steve
ASKER
when, in the SYSTEM cmd prompt, I run
echo %date%
I get --> Fri 04/03/2009
Tried
set today=%date:~-4%%date:~0,2
rename C:\test.log %today%_test.log
and although that (also) worked running as regular user, I got the same problem when running it as SYSTEM... ??