Task will run locally, but not with Scheduled Tasks

G

Guest

I have a vbscribt and a batch file - neither will run as a scheduled tasks -
but both will run if I launch them manually. I use my domain credentials in
the scheduled tasks - but the same results.

....any ideas??
 
P

Pegasus \(MVP\)

Kevin Buchanan said:
I have a vbscribt and a batch file - neither will run as a scheduled tasks -
but both will run if I launch them manually. I use my domain credentials in
the scheduled tasks - but the same results.

...any ideas??

What makes you think that the script does not run? Try
scheduling the batch file below, then report the contents
of c:\test.log. You should also post the batch file you
use - it's impossible to diagnose your problem unless
you show us what you do!

@echo off
echo %date% %time% Start of task > c:\test.log
echo User=%UserName%, Path=%path% >> c:\test.log
***Put your script command here*
echo ErrorLevel of cript task=%ErrorLevel% >> c:\test.log
echo %date% %time% End of task >> c:\test.log
 
G

Guest

The batch file is below. The vbscript is more complex, but it essentially
did the same thing.

To make this "simple", I have already tested a "simple" script that mapped a
network drive and dumped the directory listing into a log file - which ran
fine if I launched it, but it didn't run when scheduled.

Ok - let me try to paint this picture a little better: The batch file below
is scheduled to run...and it scheduled task is "executed" as evidenced by the
"Last Run Time" column. However, the code within the script doesn't execute.
The scheduled tasks doesn't report any error ("Last result" column = 0x0).

I have tried everything but rebooting the server. I have restarted the
scheduled task service, but it didn't change the results.

-Kevin



@echo off
rem This program will create Date Variables (%DD% %MM% %YYYY%)
rem and copy files to the backup server.
rem Reference: http://www.fpschultze.de/smartfaq+faq.faqid+60.htm


Rem -----------------------------------------------------------------------
echo. | date | FIND "(mm" > NUL
if errorlevel 1 (call :parsedate DD MM) else (call :parsedate MM DD)
goto :EOF

