objShell.ShellExecute strCommandLine, strArguments,
""
,
"runas"
So without further ado, here is my solution. This was written for Windows Server 2008R2 and .NET 4 and assumes that the gacutil.exe and related files are installed in "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\" – if any of these are different in your environment, you may need to tweak the instructions. Create the following files; Save all of these files to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\ and double-click the reg file to merge it into the registry. You should now be able to update dlls without having to stop and write a script or pull up a command prompt :)
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\gacutil.exe"
/uf %~n
1
/if %~dpnx
pause
This script calls the GacRefresh.cmd script with elevated permissions (the "runas" parameter elevates) – This is the key to getting past the elevation requirement (gacutil requires elevated permissions). It expects and passes 1 parameter to GacRefresh.cmd.
Set
objShell = CreateObject(
"Shell.Application"
)
strArguments = WScript.Arguments(0)
objShell.ShellExecute
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\GacRefresh.cmd"
, strArguments,
This registry entry is what creates the context menu item and exposes it to the shell.
Windows Registry Editor Version
5.00
[HKEY_CLASSES_ROOT\dllfile\shell\Gacutil Refresh]
@=
"Gacutil Refresh (Administrator)"
"HasLUAShield"
=
[HKEY_CLASSES_ROOT\dllfile\shell\Gacutil Refresh\command]
"wscript \"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\Bin\\NETFX 4.0 Tools\\GacRefresh.vbs\" \"%1\""
I hope somebody finds this helpful and I am curious to see how others would accomplish this using alternate methods so I look forward to your comments!
Maheshkumar S Tiwari edited Original. Comment: Added tags