Error might be comes if you are using proxy account credential and try to execute xp_cmdshell procedure with non-sysadmin SQL Server account. You might be get below error that your windows domain user does not have sufficient permission.
“Access to the temp directory is denied. Identity ‘Domain\UserAccount’ under which XmlSerializer is running does not have sufficient permission to access the temp directory. CodeDom will use the user account the process is using to do the compilation, so if the user doesnt have access to system temp directory, you will not be able to compile. Use Path.GetTempPath() API to find out the temp directory location. “
To resolve this error I tried so much googling but didn’t found any thing helpful which tell that what permission to be needed to resolve above error and on which path we have to provide the permission on temp folder.
Than I found Process Monitor tool which is used to monitor running process on system. Click here to download Process Monitor tool.
I ran this utility and track the process activity and found that below path and Modify, Read, Write Permission required on Temp folder.
C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp
Actually process internally used to perform read write operation “IRP_MJ_CREATE” on above Temp folder which gives “ACCESS DENIED”.

