Link to home
Start Free TrialLog in
Avatar of JAM
JAMFlag for Canada

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??
@echo off
set today=%date:~-4%%date:~4,2%%date:~7,2%
 
rename C:\test.log %today%_test.log

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JAM

ASKER

dragon-it:

when, in the SYSTEM cmd prompt, I run

echo %date%

I get --> Fri 04/03/2009


Tried

set today=%date:~-4%%date:~0,2%%date:~3,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... ??
Avatar of JAM

ASKER

wait, I may have had a typo, reviewing now and will post back revised results...
Avatar of JAM

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