:parsedate ----------------------------------------------------------
rem for /f "tokens=1-4 delims=/.- " %%A in ('date /t') do (
for /f "tokens=1-4 delims=/ " %%A in ('date /t') do (
set Dow=%%A& set %1=%%B& set %2=%%C& set YYYY=%%D& goto :LogDate)


Rem -----------------------------------------------------------------------
:LogDate
Rem echo this for the log file
date /T
echo %YYYY%-%MM%-%DD%
goto :CopyFiles


Rem -----------------------------------------------------------------------
:CopyFiles

Rem Map the network drive, make the directories and copy the files
net use s: \\172.17.1.15\PACS_SQL_And_Server_Logs$ <PWXXXXX> /user:<IDXXXXX>
mkdir S:\Master-MSDBDB_Backup
mkdir S:\wisedb_backup
mkdir S:\WiseServerLogFiles
mkdir S:\WiseServerLogFiles\save-%YYYY%-%MM%-%DD%
xcopy H:\Master-MSDBDB_Backup S:\Master-MSDBDB_Backup /E /Y
xcopy H:\wisedb_backup S:\wisedb_backup /E /Y
xcopy C:\Progra~1\Philips\EasyAccess\log\saved
S:\WiseServerLogFiles\save-%YYYY%-%MM%-%DD% /E /Y
net use s: /del

Rem -----------------------------------------------------------------------
:EOF
 
A

Ayush

Try creating a new task and see if that runs.

--
Ayush [ Be ''?'' Happy ]

For any query, search > www.Google.com
Want to know about a term > http://en.wikipedia.org

Replied To :
-------------------------------------------------------------

:I have a vbscribt and a batch file - neither will run as a scheduled tasks -
: but both will run if I launch them manually. I use my domain credentials in
: the scheduled tasks - but the same results.
:
: ...any ideas??
:
:
: --
:
: -Kevin
 
A

Ayush

I mean try creating a task with a different file. May be the problem is not with the
script but somewhere in Scheduled tasks.

--
Ayush [ Be ''?'' Happy ]

For any query, search > www.Google.com
Want to know about a term > http://en.wikipedia.org

Replied To :
-------------------------------------------------------------

"Ayush" <ayushmaan.j[aatt]gmail.com> wrote in message
: Try creating a new task and see if that runs.
:
: --
: > Ayush [ Be ''?'' Happy ]
:
: For any query, search > www.Google.com
: Want to know about a term > http://en.wikipedia.org
:
: Replied To :
: -------------------------------------------------------------
:
: ::I have a vbscribt and a batch file - neither will run as a scheduled tasks -
:: but both will run if I launch them manually. I use my domain credentials in
:: the scheduled tasks - but the same results.
::
:: ...any ideas??
::
::
:: --
::
:: -Kevin
:
:
 
P

Pegasus \(MVP\)

You should really insert a line at the beginning of your
batch file in order to prove beyond doubt that the batch
file does run, contrary to what you believe:
echo %date% %time% >>c:\test.log

Mapping drive letters to shares in a background task
is a bad idea because the letter might not be available.
Always use UNC coding. Have a look here:
http://support.microsoft.com/?kbid=180362

I recommend that you add the /d and the /c switch
to your xcopy command. It makes for faster and
more robust operation.

Note that this code
for /f "tokens=1-4 delims=/ " %%A in ('date /t') do (
set Dow=%%A& set %1=%%B& set %2=%%C& set YYYY=%%D& goto :LogDate)
can now be replaced by something that is much easier to
debug and maintain, e.g.
set DOW=%date:~0,3%
set YYYY=%date:~8,4%
etc.

Kevin Buchanan said:
The batch file is below. The vbscript is more complex, but it essentially
did the same thing.

To make this "simple", I have already tested a "simple" script that mapped a
network drive and dumped the directory listing into a log file - which ran
fine if I launched it, but it didn't run when scheduled.

Ok - let me try to paint this picture a little better: The batch file below
is scheduled to run...and it scheduled task is "executed" as evidenced by the
"Last Run Time" column. However, the code within the script doesn't execute.
The scheduled tasks doesn't report any error ("Last result" column = 0x0).

I have tried everything but rebooting the server. I have restarted the
scheduled task service, but it didn't change the results.

-Kevin



@echo off
rem This program will create Date Variables (%DD% %MM% %YYYY%)
rem and copy files to the backup server.
rem Reference: http://www.fpschultze.de/smartfaq+faq.faqid+60.htm
Rem -----------------------------------------------------------------------
echo. | date | FIND "(mm" > NUL
if errorlevel 1 (call :parsedate DD MM) else (call :parsedate MM DD)
goto :EOF

:parsedate ----------------------------------------------------------
rem for /f "tokens=1-4 delims=/.- " %%A in ('date /t') do (
for /f "tokens=1-4 delims=/ " %%A in ('date /t') do (
set Dow=%%A& set %1=%%B& set %2=%%C& set YYYY=%%D& goto :LogDate)
Rem -----------------------------------------------------------------------
:LogDate
Rem echo this for the log file
date /T
echo %YYYY%-%MM%-%DD%
goto :CopyFiles
Rem -----------------------------------------------------------------------
:CopyFiles

Rem Map the network drive, make the directories and copy the files
net use s: \\172.17.1.15\PACS_SQL_And_Server_Logs$ <PWXXXXX>
/user: said:
mkdir S:\Master-MSDBDB_Backup
mkdir S:\wisedb_backup
mkdir S:\WiseServerLogFiles
mkdir S:\WiseServerLogFiles\save-%YYYY%-%MM%-%DD%
xcopy H:\Master-MSDBDB_Backup S:\Master-MSDBDB_Backup /E /Y
xcopy H:\wisedb_backup S:\wisedb_backup /E /Y
xcopy C:\Progra~1\Philips\EasyAccess\log\saved
S:\WiseServerLogFiles\save-%YYYY%-%MM%-%DD% /E /Y
net use s: /del
Rem -----------------------------------------------------------------------
 
H

HeyBub

Kevin said:
I have a vbscribt and a batch file - neither will run as a scheduled
tasks - but both will run if I launch them manually. I use my domain
credentials in the scheduled tasks - but the same results.

...any ideas??

If you use a password to log on, scheduled tasks will NOT run.

At least that's the way it was originally, but some update to XP (SP2?)
fixed that. You may have skipped the update.
 
I

Its me Earnest T.

Also, you may want to try running "CScript" and then passing it your script
instead of running your script directly.

Bryan
 
G

Guest

Assuming you have LOCAL machine administrator privileges, go to
Administrative Tools->Local Security Policy->Security Settings->Local
Policies->User Rights Assignment on the left pane. On the right pane
navigate to "Log on as a batch job" and add your username. THEN, go back to
the task scheduler and open your tasks. On the Task tab, go to the Run as
window and enter the same account you just added to the Log on as a batch job
right. MAKE SURE to enter the account name as mymachinename\myusername if
the account is a local machine account OR as
mydomainname\mydomainaccountname, as appropriate. Then click the set
password button and enter the credentials for the account you just selected
for Run as. Finally, DESELECT the Run only if logged on box at the bottom
left of the Task tab.

That should do it.

J
 

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