By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,635 Members | 2,243 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,635 IT Pros & Developers. It's quick & easy.

Windows Service: Running Script Or Executable From

P: n/a
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?
2.) I want the program to wait until the script finishes processing is this
possible?
3.) Is there anything else I should consider?

Thanks
Amy.
Nov 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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]
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
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.

Thanks
Amy.


[1] look up asynchronous/synchronous programming in MSDN library
hth,
Jonel

Nov 22 '05 #2

P: n/a
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]
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
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.

Thanks
Amy.


[1] look up asynchronous/synchronous programming in MSDN library
hth,
Jonel

Nov 22 '05 #3

P: n/a
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
Nov 22 '05 #4

P: n/a
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
Nov 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.