Scheduled task failing

  • Thread starter Thread starter Rob Oldfield
  • Start date Start date
R

Rob Oldfield

I have a pretty straightforward app that's designed to take entries from a
database and create a Word template containing AutoText entries using those
entries. A basic outline of the code is below.

If I run it manually then everything works fine. But the idea is that it
runs overnight and....

If I set it up as a scheduled task (Win 2K server, running as a user that
has full domain admin rights) then it works the first time, but second and
later I get a "Task could not start" error and the following in the task
scheduler log.

"The attempt to log on to the account associated with the task failed,
therefore, the task did not run.
The specific error is:
0x80070569: Logon failure: the user has not been granted the requested logon
type at this computer.
Verify that the task's Run-as name and password are valid and try again."

If I then set the job up again (i.e. reinput the path to the exe and enter
the user name and password), then the same thing happens. First time fine,
next time clunk. I figure that the rights issue error message must be wrong
otherwise how could it run successfully the first time.

To try and separate what exactly was going wrong I also took all of my code
and put it into a subroutine, changed the load code to just enable a timer,
and called my main subroutine from the timer elapsed event. Same thing
happens.

I appreciate that this may not be the best newsgroup for this question, but
nobody on win2000.general had a clue.

Any ideas?


.....and the code which is in the load event of my one form (simplified
version, but containing everything that I'm doing)....

Dim Pth As String
AddressEventLog.WriteEntry("Starting") 'when it fails, nothing is written
to the log
Pth =
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssem
bly.Location) + "\"
'OrigTemplate is just a dot with a bookmark named bmark in it
FileCopy(Pth + "OrigTemplate.dot", Pth + "NewTemplate.dot")
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oTemp As Word.Template
Dim oRange As Word.Range
Dim addr As String

oWord = CreateObject("Word.Application")
oWord.Visible = False
oDoc = oWord.Documents.Add(Pth + "NewTemplate.dot")
oTemp = oWord.ActiveDocument.AttachedTemplate
oRange = oDoc.Bookmarks.Item("bmark").Range

Dim i As Integer, cd As String, dr as datarow
PortAddDA.Fill(PortAddDS1)
For Each dr In PortAddDS1.Tables("Addresses").Rows
addr = ""
cd = dr.Item("Code"))
oTemp.AutoTextEntries.Add(cd, oRange)
addr += dr.Item("Client") + vbCrLf + dr.Item("Address")
oTemp.AutoTextEntries.Item(cd).Value = addr
Next

oRange = Nothing
oTemp = Nothing
CType(oDoc, Word._Document).Close()
oDoc = Nothing
CType(oWord, Word._Application).Quit()
oWord = Nothing

FileCopy(Pth + "NewTemplate.dot",<Target location(s) on network>)

GC.Collect()
Me.Close()
 
Hi ,
One thing I can suggest is that you should copy the msconfig.exe utility
from windows xp machine to this 2000 server and drop it in the system32
folder. then run msconfig from start->run and choose the diagnostic startup
mode and then restart it and run the program and see if it works fine. It
it does thatn probably some start up item on the server maybe the cause for
the problem. You can look at the start up items by running msconfig and
looking at the start up tab, then basically you will have to narrow down
and find out which one causes the problem.

Thanks
Anand Balasubramanian
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks
 
Thanks for the idea, but I don't see how startup items can be causing
problems. If they were then surely the scheduled task wouldn't work the
first time. Could you expand on how you think a startup item could be
breaking the task?
 
Hi ,
One reason I can think of is, the task may be doing something after a
specific period of time and hence when your program runs the first time, it
may work. Anyway the start-up item theory is just one I could think of. I
have seen this happen a few times in the past. So you might just want to
give it a try.

Anand Balasubramanian
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks
 
Thanks again, but it just doesn't make any sense to me to link it to startup
items. If I schedule the job, it runs. I reschedule (and tell it the app
again) one minute later, it works. If I schedule (successfully) and the
reschedule one minute later (without telling it the app again) it fails.

I can't see how that can possibly link to startup stuff.
 
Back
Top