views:

29

answers:

1

Hey, guys.

I've been working on modifying an existing vbscript. The wierd part is that when I run the script manually, it works fine. But as soon as I try to run it as a scheduled task, it reports as complete, but doesn't actually do anything. After much troubleshooting, I think I tracked it down to the original CreateObject. Here's the code:

On Error Resume Next

'create an instance of IE
Dim oIE, objFSO, linenum

linenum = 0
Set oIE = CreateObject("InternetExplorer.Application")

'If err.number <> 0 Then linenum = 6
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const ForAppending = 8

Set objTextFile = objFSO.OpenTextFile ("C:\test.txt", ForAppending, True)

'objTextFile.WriteLine(now() & " Internet object created.")

'Execute our URL
'oIE.navigate("<intranet site>")

'objTextFile.WriteLine(now() & " Starting import")

'wait for the window to be closed (exit IE)
'Do Until Err : oIE.visible = True : wsh.sleep 1000 : Loop

'objTextFile.WriteLine(now() & " Import complete.")

if  Err.Number <> 0  then   
   ' An exception occurred
    objTextFile.WriteLine("Exception:" & vbCrLf & "    linenum: " & linenum & vbCrLf & "      Error number: " & Err.Number & vbCrLf & "     Error source: " & Err.source & vbCrLf & "    Error description: " & Err.Description & vbCrLf)
End If


'clean up
'oIE.Quit
'oIE.Visible = False
'Set oIE = Nothing

I've commented most of it out, to narrow it down, and from the logging I added, it spits out the current error:

Exception:
    linenum: 0
    Error number: -2147467259
    Error source: 
    Error description: 

Yes, the source and description lines are blank. Googling the error doesn't seem to bring up anything useful. So I'm not sure what's going on. Permissions have been checked multiple times, and it's always run as Administrator, the same user as I'm logged in as. The funny part is, this script works fine with Windows 2000. About the only thing I can think of is perhaps the Remote Desktop connection I'm using is somehow interfering with it.

Anyone have any ideas or things I might be able to try to resolve this?

A: 

For reference, when you've got problems googling a decimal error number, try converting it to hexadecimal. -2147467259 is the same as 80004005 and if you search for that you'll find that it's quite a common error and usually means that you're denied access to something so even if you're sure that it's not permissions for the things you've checked, it might be worth doing the following checks:

Does the scheduled task run under the same account as you used when you executed the script manually? Otherwise, try doing a RunAs on the script to run as the same user account as the task, if that works, try scheduling the task as your account.
That way you'll know if it's (task vs manual) or if it's (user1 vs user2). Which might make it a little easier to track down the issue.

ho1