When run Visual Studio 10 as administrator and build a project with this in my csproj:
<Target Name="BeforeClean"> <Exec WorkingDirectory="$(CommonProgramFiles)\ArcGIS\bin" Command="esriRegasm.exe "$(TargetPath)" /p:Desktop /u " Condition="Exists('$(TargetPath)')" /> </Target> <Target Name="AfterBuild"> <Exec WorkingDirectory="$(CommonProgramFiles)\ArcGIS\bin" Command="esriRegasm.exe "$(TargetPath)" /p:Desktop " /> </Target>
It is able to do the clean (unregister) without any problems. However it complains saying ...
Registration failed. Could not write to disk.
... when it does the AfterBuild. (Notice I've removed the
/s option on the command line.)
I have a bat file that can call EsriRegasm.exe without any problems when run as administrator. However, when I run it as a non-admin I get the same error, which is expected. Batch files run as admin results in spawned processes that are also run as admin. Can Visual Studio do this too?
Is there some option I can add to the csproj file to make it run EsriRegasm.exe as admin?
I've already set my UAC to "never notify", as suggested by kb 39158. And set the file properties on EsriRegasm.exe to run as administrator.