Jonel Rienton <csharp@nospam_.core.com> wrote in
news:3FB989AA.9080103@nospam_.core.com:
Amy L. wrote: I have a windows service where I would like to launch a script (bat,
cmd, vbs, exe, etc) from the service. This script should execute in
the background and not require any input from the user (i.e. not
interact with the desktop).
I have been looking at System.Diagnostics.Process.Start() to launch
this script.
Here are my questions based on this.
1.) Is this the right namespace to be using?
I would use System.Threading namespace or use delegates[1]
System.Threading won't run scripts (or other .exes) and neither will delegates, so,
yes, you are looking in the right place.
2.) I want the program to wait until the script finishes processing
is this possible?
This is the reason why i suggested delegates in #1 question, with
delegates, you can use callback function to grab whatever data you
would need from the asynchronous/synchronous call
Yes, you do a Process p = Process.Start("exename", "args"); and then p.WaitForExit();
Scripts don't do callbacks.
3.) Is there anything else I should consider?
I would be concern with security on what you're trying to accomplish
and since i'm not exactly sure what task the script will do, i cannot
comment any further.
Remember that the script will run as the user that the service is logged in as. By
default that is the LocalSystem account, which is fairly privelidged on the local
system.
Thanks
Amy.
[1] look up asynchronous/synchronous programming in MSDN library
hth,
Jonel
Mark