Select to view content in your preferred language

Python arcpy and arcscript methods do not work with Windows Task Scheduler

1041
8
03-24-2011 01:14 PM
ChadHults
New Contributor
Technical Background:  Running ArcGIS 10, Python 2.6, with Windows XP.

I can run Python scripts using the Windows Task Scheduler that do not contain arcpy or arcscript methods.  For scripts that contain arcpy or arcscript methods, I can run using the Scheduler while I'm logged in but not when I'm logged out. 

I have a batch job permission for my user account.  I can run other programs and scripts using the Scheduler when I'm logged out.  I have tested many ways to run the script: batch file; running as .pyw; added .py to PATHEX; changed settings in the registry for running tasks by accessing the desktop; added SetProduct method for license; and more).  None of these changes worked.

Can someone help me figure out why the Arc related methods do not work with the Windows Task Scheduler while I'm logged out?
Tags (2)
0 Kudos
8 Replies
MathewCoyle
Honored Contributor
Arcpy consumes a license which I would guess it cannot access without being logged in as a user with permissions to be granted a license, depending on your network setup.
0 Kudos
GrantCrosswell
Deactivated User
Chad did you get this to consume a license when running?

I have experienced a similar problem. Can this be done on a server? 

I have a number of Point feature classes I'd like to update by delete features> xy event layer> append.  It would be good if I can get this to run at a less busy time.
0 Kudos
MathewCoyle
Honored Contributor
You can check this out for more information.

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000000z000000.htm

As far as I know, to run a script on a server you will need an ArcGIS Server license available to that machine.
0 Kudos
eddiequinlan
Deactivated User
Does anyone have a direct answer to this?  I'm having the same problem.  My .bat file with .py scripts being run from the .bat works great when I'm logged into the server and the scheduled task is set to run when the user logs in.

If i check "run whether user is logged on or not", the .bat script will run but not the .py scripts within the .bat.  The .py scripts will not run even if I try to schedule them individually.  I think I understand why it's not working; just don't know how to get around the user/logged in issue.

Help,
Eddie
0 Kudos
BruceNielsen
Frequent Contributor
This may not apply to you, but one issue I had to deal with when writing scripts to run as scheduled tasks is how to address files that are on a server. Since you're not logged in, the system running the script won't know what your drive mappings are, so you need to replace references to networked drives with UNC conventions. For example, if your script refers to a file on your H: drive you will need to use r'\\servername\home\username\...' instead (your actual drive mappings may vary).
0 Kudos
eddiequinlan
Deactivated User
Hi Bruce,

Thanx for the info.  I think you've hit on the answer.  I tested the scripts on the local C drive and they work, so if I set it up correctly with the mapped drives it should too.  I'm a bit confused on your example......

right now my "lyr" variable = "M:\\coverages\\etc.......

the mapped M drive is on machine "xyz" to directory "gisdatabase".  Not sure where to replace the M with the machine name.

Eddie
0 Kudos
eddiequinlan
Deactivated User
Hi Bruce,

Thanx again.  I figured out the syntax and at this point it's working.

Lyr = (r"\\machine name\gisdatabase\coverages\clrmn\lib\clrmn\annotation.clrmn")

Lyr being a variable.  Gisdatabase being the directory the mapped drive is connecting to.

sincerely,
Eddie
0 Kudos
JaneWickers
Deactivated User
Thanks to this thread I changed my mapped drives to UNC.

What I'm not sure about is what to do with my interoperability connection to ORacle Spatial.

Here's an example:
gp.QuickExport_interop("'Interoperability Connections\\Connection (1) -  ORACLE8I.fdl\\TWEED.SP_CATTLE_DIP_SITE Point'", Output_Dataset_Constraints)

Any ideas appreciated.

Jane
0 Kudos