I was using this question to help with launching workbench from shutdown script but I kept failing.
https://knowledge.safe.com/questions/93753/how-to-execute-a-workbench-from-python.html
The error message I get is.
BADNEWS: FME_END_PYTHON failure class StatusInfo *__cdecl FMETranslator::translate(class FMETValOrderedVector<class ObsoleteString>,bool &,void (__cdecl *)(FME_MsgLevel,const char *),void (__cdecl *)(const char *),bool,bool (__cdecl *)(void *,class ObsoleteString &),void *,bool)(c:\code\fme\foundation\kernel\fmetran.cpp:1369) - class StatusInfo *__cdecl FMETranslator::translate(class FMETValOrderedVector<class ObsoleteString>,bool &,void (__cdecl *)(FME_MsgLevel,const char *),void (__cdecl *)(const char *),bool,bool (__cdecl *)(void *,class ObsoleteString &),void *,bool)(c:\code\fme\foundation\kernel\fmetran.cpp:1369)
Here's my code:
import sys, os, fmeobjects
sys.path.append(r"C:\Program Files\FME\fmeobjects\python37")
os.chdir(r"C:\Program Files\FME")
runner = fmeobjects.FMEWorkspaceRunner()
# initiate FMEWorkspaceRunner Class
# Full path to Workspace, example comes from the FME 2014 Training Full Dataset
workspace = '"C:\Program Files\FME\fme.exe" "C:\Users\myname\My Documents\workspace\retrieveLogInfo.fmw"'
# Use Try so we can get FME Exception
try:
# Run Workspace with parameters set in above directory
runner.run(workspace)
# or use promptRun to prompt for published parameters
#runner.promptRun(workspace)
except fmeobjects.FMEException as ex:
# Print out FME Exception if workspace failed
print ex.message
else:
#Tell user the workspace ran
print('The Workspace %s ran successfully'.format(workspace))
# get rid of FMEWorkspace runner so we don't leave an FME process running
runner = none