Batch file from task scheduler

J

Jaimy

We have recently imaged some servers and are having
problems with task scheduler. When I call the batch file
from a location other than %systemroot% it seems that the
environment is not getting set properly. If I run the
path command in the window in which the batch file is
running there is no path. I know that I can set these
env. settings in the batch file, but I should not have
to. Can anyone shed some light onto why there are no env.
settings when I run the batch from a different location.
I have tried numerous accounts checked for permissions and
most of the obvious.
 
D

Dave Patrick

Your details are sketchy but; Control Panel|System|Advanced|Environment
Variables|System Variables and make sure that "Path" has
%SystemRoot%\system32;%SystemRoot%
at least somewhere in the string.

Else check that "Path"
found at
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
is a type Reg_Expand_Sz string and not type Reg_Sz

You can run Programs|Accessories|System Tools|Backup, then choose ERD, then
if you check the box for "Also backup....", then the reg will also be backed
up to
%windir%\repair\RegBack
leaving the
%windir%\repair\
directory files intact as original installation.

Then close all programs, run regedit, navigate to
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
rename the Reg_Sz string "Path" to "Pathx" Then run regedt32, navigate to
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
double-click on Pathx, then right-click|Copy the string then from the menu;
Edit|Add Value
Value Name:=Path
Data Type:=REG_EXPAND_SZ
OK
then paste the string (copied from Pathx) in the string editor text box.
OK
Should be ok to delete the old value "Pathx" Close regedit, and regedt32,
restart for effect.


--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft MVP [Windows NT/2000 Operating Systems]
http://www.microsoft.com/protect.

:
| We have recently imaged some servers and are having
| problems with task scheduler. When I call the batch file
| from a location other than %systemroot% it seems that the
| environment is not getting set properly. If I run the
| path command in the window in which the batch file is
| running there is no path. I know that I can set these
| env. settings in the batch file, but I should not have
| to. Can anyone shed some light onto why there are no env.
| settings when I run the batch from a different location.
| I have tried numerous accounts checked for permissions and
| most of the obvious.
 
J

jaimy

Hey thanks for the help. I had checked that reg key from
another article that I had found online. If I remove the
startin dir on the scheduled task it seems to run fine. I
am just confused on why this is different than my other
servers that are in production.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top