Run regsvr32 as post-build event in VS2008 on Vista 64?

jalaram

Lifer
Aug 14, 2000
12,920
2
81
The program I'm working on has a post-build event to register an add-in for a CAD package. However, regsvr32 won't run on my 64 bit Vista system as is because (I'm assuming) of UAC.

If I run cmd.exe with the Run as administrator option, I can run regsvr32 then.

Any suggestions on how I could elevate the privilege from the post-build event? One possibility is run VS as admin, but are there any side effects to that? Also, double-clicking a sln file would subvert that option. Another is to disable UAC, but I'm trying to avoid that.

 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Run VS as admin would have been my suggestion, and I know a few people who do that anyway. As far as I know there isn't any programmatic method to request elevation, say in a batch file, as there is with sudo in linux.
 

JasonCoder

Golden Member
Feb 23, 2005
1,893
1
81
There's always RunAs... If you don't like the interactive prompt for a password there are some automated utilities out there.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
You could compile an exe and embed a manifest resource that requires it to run as admin, that might get it to run after a UAC prompt.