PC Review


Reply
Thread Tools Rate Thread

Can i pass arguments to a windows service

 
 
Glenn
Guest
Posts: n/a
 
      8th Aug 2005
Hello

Is it possible to pass arguements to a .net service once it is in a
running state.

If this is not possible , are they alternative ways in which to achive
the same thing?

Glenn

 
Reply With Quote
 
 
 
 
Josip Habjan
Guest
Posts: n/a
 
      8th Aug 2005
Hi,

You can use TCP/IP protocol, Remoting, Shared Memory, Named Pipes ...
... then service will have server part (that will listen for data/arguments
you send) ...

Easyest way is to use TCP/IP or remoting..

I'm using my IPC (interprocess communication) library for that things and
send data to service thru Named Pipes ...
You can find library at: http://www.habjansoftware.com/ipc_library.aspx ...
(it is commercial)

Regards,
Josip Habjan
http://www.habjansoftware.com



"Glenn" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello
>
> Is it possible to pass arguements to a .net service once it is in a
> running state.
>
> If this is not possible , are they alternative ways in which to achive
> the same thing?
>
> Glenn
>



 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      8th Aug 2005
Glenn,
| Is it possible to pass arguements to a .net service once it is in a
| running state.

In addition to the other comments.

The "easiest" way to have a service accept a "command" to do something is to
override the ServiceBase.OnCustomCommand method and have it call the same
procedure your Timer.Elapsed event handler calls.

Then you can use ServiceController.ExecuteCommand to invoke this custom
command.

Note I would probably define an Enum of CustomCommands that my service
supported so its easier to keep track of them. A custom command for
OnCustomCommand is an integer between 128 & 256, which also means you can
have multiple custom commands defined.

Remember that ServiceController can control services on your local machine
as well as services on remote machines. Note you may need to configure the
various machines to allow remote control of services.

An alternative, more flexible method, which also entails more work, is to
enable your service for .NET Remoting. You could either make it a .NET
Remoting Server, in which case you call a method to have it perform some
action, or a .NET Remoting Client, and possible handle an "update data
event" on your server remoting object that says to update data...

Both of the custom commands & remoting with a service are discussed in
Matthew MacDonalds book "Microsoft Visual Basic .NET Programmer's Cookbook"
from MS Press.

As an alternative, depending on the nature of the arguments, I have written
them to the Service's app.config file, then stopped & restarted the service.
If your service only has a single service in it, stopping it causes it to be
unloaded from memory, restarting it should then cause it to re-read its
app.config. Of course if your service reads its config from the registry or
a different file, then you may not need to stop & restart it.

Hope this helps
Jay


"Glenn" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
| Hello
|
| Is it possible to pass arguements to a .net service once it is in a
| running state.
|
| If this is not possible , are they alternative ways in which to achive
| the same thing?
|
| Glenn
|


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pass the arguments from web to windows justin Microsoft ASP .NET 2 18th Dec 2006 08:26 AM
Commandline Arguments to the exe corresponding to a Windows Service dmuralikumar@gmail.com Microsoft VB .NET 1 6th Sep 2006 02:03 PM
Cannot pass arguments from .NET Web Service Client to a Java Web Service bobik72 Microsoft Dot NET Framework 0 21st Mar 2006 03:02 PM
Re: Pass Arguments Dan Artuso Microsoft Access VBA Modules 0 9th Sep 2004 11:11 PM
Get command arguments in Windows Service Eric Chong Microsoft Dot NET 5 10th Sep 2003 03:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:24 PM.