4

I just noticed that windows 7 task scheduler doesn't use the latest updated environment path variable. Task scheduler is up and running and I changed the path variable. New processes that run in the task scheduler have the old path. I had to kill the taskeng.exe so that it can start using the latest path. So looks like Task scheduler spawns new processes as child processes rather than new parent processes. Is there any work around for this without killing the task scheduler process?

Regards, AJ

Alok
  • 3,160
  • 3
  • 28
  • 47

3 Answers3

4

Use cmd /c to start the program, this will allow access to environment variables. eg:

cmd /c start %my_exe_path%\myexe.exe

SeanC
  • 15,695
  • 5
  • 45
  • 66
0

Changing the account that the job is running under in the scheduler worked for me (on win server 2008 r2).

0

to use the correct path inside the task scheduler use the registry like that:

:::: print System PATH
for /f "usebackq tokens=2,*" %%A in (`reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PATH`) do echo "%%B"

:::: print User PATH
for /f "usebackq tokens=2,*" %%A in (`reg query HKCU\Environment /v PATH`) do echo "%%B"

if you run this from an interactive CMD not a script, then change %%A and %%B to %A and %B

Badr Elmers
  • 1,487
  • 14
  • 20