Solved

How to pass command line arguments to Windows Service

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

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.   …
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

773 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