473,545 Members | 1,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Install Windows Service with command line args

I'm trying to install a .NET Windows Service using the ServiceInstalle r /
ServiceProcessI nstaller classes. I cannot seem to find a way to specify
command line arguments.

I've looked through ServiceInstalle r:Install method using reflector and it
appears that it is not possible.

According to the Win32 doco, the CreateService function in advapi32.dll
should be able to accept arguments to the binaryPath parameter. However the
Install method does not allow for this.
Nov 21 '07 #1
3 15464
Hi Robert,

It's a known limitation that currently .NET ServiceProcessI nstaller doesn't
expose a way to specify a command line to the process. We have to
workaround this by using the SCM (Service Control Manager) directly. Here's
an example in VB.NET:

#Install a Windows service the way YOU want to! - The Code Project - VB.NET
http://www.codeproject.com/vb/net/Wi...iceInstall.asp
By the way, we can now specify the description in .NET 2.0 (not available
in 1.1) using ServiceProcessI nstaller. Here's another article on this:

#BCL Team Blog : Installing a Managed Service with a Custom Name [Robert
Villahermosa]
http://blogs.msdn.com/bclteam/pages/577672.aspx
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 22 '07 #2
Thanks Walter,

Just confirming what I suspected. Just had a look at the .NET 3.5 assembly
list and there has been no change. Opportunity missed ?

Anyway, we solved this issue inheriting from the ServiceInstalle r class then
opening the RegKey directly and amending the ImagePath value to include the
commandline parameters required

Hack... maybe but it worked!!

""Walter Wang [MSFT]"" wrote:
Hi Robert,

It's a known limitation that currently .NET ServiceProcessI nstaller doesn't
expose a way to specify a command line to the process. We have to
workaround this by using the SCM (Service Control Manager) directly. Here's
an example in VB.NET:

#Install a Windows service the way YOU want to! - The Code Project - VB.NET
http://www.codeproject.com/vb/net/Wi...iceInstall.asp
By the way, we can now specify the description in .NET 2.0 (not available
in 1.1) using ServiceProcessI nstaller. Here's another article on this:

#BCL Team Blog : Installing a Managed Service with a Custom Name [Robert
Villahermosa]
http://blogs.msdn.com/bclteam/pages/577672.aspx
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 22 '07 #3
Hi Robert,

Thanks for your quick reply.

We have recorded this post in our database, hopefully it will be added in
future versions.

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 23 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1146
by: Jason Callas | last post by:
I want a single executable to be able to run as a Windows Service or from the command line. Is there a way to do this? How can I tell where I am being started from so I can know how to load myself? Thanks, Jason
1
2123
by: Rob Shorney | last post by:
Hi, I need to write a C# windows service that will scan a specified directory every n minutes, the number of minutes needs to be passed in via an argument for examples directoryscanner.exe /timer:5 , would tell the program to scan the directory every 5 minutes Therefore my question how do I code my program to do this. I envisage that some...
2
2278
by: n_o_s_p_a__m | last post by:
I run my multithreaded classes (class library) in a standard exe host, works with no problems; but once hosted in SCM, the threads are not spawned, yet no exceptions are thrown. Is this some kind of limitation?
1
5536
by: Peter Rilling | last post by:
I have an EXE that I would like to be able to run from either the command-line or as a windows service. Is there a way that I can tell which context the program is running in? Basically, if it runs as a service, I would want it to call ServiceBase.Run (which will then call the execution logic). If it is run at the command-line, I simply...
6
6708
by: Microsoft | last post by:
I'm new to CSharp, previously having done all my development in Delphi. I need to create a service, and for the development cycle I wish it to be an interactive service and use message boxes to show various messages. I know I can set the interactive property via the SMC, but I would rather set it programmatically so I do not have to get in...
2
7972
by: Fan Wang | last post by:
Hi All, I wrote a windows service with C# as below. But I can't install it with installutil.exe. I got an error message " Exception occurred while initializing the installation: System.IO.FileNotFoundException: File or assembly name windowsservice1, or one of its dependencies, was not found.. " I am new to C# environment. Any idea any clue...
1
7881
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. I have to do it this way as the consumer of the service should not be able to change the argument - except by uninstalling and reinstalling the...
4
3164
by: kkt49 | last post by:
# vim: et sw=4 ts=8 sts from wxPython.wx import * import sys, os, time import pywintypes import win32serviceutil import win32service import win32event import win32process
5
7706
by: Ajith Menon | last post by:
I have to install .NET framework 3.0. I already have .NET Framework 1.1 installed on my machine. I don't want to remove framework 1.1 since some of the critical applications are using it. While installing .NET framework 3.0 I got the error: "Microsoft .NET Framework 3.0 x86 has encountered a problem during setup. Setup did not complete...
0
7647
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7802
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7742
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5958
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5318
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4940
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3436
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1865
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.