Passing Parameters to a Windows Service?

  • Thread starter Thread starter Liz
  • Start date Start date
L

Liz

Hello All.

Is it possible to pass parameters into a Windows service?
If so, how would I do it?

I'm working with a situation wherein a number of users on
a network need to access a stamping .exe to add or remove
a watermark from a PDF file. The .exe only exists on one
machine on the network. I was hoping to have a Windows
service on the stamping machine that will wait for an
incoming request (from wherever) that would contain the
appropriate filename and would then do the stamping work.
But I'm not quite sure how to pass the filename
parameter....please help.

Thanks Much!
Liz
 
Try this out. it may be what your looking for. on a new form just add a text
box (Text1).
Then compile it to your C:\ using the name test.exe.
Then from the command promp type "c:\test.exe MyParameters"
Your form will open and "MyParameters" will be in the text box!

Private Sub Form_Load()
cmdLineArr = Split(Command(), """")
Text1.Text = cmdLineArr(0)
End Sub
 
Hi Liz,

Although I've not done it, I believe .NET Remoting is a solution. You'd
have a standard application which your users can call. This would allow them
to specify the Pdf file (via command line, text box, file-browser dialogue
or drag-n-drop from Explorer, etc). It would then create a remote instance
of some object that the Windows Service provides and pass the filename in
that way.

Regards,
Fergus
 
Liz,
As Fergus suggests: .NET remoting is a (the?) way to do this.

Matthew MacDonald's book "Microsoft Visual Basic .NET Programmer's Cookbook"
from MS Press has samples on Windows Services and on .NET remoting.

An alternative for the 'incoming request' would be a Message Queue
System.Messaging.MessageQueue. Where the requestor writes the file name to a
MessageQueue, the file name would be contained in a
System.Messaging.Message. Your Windows Service would read messages from the
MessageQueue invoking the stamping process.

The Message Queue allows the process to be very asynchronize. In that you
can queue multiple requests, then later today or this evening all those
requests can be processed. While .NET Remoting is more synchronize. In that
you can say request a stamping, and its done more or less immediately. Yes
you can make asynchronize .NET remoting calls, however the client has code
'in the background' waiting for the response, while a message queue is more
fire and forget...

Hope this helps
Jay
 
UDP and XML
have your service listen via UDP and setup some sort of XML schema for
requests.
when a UDP XML request is received, create a new thread grab what you need
from XML doc and do your processing

now if you want to do this the way microsoft recommends, i'd use remoting...
but if you want to live on the wild side a bit, i think you can make the
above approach work.
 
Back
Top