Windows batch job not running properly due to "Cannot access a closed file" error
search cancel

Windows batch job not running properly due to "Cannot access a closed file" error

book

Article ID: 252263

calendar_today

Updated On:

Products

Workload Automation Agent

Issue/Introduction

When trying to run a job that calls Excel, the job fails and the following error is seen in the spool.
 
 Unhandled Exception: System.ObjectDisposedException: Cannot access a closed file.
    at System.IO.FileStream.Flush(Boolean flushToDisk)
    at System.IO.StreamWriter.Dispose(Boolean disposing)
    at System.IO.StreamWriter.Close()
    at ClaimsInventory.modClaimsInventory.main()
 

Environment

Release : 12

Resolution

Set oscomponent.logon.elevated=true in agentparm.txt and restart the agent.

Then, rerun the job.