|
![]() |
| 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.htm
")
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.
![]() | ![]() |