Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I have a build script which runs within visual studio. As part of the script i need to register a DLL with regsrv32, however this needs to be done with elevated privileges.

When we did this under XP, since all users on our domain are local administrators, regsrv32 always succedded, however under Windows 7 it fails as the script runs with the standard user privileges.

I looked at using RunAs, however this doesn't seem to work correctly, and only runs as the account specified, not the current user with elevated privileges.

Does anybody know of a way of elevating a single command within a script?

share|improve this question

Did you get an answer off-line? RunAs doesn't work in Win7 either, even if you create another user as a member of Administrators, because he still needs to be "elevated". Sysinternals ShellRunAs has an "enumerate priviledges" option which only lists one "Basic User", even in an elevated command window - useless!

PS The only workaround I could find was to set the batch-file's shortcut to "Run as Administrator" though the resultant elevation dialog is annoying.

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.