MAKEMSI quickly and reliably creates MSI files in a non-programmatic way
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
[Bottom][Contents][Prev]: AUTOIT.EXE[Next]: Dependency Walker
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Tips and Tricks->Tools->CmdAsUser.EXE

CmdAsUser.EXE

If your MSIs normally get automatically deployed and installed under the SYSTEM account then you would probably want to test your MSIs in a manner as close as possible to this.

To do any initial testing (particularly while developing or modifying the MSI), the deployment process is probably either impossible or too time (or effort) consuming for you to duplicate the "proper" install mechanism.

This program (available from "http://www.pluralsight.com/books/pws/samples.htmThis external link was OK when tested at 21 Jun 2008

HTML page dated Wed, 12 Oct 2005 02:16:15 GMT") allows you to open up a Windows command prompt running under the SYSTEM account. You can then install the MSI. Just remember to add any MSI properties or flags that the deployment process might add to the MSIEXEC.EXE command line ("ALLUSERS=1" is probably one you will always need unless this is built into your MSIs).

Batch File Alternative!

This batch file requires "SC.EXE" to be available:

@echo off
@REM ***********************************************************************
@rem *** Written By: Dennis Bareis (dennis at Dennisbareis dot id.au)    ***
@rem *** BASED ON : http://blogs.msdn.com/adioltean/articles/271063.aspx ***
@REM ***********************************************************************
cls
SetLocal
for %%x in (".") do set  CurrentDir=%%~fx
set ServiceDesc=$CMD.EXE (under SYSTEM account)
set  ServiceCmd=cmd.exe /C start \"%ServiceDesc% - %CurrentDir%\" CMD.EXE /K CD /D "%CurrentDir%"
sc.exe create $LocalSystem binpath= "%ServiceCmd%" type= own type= interact DisplayName= "%ServiceDesc%"
sc.exe start  $LocalSystem
sc.exe delete $LocalSystem

The batch file will open the prompt at the current directory. Just ignore the error message that may (probably will) appear (as long as the new command prompt opens) as "CMD.EXE" wasn't designed to be used as a service.

If It Fails...

I have seen both approaches fail on some boxes, this will likely be because of policies on the box preventing it.


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006 & 2007 for the Windows SDK (Windows Installer) area.This external link was OK when tested at 12 Jun 2008Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: AUTOIT.EXE[Next]: Dependency Walker


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Wednesday June 25 2008 at 7:16pm
Visit MAKEMSI's Home PageThis external link was OK when tested at 21 Jun 2008

HTML page dated Mon, 29 Jan 2007 00:11:11 GMT
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006 & 2007 for the Windows SDK (Windows Installer) area.This external link was OK when tested at 12 Jun 2008