Discussion Locked

Environment var in scheduled task

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi Guys,

I have set Windows 2000 to run a task using schedule task. The script that I wrote needs to know some environment variables such as ComSpec, HOMEDRIVE and HOMEPATH. I can get env var ComSpec without any problems but I cannot get env var HOMEDRIVE and HOMEPATH. It seems to me that schedule task doesn't by pass some parameter in User Profile to environment such as Home Directory. I can run this script at command prompt so my script works properly.

Anyone knows how to get these env variables from the script when running it in schedule task.

Thanks in advance.

Nopadon H. (Kim)
Email: nopadon@agere.com

2 replies

by dsr28

The task scheduler doesn't run as as user, It runs as localsystem.

Therefore the home path is null and void. To fix this, you can set a global environment variable at the system level to determine if you are scheduled or not, and therefore perhaps hard wire some paths in depending on the case.

by nopadh

Can you give me an example or steps to do it?

Nopadon H. (Kim)
Email: nopadon@agere.com

This discussion is closed to new replies.