How to run python script without opening the mxd?

Discussion created by bartkowalski on Jul 21, 2011
Latest reply on Jul 22, 2011 by Hornbydd
I just wrote my first python script that copies an even layer to a shp (yay!). It works fine when I run it in python window with the mxd already open. However, if I run the code without  opening the mxd, I get the dataset "does not exist" error message, and if I run it outside of ArcMap entirely, I get a bunch of error messages.
Ultimately, I want to schedule a task that runs the python script like an executable. I understand that the first case is probably due to the fact that I don't have a full path, but it is an event layer, so I am not sure what to put in the path.
Any help would be greatly appreciated.


import arcpy
#set the overwrite option
arcpy.env.overwriteOutput = 'true'
#define the mxd
mxd = arcpy.mapping.MapDocument(r"G:\Temp\Bart\mxds\Parcel_map.mxd")
#copy specified layer to a new shapefile
arcpy.CopyFeatures_management("Transfer Status","G:\Temp\Bart\Shapefiles\PyTest6.shp")