Tired of enabling installer packages with User Account Control turned on? Miss the right-click & Run as Administrator command on MSI files? Want to easily run each installer with logging enabled?

ManuallyCallLogFromAdminConsole

 

At least I was. Here is a quick way to add a Run As Administrator With Log command to msi files (inspired by David Ebbo’s post ):

All we need is modify the MSI.Package class definition in the registry.

    The first step is to add a “runas” shell entry. This allows the command to automatically be run as administrator.

    The next step is defining a command to be executed. This is the tricky part, because for flexibility our command needs to be of the REG_EXPAND_SZ type. The latter means that any system shortcuts such as %appdata%, %systemroot%, %windir%, etc. will automatically get resolved. Thus, a simple command such as:

"%SystemRoot%\System32\msiexec.exe" /i "%1" /limev "%1.log"

  RegFileCommandLineResult
needs to be defined in binary format, i.e.:

@=hex(2):22,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
  00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6d,00,\
  73,00,69,00,65,00,78,00,65,00,63,00,2e,00,65,00,78,00,65,00,22,00,20,00,2f,\
  00,69,00,20,00,22,00,25,00,31,00,22,00,20,00,2f,00,6c,00,69,00,6d,00,65,00,\
  76,00,20,00,22,00,25,00,31,00,2e,00,6c,00,6f,00,67,00,22,00,00,00

Here is the full content of the regfile I used:

 

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Msi.Package\shell\runas]
@="Run as &Admin With Log"

[HKEY_CLASSES_ROOT\Msi.Package\shell\runas\command]
@=hex(2):22,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6d,00,\
73,00,69,00,65,00,78,00,65,00,63,00,2e,00,65,00,78,00,65,00,22,00,20,00,2f,\
00,69,00,20,00,22,00,25,00,31,00,22,00,20,00,2f,00,6c,00,69,00,6d,00,65,00,\
76,00,20,00,22,00,25,00,31,00,2e,00,6c,00,6f,00,67,00,22,00,00,00

 

Just create a reg file and import it to your registry and you’ll have the command enabled:

CommandActive

 

Best,


About the Author

Erjan Gavalji

 is Software Developer in Telerik

Related Posts

Comments