Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 &quot;$(TargetPath)&quot; /p:Desktop /u " 
      Condition="Exists('$(TargetPath)')" />
  <Target Name="AfterBuild">
    <Exec WorkingDirectory="$(CommonProgramFiles)\ArcGIS\bin" 
    Command="esriRegasm.exe &quot;$(TargetPath)&quot; /p:Desktop " />

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.

share|improve this question
up vote 1 down vote accepted

Have you tried putting it in a runas call? That is, instead of

Command="esriRegasm.exe &quot;$(TargetPath)&quot; /p:Desktop " />


Command="runas.exe /noprofile /savecred /user:Administrator esriRegasm.exe &quot;$(TargetPath)&quot; /p:Desktop " />

in the build step's command.

Alternately, you can edit the shortcut to devenv.exe in your start menu to always run as administrator.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.