Solved

How to pass command line arguments to Windows Service

Posted on 2008-09-29
4
7,582 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
Comment Utility
0
 
LVL 12

Expert Comment

by:ShazbotOK
Comment Utility
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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

8 Experts available now in Live!

Get 1:1 Help Now