Cannot access file, in use by another process


here is what I am executing:

Powershell ".\PAL.ps1"
-Log 'C:\PALReports\SRV-MBX-WVA06_Mbx_11010849.blg'
-ThresholdFile 'C:\Program Files\PAL\PAL\Exchange2007-MBX-TechNet.xml'
-Interval 'AUTO'
-IsOutputHtml $True
-HtmlOutputFileName '[LogFileName]_PAL_ANALYSIS_[DateTimeStamp].htm'
-IsOutputXml $False
-XmlOutputFileName '[LogFileName]_PAL_ANALYSIS_[DateTimeStamp].xml'
-OutputDir 'C:\PALReports'
-AllCounterStats $False
-NumberOfThreads 1
-DatabaseDisks 'E:'
-LogDisks 'L:'
-PagingDisks 'D:'
-TempDisk 'C:'
-MajorityClientsCached $False
-CCR $False
-NumberOfProcessors '2'

Here is the exact error message:

Generating the HTML Report...WARNING: Please post errors or problems with this t
ool to the PAL web site
located at http://www.codeplex.com/PAL with the following error message and a
brief description of what you were trying to do. Thank you.
The process cannot access the file 'C:\PALReports\SRV-MBX-WVA06_Mbx_11010849_PA
L_ANALYSIS_2012-11-01_13-31-36.htm' because it is being used by another process
At C:\Program Files\PAL\PAL\PAL.ps1:4851 char:146
  • $sPart00 + $sPart01 + $sPart02 + $sPart03 + $sPart04
  • $sPart05 + $sPart06 + $sPart07 + $sPart08 + $sPart09 + $sPart10 >> <<<< $h
    • CategoryInfo : OpenError: (:) [], IOException
    • FullyQualifiedErrorId : FileOpenFailure
C:\Program Files\PAL\PAL>

This occurs regularly though sometimes it does finish properly. The HTML file is always partially completed when this error occurrs. Things I have tried:

-Run as administrator
-Number of processing threads, tried the values of 1 and also 4 (my system has 4 cores), same resultes either way.

Thought I would throw this up here so maybe someone else might have an idea why it's happening.
Closed Oct 3, 2013 at 5:42 PM by ClintH
Caused by anti-virus software.


ClintH wrote Nov 1, 2012 at 6:45 PM

Most likely your anti-virus software is scanning the file because I write a small amount of data to the HTML report at the beginning as a test to see if I can write to the location, then I close the file until I am ready to write more to it. Each time I write, it is a file system notification that things like anti-virus software love to listen for and scan.

I recommend using Process Monitor (http://live.sysinternals.com/procmon.exe) to capture a trace when the problem occurs, then filter on that directory in Process Monitor to see what software has the HTML file locked.

If you suspect anti-virus software, then consider adding an exclusion in the software to exclude that directory.

ingram20 wrote Nov 2, 2012 at 9:28 PM

You nailed it, moved it to a system with no AV and it completed successfully. Thank you Clint.

ClintH wrote Nov 5, 2012 at 4:38 PM

Ah, good to hear. Thanks for the follow up!

wrote Feb 22, 2013 at 12:46 AM

wrote May 16, 2013 at 11:56 AM

wrote May 16, 2013 at 11:56 AM

wrote Jun 14, 2013 at 7:33 AM

wrote Oct 3, 2013 at 5:42 PM