When you run the following cmdlet to prepare Active Directory for the installation of an Exchange Server Cumulative Update (in this case CU17) you might encounter a System.UnauthorizedAccessException.
D:\tmp\Cu17>setup.exe /PrepareAD /IAcceptExchangeServerLicenseTermsMicrosoft Exchange Server 2013 Cumulative Update 17 Unattended SetupUnhandled Exception: System.UnauthorizedAccessException: Access to the path 'C:\Windows\Temp\ExchangeSetup\ExSetup.exe' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.File.SetAttributes(String path, FileAttributes fileAttributes) at Microsoft.Exchange.Setup.CommonBase.SetupHelper.DeleteDirectory(String path) at Microsoft.Exchange.Bootstrapper.Setup.BootstrapperBase.CopySetupBootstrapperFiles() at Microsoft.Exchange.Bootstrapper.Setup.Setup.Run() at Microsoft.Exchange.Bootstrapper.Setup.BootstrapperBase.MainCore[T](String[] args) at Microsoft.Exchange.Bootstrapper.Setup.Setup.Main(String[] args)
There is a simple reason for the the System.UnauthorizedAccessException:
- .NET Framework Optimization Service
The required .NET Framework 4.6.2 had been installed just minutes before executing setup.exe. Preparation of the Active Directory schema ran without any issues. But when the /PrepareSchema call finished, the temporary folder in C:\Windows\Temp\ExchangeSetup could not be fully cleaned up, as mscorsvw.exe had an open file handle on ExSetup.exe.
Additionally, when you run Setup.exe and the folder C:\Windows\Temp\ExchangeSetup exists, the setup will not try to copy required installation files. Regardless if the folder files exists in the folder or not.
Solution
- End both mscorsw.exe processes or wait until both process have finished optimizing your .NET Framework applications
- Manully delete the folder C:\Windows\Temp\ExchangeSetup
- Run the required Exchange setup step again
D:\tmp\Cu17>setup.exe /PrepareAD /IAcceptExchangeServerLicenseTermsMicrosoft Exchange Server 2013 Cumulative Update 17 Unattended SetupCopying Files...File copy complete. Setup will now collect additional information needed forinstallation.Performing Microsoft Exchange Server Prerequisite Check Prerequisite Analysis COMPLETEDConfiguring Microsoft Exchange Server Organization Preparation COMPLETEDThe Exchange Server setup operation completed successfully.
Enjoy Exchange!