473,386 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Windows Service: Running Script Or Executable From

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
4 1601
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Amy L. | last post by:
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...
3
by: belgiozen | last post by:
Hi, I have a working windows service,it is looking for files on the disk and when some of the files are cupdated it calls an executable. But it takes a lot of time(about 10 minutes) to run the...
9
by: SP | last post by:
Hi All, I wrote a windows service which is supposed to stop after specified amount of time. I am calling OnStop() after specified time. OnStop() methods executed but I dont see the service...
10
by: Ger | last post by:
I am having problems using VB.Net's Management base object on a machine hosting Windows Server 2003. I am trying to set file permissions from a Windows Service. These files may be loacted on a...
6
by: Leonardo Curros | last post by:
Hello, I would like to know what's the best way to restart one service. I would like to do it from the service itself. Is this possible? I try it with ServiceController.stop()...
2
by: deko | last post by:
When to use a privileged user thread rather than a windows service? That's the question raised in a previous post . It was suggested that if the service needs to interact with a WinForms app...
4
by: ags5406 | last post by:
Hi All I have a task that I'm thinking about attacking in two different ways but don't know enough about Windows Services. First: We have a server application written in VB.net that acts as...
15
by: Daniel Klein | last post by:
I'm trying to get popen to work on Windows. Here's a simplified example of what I'm trying to get working: I have a hw.c program as follows: #include <stdio.h> main() { printf ("Hello...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.