Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

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

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

do

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

 
discard

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.