Solved

How to pass command line arguments to Windows Service

Posted on 2008-09-29
4
7,792 Views
Last Modified: 2013-12-17
I am writing a service in C#. It needs to take couple of command line arguments. If I add these to the "Start Parameters" within the service properties, then I cannot save those. Is there another way to pass arbitrary command line arguments to the services. Thanks.
0
Comment
Question by:swsbuyer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
Michael_D earned 500 total points
ID: 22598968
0
 
LVL 12

Expert Comment

by:ShazbotOK
ID: 22599366
The OnStart() can take a string array of arguments just like a simple command console app.  anything you put in the startup parameters will be your array of string arguments
0
 

Author Comment

by:swsbuyer
ID: 22599459
My question was "how do I save the startup parameters". Within the Windows service properties, this field is not saved. If you know the answer, please definitely let me know.
0
 

Author Comment

by:swsbuyer
ID: 22600684
Along with the solution recommended by Michael D, another option would be to build the installer within the app itself - to programatically install the service. Please see http://www.c-sharpcorner.com/UploadFile/sachin.nigam/InstallingWinServiceProgrammatically11262005061332AM/InstallingWinServiceProgrammatically.aspx.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question