473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How register service with command line arguments

2
Hello,

I would like to register service to start with some arguments - meaning command line arguments of service itself. The best approach was some articles about selfregistrating service, like f.e. http://alt.pluralsight.com/wiki/default.aspx/Craig/SelfInstallingService.html

In this case I had assembly executable and could add my parameter at the end, but unfortunately registration itself closed it into dobulequotes :(, so result was "c:\directory\myservice.exe /param" and service didn't not start of couse.

I spent almost all day looking for some solution but till now nothing. Do somebody know some solution or only way is to use an API function ?

tvr
Dec 1 '09 #1
4 9195
Plater
7,872 Expert 4TB
Well you can start your service with arguments from the command line
It's like:
Expand|Select|Wrap|Line Numbers
  1. NET START MYSERVICE /param1 /param2 /param3
  2.  
There might be something you can take away from that?

Also there might be something you can do in the registry at:
Expand|Select|Wrap|Line Numbers
  1. HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\MYSERVICE
  2.  
Dec 3 '09 #2
tvrdak
2
Thank for response, just now I am not in hurry to solve it, but in case I will need, I will try it by edit registry. I am just disapointed to have an installation support inside .net, but no support for add command line parameters when service is beeing registered
Dec 4 '09 #3
Frinavale
9,735 Expert Mod 8TB
I'm a little confused.

What do you mean exactly when you say "register service"?

Do you want to register a .NET DLL (that can be exposed to COM) into the Windows Registry?

Do you want to "register" the software against some sort of database or web service/website?

What tool are you attempting to "register" your service with?
Is it your own tool that you've developed?

-Frinny
Dec 4 '09 #4
Plater
7,872 Expert 4TB
You have to register your service with the service control manager SCM(services.exe) in windows.
For .NET services, this is done with:
Expand|Select|Wrap|Line Numbers
  1. //INSTALL COMMAND
  2. // C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil /i <path and filename of service>
  3. //UN-INSTALL COMMAND
  4. // C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil /u <path and filename of service>
  5.  
(or similar depending on your .NET package I suppose)

I however have not seen anything in InstallUtil, nor the System.ServiceProcess.ServiceProcessInstaller or System.ServiceProcess.ServiceInstaller classes that allow for parameters.

http://msdn.microsoft.com/en-us/libr...e.onstart.aspx
Process initialization arguments for the service in the OnStart method, not in the Main method. The arguments in the args parameter array can be set manually in the properties window for the service in the Services console. The arguments entered in the console are not saved; they are passed to the service on a one-time basis when the service is started from the control panel. Arguments that must be present when the service is automatically started can be placed in the ImagePath string value for the service's registry key (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servi ces\<service name>). You can obtain the arguments from the registry using the GetCommandLineArgs method, for example: string[] imagePathArgs = Environment.GetCommandLineArgs();.

From what I have read, the default servicetype does not allow parameters(my service has the parameters box grayed out in the services.msc settings)
This talks about a FileHandlingWinService type:
http://support.microsoft.com/?kbid=829483
Dec 4 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Hari | last post by:
can i have command line arguments in VS.NET applicatio? if yes how? Can i have some code snippets of the above functionality? I know we can acjieve this in console application form command...
1
by: rforman1 | last post by:
I have found many threads with this question asked and ostensibly answered, but none with an example of how exactly to do it. Help! I know that in order to set up the values of command line...
6
by: Jon Hewer | last post by:
hi i am writing a little script and currently implementing command line arguments following the guide by mark pilgrim from dive into python; ...
7
by: Steve M | last post by:
I'm trying to invoke a Java command-line program from my Python program on Windows XP. I cannot get the paths in one of the arguments to work right. The instructions for the program describe the...
25
by: David Bernier | last post by:
I'd like to pass on the command line two filenames. As for example: my_executable filename_1 filename_2 I haven't done any C programming with command line arguments so far. I'm familiar...
3
by: Shailesh Humbad | last post by:
I want to set a command-line argument for a Windows service that I programmed in VB.Net. This ought to be available from the service installer classes, but I can not find any such property. What...
1
by: amirmira | last post by:
I would like to set command line arguments to a service at install time. I need to do this because I need to get information from different registry locations depending on my command line argument....
4
by: Roland | last post by:
Hi, I am developing a C++ project and want to pass some command line arguments in VS .NET 2003. I am in debug mode, the configuration is set to Debug and I entered my argument list in Project ->...
2
by: Milan | last post by:
Hi, Please guide me how to set command line argument and how to retrive command line argument. Senario: vb.net application should be able to execute from command prompt by passing login and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.