task scheduler and bach files running

  • Thread starter Thread starter ray.koerner
  • Start date Start date
R

ray.koerner

I just finished writing a batch file that will psftp (secure ftp
client) a file from a Linux machine to a windows machine, after the
copy is complete it takes the log file that was created during the copy
and it emails it to me via Blat, then takes the log file from one
directory and copies it to another and renames it with the current
date, and finally it emails me a dir command off the log file directory
so that I can verify that the file was renamed to the current date. If
I run this batch file from the command line it works perfectly, but as
soon as I schedule it to run through the windows task scheduler it
skips the psftp line. Anyone seen anything like this?
 
I just finished writing a batch file that will psftp (secure ftp
client) a file from a Linux machine to a windows machine, after the
copy is complete it takes the log file that was created during the copy
and it emails it to me via Blat, then takes the log file from one
directory and copies it to another and renames it with the current
date, and finally it emails me a dir command off the log file directory
so that I can verify that the file was renamed to the current date. If
I run this batch file from the command line it works perfectly, but as
soon as I schedule it to run through the windows task scheduler it
skips the psftp line. Anyone seen anything like this?


Under what account is the job scheduled.
Does that account have access to psftp or the credentials to log on or file system permissions or.....

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 
The job is currently scheduled to run under a domain admin account, but
I have tried a local admin account and both did not work.
 
I just finished writing a batch file that will psftp (secure ftp
client) a file from a Linux machine to a windows machine, after the
copy is complete it takes the log file that was created during the copy
and it emails it to me via Blat, then takes the log file from one
directory and copies it to another and renames it with the current
date, and finally it emails me a dir command off the log file directory
so that I can verify that the file was renamed to the current date. If
I run this batch file from the command line it works perfectly, but as
soon as I schedule it to run through the windows task scheduler it
skips the psftp line. Anyone seen anything like this?


Is PSFTP installed for the Domain Admin account your are using?
Any errors in the %SystemRoot%\Schedlgu.txt file?

As a last resort, log on the computer that runs the task as the schedule user and log off.
This will place a profile on the local computer that psftp might need (I don't know the product).


Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 
I am logged on with the user that is sceduled to run the task. No
errors in the log. Everything looks like it completed normally.
 
I am logged on with the user that is sceduled to run the task. No
errors in the log. Everything looks like it completed normally.


????????????????

Cause the job to log everything

If the job is:

@echo off
setlocal
cmd1
cmd2
endlocal


change it to

@echo off
setlocal
call :logit>>C:\logit.log 2>>&1
endlocal
goto :EOF
:logit
cmd1
cmd2

and then inspect the C:\logit.log file.


Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 
I don't really understand the security settings involved but when I ran into
this situation myself I had to schedule an exe that I wrote to run my batch.

That exe was written with VC 6.0 and retrieved a security descriptor then
called CreaterProcessAsUser() to run the batch.

It seems as if running cmd from scheduler does not pass security credentials
to cmd.exe.

J
 
Back
Top