service.exe /install?

P

Phill W.

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 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(IDictionary stateSaver)
at System.Configuration.Install.Installer.Install(IDictionary stateSaver)
at (namespace) ... Program.SelfInstallService(Boolean install)
in (source file) ...\\Program.vb:line 68

Any suggestions?

TIA,
Phill W.
 
P

Phill W.

Mr. Arnold said:
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.
 
C

Chris Dunaway

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top