Python subprocess.run() seems to start my MS Access app in read only
My Python 3.7.3 script calls a MS Access app on Win 10 via subprocess.run(). When it executes the MS Access application MS Access hits an error condition and I get a pop up stating “Cannot update. Database or object is read-only”. I only hit this condition when I execute the MS Access app (for this example called: MetaQA.accdb) in python. If I double click MetaQA.accdb in explorer it runs fine. I’ve never seen this issue until I called MetaQA.accdb via subprocess. Is subprocess running it in read-only mode? If so how do I change that?
Side note: I looked at my various MS Access apps and they seem to fail when writing into a local table, i.e. “SELECT empnum, max(transdate) AS lastpaid INTO last_staff_paid”
Variable values to the below code:
access = C:/Program Files (x86)/Microsoft Office/Office16/MSACCESS.EXE
commandLine = S:/ADMIN/DIS/Access Projects/AFEs/MetaQA.accdb
try:
os.chdir( batchPath ) # cd to the batch dir.
if( args.verbose ):
print( "changed directory to: " + os.getcwd() )
except OSError:
print( "Unable to change directory to:", batchPath )
if( args.job ): # run only one job
commandLine = batchPath + args.job
if( args.verbose ):
print( "Running process: " + access + " " + commandLine )
# No timer as its assumed this is being run on the cmd line
proc = subprocess.run( [ access, commandLine ],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True
)
if( proc.returncode != 0 ):
returnStatus = returnStatus + " The following batch job failed: " + batchFiles + "\n"