Solved

Task Runs from Command Prompt but not Task Scheduler

Posted on 2013-12-24
17
650 Views
Last Modified: 2014-02-01
We have a simple task that reads records from a Pervasive database using ODBC and writes them to a SQL database.  The task can be run from a command line but NOT from the task scheduler which throws all kinds of  ODBC connection errors (HandleError for every table).  Security, logins, etc. are all identical for the logged in user and the task.
0
Comment
Question by:branuda
  • 7
  • 4
  • 3
  • +3
17 Comments
 
LVL 20

Expert Comment

by:Patrick Bogers
ID: 39738083
What kind of job is it? batch? cmd or powershell?
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39738085
Does the task use ODBC DSNs? If so, they might be defined for the user instead of the system.
0
 

Author Comment

by:branuda
ID: 39738111
cmd
0
Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

 

Author Comment

by:branuda
ID: 39738114
There was a user DSN.  Now there is a System one but same results either way.
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39738122
Make sure you don't mess up with 32bit and 64bit ODBC drivers. Task Scheduler might want to use 64bit executables.
0
 

Author Comment

by:branuda
ID: 39738144
we must use the 32 bit version to connect to pervasive.
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39738161
Than make sure you call 32bit tools inside of the cmd file, or call cmd.exe from the SysWoW64 folder (instead of system32) in your task, e.g. with
  %WinDir%\SysWoW64\cmd.exe /c c:\Scripts\KillTheDb.cmd
0
 
LVL 18

Expert Comment

by:mirtheil
ID: 39738169
What are the exact ODBC errors being thrown?
0
 

Author Comment

by:branuda
ID: 39738343
For EVERY table (so I have just written [tablename] in this example):

Fri 12/20/2013 10:00:24 PM  (Error)  -
                                   at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
   at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle)
   at System.Data.Odbc.OdbcConnectionOpen..ctor(OdbcConnection outerConnection, OdbcConnectionString connectionOptions)
   at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.Odbc.OdbcConnection.Open()
   at [tablename].CreateSchema(String tablename, Table table, Int32 connectionID)
0
 
LVL 18

Expert Comment

by:mirtheil
ID: 39738413
Is there any exception listed in the error?  
Are you using ODBC to both read and write the data?  
Is the error occurring on the read or write portion?  
Did this work at one point and stop or has it never worked?
Does the error happen every time you run the scheduled task?
0
 

Author Comment

by:branuda
ID: 39738571
No exceptions.
Using ODBC to both read and write.
It looks like the error is on the read.
This did stop working but the customer claims that "nothing has changed".
This happens every time the task is run and NEVER when run from a command line.
0
 
LVL 18

Expert Comment

by:mirtheil
ID: 39738610
At this point, I would suggest adding some debugging code to it.  Something is causing the HandleError and you need to figure out what it is.  Ideally, the debugging code would write to a log or event log and show the line(s) of code that cause or at least precede the error. It would also, hopefully, give you a better error with exception or error message that's being returned.
I've written apps (.NET and standard Win32) using the Pervasive ODBC driver (and Pervasive Managed Provider) that run as scheduled tasks without any problems so I know it's possible.
0
 
LVL 12

Expert Comment

by:Dave
ID: 39738927
If its server 2008 or later make sure you click the box which says "run with highest privileges"
0
 
LVL 33

Expert Comment

by:ste5an
ID: 39739017
Do you run the task under the default account or under this user account?
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39739019
You can also try whether the ODBC Trace shows something (useful).
Call %WinDir%\system32\odbcad32 and %WinDir%\SysWoW64\odbcad32 (ODBC Administrator)d 32 bit), open tab Tracing, set a different log file for both, and start logging. After executing the task, stop tracing.
This will show
a) which driver is used
b) if there is some exchange at all
c) details about the failing call
0
 

Accepted Solution

by:
branuda earned 0 total points
ID: 39812393
Thank you for all of your comments.  While helpful, the solution was something else entirely - apparently the task was being run on a different server and for whatever reason, this was not allowed.
0
 

Author Closing Comment

by:branuda
ID: 39826091
Changing servers that ran the task fixed the issue.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mysql database, schema and table creation 13 59
encrypted folder 7 68
Very Large data in MYSQL 7 74
Batch File- Finding Drive Description 11 20
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question