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]: Registry Related Tools[Next]: SCHTASKS.EXE
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Tips and Tricks->Tools->RunProcess.exe

RunProcess.exe

This is free tool very handy if you need a timeout on a process (it has other useful abilities). You can get it from "http://dennisbareis.com//swrecom.htm". There is another program which does some of the same things (look for "RunPrio.ZIP").

I have used this program on a keyboard firmware updating program which can in some circumstances display a message box (i.e. hang).

Note that if I don't use a full path to an executable then a search (via the PATH) is only performed if the name didn't supply an extension! So if "SomeThing.exe" is not in the current directory it won't be searched for but if you supplied "SomeThing" then it would be!

Timeout - Handling Secondary Processes

Some processes might themselves kick off others, it is worth checking for this and trying to reproduce hangs (perhaps by clearing a ".iss" file) to check what happens. If not all tasks are killed on timeout (any child processes probably aren't) then you can use "PV.EXE" to do this (kill processes by name). You would execute the appropriate kill commands before the runprocess based task and perhaps as a rollback action.

Some InstallShield "setup.exe" installers invoke a second copy, I don't feel comfortable killing a process with such a "generic" name however I have noticed that if I rename the "setup.exe" to "DistinctiveName-Setup.exe" the secondary process also has the same name and so can be safely killed without the small risk that you are killing some other "setup.exe" task!

RunProcess.EXE /?

Version 0.523, Copyright (C)2002, Frank P. Westlake. The only way to the Father is through Jesus.
Runs a process.

RunProcess [options] ProgramName [ProgramName's parameters]

OPTIONS (':' is optional):
 /a:file      The contents of this file will be appended to the command line,
              following a space (unless '/-a'), and line endings will be
              converted to spaces. The length of the resulting command line is
              limited by the system to 32kb.
 /c:l|n|h|r   Set the priority class to low (l), normal (n), high (h), or
              realtime (r). Realtime priority should not be used. Ex: /c:n
 /desktop:[]  Desktop or window station and desktop (default=WinSta0\Default).
 /d:DirName   Current directory for the process is 'DirName'.
 /f:flags     Process flags, for experts only. 'flags' may be one or more of
              the following (ex: /f:cgp):
                c  Create a new console window. Cannot be used with 'd'.
                d  Create a detached process. Cannot be used with 'c'.
                g  Create a new process group.
                p  Create the 16-bit application in a private VDM.
                s  Create the 16-bit application in the shared VDM.
                u  Create a Unicode environment.
                w  Create suspended process (if /fGW, CTRL-C resumes).
                b  If logon as user ('/u'), perform a batch logon.
                i  If logon as user ('/u'), perform an interactive logon.
                n  If logon as user ('/u'), perform a network logon.
                v  If logon as user ('/u'), perform a service logon.
 /e:o|n       Send the process's STDERR to STDOUT (/e:o) or NULL (/e:n).
 /o:e|n       Send the process's STDOUT to STDERR (/o:e) or NULL (/o:n).
 /i           Ignore CTRL_LOGOFF_EVENT for use with SRVANY as a service.
 /k:time      Kill the process if it does not finish in the specified time. If
              not specified otherwise, the time will be read as milliseconds.
              To indicate hours, minutes, or seconds, immediately follow the
              time with one of the modifiers: h, m, or s. Ex: /k:3000 or /k:3s
 /m[:BitMask] Process affinity mask. Ex: /m:1 (1), /m:11 (1,2), /m:10 (2).
 /r[:o|e|c|n] Print a process report to STDOUT (o), STDERR (e), or directly to
              the console window (c). The default is STDERR. Ex: /r or /r:o
              or /r:n to disable all reporting. Any other string is a filename.
 /u:username  If specified, the process will be logged on with the indicated
              username. The username may be preceded with the domain name. Ex:
              /u:fwestlake or "/u:NT Authority\system" or /u:.\fwestlake
 /p[password] A plain text password that is necessary for username. If absent,
              no password is used. If '/p' alone, password is read from STDIN.
 /t:time      A time, date-time, period, or date-time interval (ISO8601:2000).
              Format: [R[n]/][start-date]Tstart-time[/[end-date][Tend-time]]
              Ex: /t:T23:36, /t:2002-09-11T23:36, /t:R3/T23:36/T23:45, /t:PT3S
 /title:text  A console window title.
 /v:file      Environment block for the process. One line per variable, lines
              must be sorted. Leading spaces will not be removed. Format:
              Variable Name=Variable value
 /w:flags     Sets window options. 'flags' may be one or more of the following
              followed by a value and separated by commas (Ex: /w:R80,L25):
                x  Window position, pixels from left of screen.
                y  Window position, pixels from top of screen.
                c  Window size, pixels from left to right.
                r  Window size, pixels from top to bottom.
                l  Consoles only, buffer size in characters from left to right.
                w  Consoles only, buffer size in lines from top to bottom.
                b  Consoles only, background color.
                f  Consoles only, foreground color.
                s  Window state (0=hidden, 1=normal, 2=min, 3=max)
 /x           Do not wait for process to complete before repeating or exiting.

NOTES:
- If the file name extension is not specified, a search will be conducted using
the PATHEXT environment variable.
- For extended command line lengths (/a) do not use CMD.EXE.
- '/k' limits the duration of each occurance of ProgramName, '/t' with an end
time or duration ends all repetitions of ProgramName.
- if '/f:u' and '/v:file' are both specified, 'file' must be a Unicode file.
- The 'ErrorMessage:' item in the report is only useful if the process is using
Windows System Exit Codes. Some programs do, but not always.

EXAMPLES:
  Run a process and wait for it to complete:
    RunProcess ProgramName

  Run a low priority process, wait for it to complete or kill it in 5 seconds,
  and print a report to the console instead of STDERR:
    RunProcess /c:l /k:5s /r:c ProgramName

  Run a process as another user and wait for it to complete:
    RunProcess /u:accounting\ksmith /p:secret ProgramName

  Repeat a process indefinately from 12:00 to 13:00, kill each instance that
  lasts longer than 2 minutes and kill the last instance at 13:00:
    RunProcess /t:R/T1200/T1300 /k:2m ProgramName

  Run a process on the default desktop and do not wait for it to complete:
    RunProcess /x /f:c /desktop ProgramName


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: Registry Related Tools[Next]: SCHTASKS.EXE


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Friday October 13 2017 at 2:08pm
Visit MAKEMSI's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.