473,386 Members | 1,708 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 15 '05 #1
3 1756
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 15 '05 #2
You could use System.Diagnostic.Process for the next reasons
1. It's better for performance then Threading
2. You can use delegates - Process has event Exit, so enjoy
3. Method Start of Process class is static and return process - so you could to connect to his events without writing a lot of code.
Nov 15 '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 15 '05 #4

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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.