Solved

How to pass command line arguments to Windows Service

Posted on 2008-09-29
4
7,632 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now