473,386 Members | 1,720 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,386 software developers and data experts.

service.exe /install?

Is it [still] possible to write a Windows Service such that it can
install /itself/ based on a command-line argument?

I've got my Service (in VB'2005) with its own, integral Installer which
/works/ when fed into InstallUtil but, for .. "Reasons" .. I'd prefer to
"drive" this all from the executable. I can't work out how to "invoke"
the installer[s] from Sub Main of the service. I keep getting
NullReferenceExceptions from inside the ServiceInstaller's Install method:

' Create my service's installer (added via the IDE)
' This invokes initializeComponent(), which adds
' /two/ Installers (ServiceInstaller and ServiceProcessInstaller)
Dim installer as New ProjectInstaller()

' Something to hold "state" in
Dim state as IDictionary = new Hashtable()

Try
If bInstall Then
installer.Install(state) <- BOOM!

NullReferencEexception
at System.ServiceProcess.ServiceInstaller.Install(IDi ctionary stateSaver)
at System.Configuration.Install.Installer.Install(IDi ctionary stateSaver)
at (namespace) ... Program.SelfInstallService(Boolean install)
in (source file) ...\\Program.vb:line 68

Any suggestions?

TIA,
Phill W.
Feb 27 '08 #1
4 1616

"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
news:fq**********@south.jnrs.ja.net...
Any suggestions?
I've got my Service (in VB'2005) with its own, integral Installer which
/works/ when fed into InstallUtil

Feb 27 '08 #2
http://www.eggheadcafe.com/articles/20041204.asp

Ignore the msmq stuff... and check the install.bat and uninstall.bat stuff.

...

"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
news:fq**********@south.jnrs.ja.net...
Is it [still] possible to write a Windows Service such that it can install
/itself/ based on a command-line argument?

I've got my Service (in VB'2005) with its own, integral Installer which
/works/ when fed into InstallUtil but, for .. "Reasons" .. I'd prefer to
"drive" this all from the executable. I can't work out how to "invoke"
the installer[s] from Sub Main of the service. I keep getting
NullReferenceExceptions from inside the ServiceInstaller's Install method:

' Create my service's installer (added via the IDE)
' This invokes initializeComponent(), which adds
' /two/ Installers (ServiceInstaller and ServiceProcessInstaller)
Dim installer as New ProjectInstaller()

' Something to hold "state" in
Dim state as IDictionary = new Hashtable()

Try
If bInstall Then
installer.Install(state) <- BOOM!

NullReferencEexception
at System.ServiceProcess.ServiceInstaller.Install(IDi ctionary stateSaver)
at System.Configuration.Install.Installer.Install(IDi ctionary stateSaver)
at (namespace) ... Program.SelfInstallService(Boolean install)
in (source file) ...\\Program.vb:line 68

Any suggestions?

TIA,
Phill W.

Feb 27 '08 #3
Mr. Arnold wrote:
>
"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
news:fq**********@south.jnrs.ja.net...
>Any suggestions?

I've got my Service (in VB'2005) with its own, integral Installer which
/works/ when fed into InstallUtil
I thought that one would come back on me.

Of course I /could/ use InstallUtil.exe - but only if the DOS Batch
script that's kicking this "installation" off can /locate/ the correct
(or latest) version /of/ InstallUtil.exe, wherever that might be on the
machine. (You see; it'd be so much easier if the exe is running /in/
the right Framework already and I could just /invoke/ its own installer).

Regards,
Phill W.
Feb 28 '08 #4
On Feb 28, 7:02 am, "Phill W." <p-.-a-.-w-a-r...@-o-p-e-n-.-a-c-.-u-k>
wrote:
Mr. Arnold wrote:
"Phill W." <p-.-a-.-w-a-r...@-o-p-e-n-.-a-c-.-u-kwrote in message
news:fq**********@south.jnrs.ja.net...
Any suggestions?
I've got my Service (in VB'2005) with its own, integral Installer which
/works/ when fed into InstallUtil

I thought that one would come back on me.

Of course I /could/ use InstallUtil.exe - but only if the DOS Batch
script that's kicking this "installation" off can /locate/ the correct
(or latest) version /of/ InstallUtil.exe, wherever that might be on the
machine. (You see; it'd be so much easier if the exe is running /in/
the right Framework already and I could just /invoke/ its own installer).

Regards,
Phill W.
Here is some code at this link that does what you want:

http://tinyurl.com/2otxhv

Chris
Feb 29 '08 #5

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

Similar topics

0
by: chriss | last post by:
Hello everybody! I'm very bad in English but I'm going to try to explain my problem. I have a python program and this program is a service. chronologically: 1. I install my program like...
4
by: DraguVaso | last post by:
Hi, I developped a Windows Service in VB.NET (2005). I need to have it installed two times on 1 machine. When I want to install it a second time, the setup doesn't allow me to install it again...
0
by: poi | last post by:
Running the code below, I get the error Cannot start service from the command line opr debugger. A Windows Service must first be installed (using installutil.exe) and then started with the...
3
by: Jeremy S. | last post by:
On my dev machine (XP/Pro with VS.NET 2003) I have been developing a Windows Service and installing it on the local machine by opening the Visual Studio Command Prompt and then executing . Now I...
2
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:...
3
by: Chris Wagner | last post by:
Anyone knows how to install/unistall service with VB.NET without using InstallUtil program? Thanks
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....
2
by: letibal | last post by:
Hello, I have written a windows service and created an installer for it. The service runs under the system accounts. When started, it launches a GUI. By default, the InteractiveProcess property...
13
by: dancer | last post by:
I have made a new post because when I try to respond to another, I get the error, "Article Rejected -- Ill-formed message id" This is in response to the advice of Juan Libre to install Net...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.