Do you need to:
- Run a process (like batch files and external exes) asynchronously from within your app and monitor the output (think of FTPing files via an
external FTP client)?
- Handle scripting languages (like PHP scripts) synchronously or
- Run a user interface to control your service (and bypass UAC)?
Then you need to take a look at OddJob.
OddJob enables you to easily run and manage processes (like batch files
and external exes) from within your application. Not only can you run and
terminate the processes that you start, but you can monitor them in your application as they're
Lets face it, sometimes you just can't get away from those ol' batch
files. And being able to run them displaying (and being able to analyse the
output) in your application
.. wow, that's really useful. Or an FTP exe. Simply pass the
details on the command line, and get the "I'm done" when it's finished, and
be able to verify if it succeeded or not. Instead of using the RUN (or
shellexecute) and hoping the program executes correctly, you can retrieve
the output and check it.
Think about it. Retrieving data from process (like the output of a batch file
normally displayed in the black dos window), could really come in
handy sometimes. Also hiding the dos window that is normally
displayed while running a batch file....
These functions writing to the DOS window are writing their results to
something called "Standard Out" - or StdOut. By contrast OddJob allows you
to start a process and "attach" the Standard out from that process to your process.
You also control the "Environment" that the other process has to run
with. So you have complete control over the environment variables that the
other process will "see" as it runs. A Job Object allows groups of these
"processes" (EXEs, batch files, etc) to be managed as a unit.
So one way to think of OddJob is like a RUN command on steroids
Indeed it's way beyond RUN because the usefulness of RUN ends as soon as the
other process is started. With OddJob the
usefulness is only just beginning when the other process starts.
OddJob also allows you to monitor the processes in a Job returning
information like CPU and Memory usage. So if you attach a process to your
job, you can then decide if the other process has consumed too many
resources, and if necessary, kill it. And restart it. So if you want one
program to monitor another, this makes an excellent way to do that. Better
yet, if the process being monitored is something you wrote, then you could
be more polite than just killing it, by sending it a message to shut-down or
OddJob has functionality that let's you list all the processes running on
the PC - not just the ones already in your job. And then you can add any of
those processes to your job. (The only caveat being that a process can only
be in one Job, so if it's already in a job then you can't grab it.) Once the
process is in your job you can monitor it, and kill it if you like. (You can
kill any process, even if they're not in your job, but you can't monitor
them as effectively if they're not in your job). So in this way,
a process Manager
How about starting a desktop interface for your services? In token ring
0, which means you bypass UAC (Vista's User Access Control).