Can I make a shell context action run as administrator?

5

1

I like to add a shell context menu for registering .dll files using the command

%windir%Microsoft/Framework/v2.0.50727/regasm.exe "%1" /codebase

which used to work fine in XP. However in Windows 7 this command requires administrator privileges. Is there some way I can make this command run as administrator?

Sam Holder

Posted 2010-09-17T15:30:35.830

Reputation: 961

Why do you want to do that in the GUI? Are you having to do this often for some reason? Why don't you just open a CMD prompt as admin and so it from there? – paradroid – 2010-09-17T15:36:54.320

yes I have to do it often, as I switch from building source code from one branch to the other and need to register various files, and I don't want to have the hassle of opening a cmd prompt navigating to the folder for the regasm command and then typing the full path of the file to register, which can be long – Sam Holder – 2010-09-17T18:39:38.130

Why not use the hidden Administrator account when doing this kind of work. cmd...net user administrator /active:yes...log off and you can now log into the real admin account. – Moab – 2010-09-17T19:25:51.123

@Moab, I'm and administrator on the machine already. And logging on and off seems like a hassle to do this. – Sam Holder – 2010-09-23T09:19:36.147

In windows7 user accounts are not like the hidden Admin account, so you are not really the true admin while in a user account like you were in XP. – Moab – 2010-09-23T16:52:46.597

Answers

3

To do this, you need this command to launch using the Shell verb "runas".

You can download a reg file here.

http://www.winhelponline.com/blog/register-dlls-elevated-using-the-context-menu/

REGEDIT4

;Register modules (Elevated) from the context menu
;March 25, 2008 - (c) 2008 Ramesh Srinivasan
;http://www.winhelponline.com
;http://www.winhelponline.com/blog/

[HKEY_CLASSES_ROOT\dllfile\shell]
@="none"

[HKEY_CLASSES_ROOT\dllfile\shell\runas]
@="&Register (as Administrator)"

[HKEY_CLASSES_ROOT\dllfile\shell\runas\command]
@="regsvr32.exe \"%1\""


[HKEY_CLASSES_ROOT\ocxfile\shell]
@="none"

[HKEY_CLASSES_ROOT\ocxfile\shell\runas]
@="&Register (as Administrator)"

[HKEY_CLASSES_ROOT\ocxfile\shell\runas\command]
@="regsvr32.exe \"%1\""

surfasb

Posted 2010-09-17T15:30:35.830

Reputation: 21 453

How do I add multiple verbs that need to run as administrator? – Doub – 2019-04-05T22:38:26.893