MapDocument("CURRENT") returns an error "cannot open map document" if it is not run within an ArcMap session and I understand why. However, I need to be able to add a layer to the ArcMap TOC from outside the ArcMap application. How do I best approach that? Can it be done somehow from python outside an ArcMap session?
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "*")[0]
lyr = arcpy.mapping.Layer(os.path.join(sPath,sFile))
arcpy.mapping.AddLayer(df, lyr, "AUTO_ARRANGE")