Windows Service won't instal

S

Schoo

I am trying to install a windows service on my XP workstation (XP
Professional) which I do development on. I am using an example from an
article by Billy Hollis but when I try to run the installutil.exe, it stops
and asks me for a Username and Password (Set Service Login) dialogue box.
This is not mentioned in the article, but then it was written in 2001, so XP
may be more restrictive. I have tried my login and used my
domainName\UserName, but that didn't work either. In the end, it will not
install. Is there anything I am doing wrong or can do differently to
install this Windows Service?

Scott
 
S

Schoo

I don't understand... the link you provided seems to point to a way to set
the ServiceAccount property programmatically. The service is already built
and I am trying to use the DOS window and installutil.exe to get the service
installed. I don't see what VB program code like the
ServiceProcessInstaller.Account Property has to do with this. (maybe it is
just me. :) )

I am not sure what other accounts are available on the workstation, but
there is a "Guest" account. I tried my account info and the Guest acct.
with blank password boxes and still it will not let me install. The actual
error in the DOS window is:

"An exception occurred during the Install phase.
System.CompnentModel.Win32Exception: The account name is invalisd or does
not exist, or the password is invalid for the account name specified".

Then it initializes a rollback.

I can confirm that my user account is set up as "Computer Administrator"
from the control panel.

I hope someone here has some thoughts because I don't see why this wouldn't
work.

Schoo


Phil Wilson said:
Probably the way you have the Account property set. See the point about
asking for user account at install time:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemserviceprocessserviceprocessinstallerclassaccounttopic.asp
--
Phil Wilson [MVP Windows Installer]
----
Schoo said:
I am trying to install a windows service on my XP workstation (XP
Professional) which I do development on. I am using an example from an
article by Billy Hollis but when I try to run the installutil.exe, it stops
and asks me for a Username and Password (Set Service Login) dialogue box.
This is not mentioned in the article, but then it was written in 2001,
so
XP
may be more restrictive. I have tried my login and used my
domainName\UserName, but that didn't work either. In the end, it will not
install. Is there anything I am doing wrong or can do differently to
install this Windows Service?

Scott
 
P

Peter Huang

Hi Scott,

If we need to install the windows service with the installutil tool, we
need to add the Installer class into the project by right click on the
service design view and select Add installer. The serviceProcessInstaller1
will handle the service logon account.
1. Set the Account property to User
2. Set the pass and user
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new
System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
this.serviceProcessInstaller1.Password = "pass";
this.serviceProcessInstaller1.Username = @"domain\user";
this.serviceProcessInstaller1.AfterInstall += new
System.Configuration.Install.InstallEventHandler(this.serviceProcessInstalle
r1_AfterInstall);
this.serviceInstaller1.ServiceName = "TestAccount";
this.serviceInstaller1.AfterInstall += new
System.Configuration.Install.InstallEventHandler(this.serviceInstaller1_Afte
rInstall);
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1, this.serviceInstaller1});
}

3. rebuild the solution
4. run the installutil tool to install the service which will logon as
{domain\user, pass} pair.

If we do not specified the information the installutil tool do not know how
to do that. You may also look into the link Phil posted.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Schoo

Ahhh! I did not know I had to do that. I see it now and I think we are
getting closer... I have some additional questions though:

There are 2 classes in the BeepService project: ProjectInstaller.vb and
Service1.vb. My code is in Service1.vb and there appears to be no code in
ProjectInstaller.vb. However, if I right click the Service1.vb[design] and
choose "Add Installer", it adds it to the ProjectInstaller.vb[Designer] tab
instead. I am going to assume this is OK, please let me know if that is
wrong.

Moving along... I then double-click the ServiceInstaller1 object in
ProjectInstaller.vb[Design] and VS.NET auto-creates a
ServiceInstaller1_AfterInstall procedure. I do not see an
InitializeComponet() item in the Procedure drop-down for the
ServiceInstaller1 object. Am I supposed to just create my own
InitializeComponent procedure? (BTW: I am programming in VB.NET so I will
do my best to convert your code). If so, do I need to set this as a startup
procedure or something? How will the framework know to run this code first
if it is not in a pre-defined initialize event?

Then, there is the "@"domain\user";" line that you have. When I get to this
point, I assume this will have to read: "@ourdomain\myusername" in VB.NET,
right? Also, do I have to substitute anything for "TestAccount" in your
code example or do I need to set up an account anywhere with that name in
the system or anything?

Also, why do I need to specify the domain when I am just installing this
locally? If I am being authenticated accross the network to install
something on my workstation, do I need to make sure of any conditions on the
administration server that would do the authentication?

I look forward to reading your response. :)

Scott


"Peter Huang" said:
Hi Scott,

If we need to install the windows service with the installutil tool, we
need to add the Installer class into the project by right click on the
service design view and select Add installer. The serviceProcessInstaller1
will handle the service logon account.
1. Set the Account property to User
2. Set the pass and user
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new
System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
this.serviceProcessInstaller1.Password = "pass";
this.serviceProcessInstaller1.Username = @"domain\user";
this.serviceProcessInstaller1.AfterInstall += new
System.Configuration.Install.InstallEventHandler(this.serviceProcessInstalle
r1_AfterInstall);
this.serviceInstaller1.ServiceName = "TestAccount";
this.serviceInstaller1.AfterInstall += new
System.Configuration.Install.InstallEventHandler(this.serviceInstaller1_Afte
rInstall);
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1, this.serviceInstaller1});
}

3. rebuild the solution
4. run the installutil tool to install the service which will logon as
{domain\user, pass} pair.

If we do not specified the information the installutil tool do not know how
to do that. You may also look into the link Phil posted.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Huang

Hi
There are 2 classes in the BeepService project: ProjectInstaller.vb and
Service1.vb. My code is in Service1.vb and there appears to be no code in
ProjectInstaller.vb. However, if I right click the Service1.vb[design] and
choose "Add Installer", it adds it to the ProjectInstaller.vb[Designer] tab
instead. I am going to assume this is OK, please let me know if that is
wrong.
This is OK.
Moving along... I then double-click the ServiceInstaller1 object in
ProjectInstaller.vb[Design] and VS.NET auto-creates a
ServiceInstaller1_AfterInstall procedure. I do not see an
InitializeComponet() item in the Procedure drop-down for the
ServiceInstaller1 object. Am I supposed to just create my own
InitializeComponent procedure? (BTW: I am programming in VB.NET so I will
do my best to convert your code). If so, do I need to set this as a startup
procedure or something? How will the framework know to run this code first
if it is not in a pre-defined initialize event?
After the steps above, you can change the code view of ProjectInstaller.vb,
and find the #Region " Component Designer generated code ",click the "+" to
expand the region, and you will find the InitializeComponent method.
Then, there is the "@"domain\user";" line that you have. When I get to this
point, I assume this will have to read: "@ourdomain\myusername" in VB.NET,
right? Also, do I have to substitute anything for "TestAccount" in your
code example or do I need to set up an account anywhere with that name in
the system or anything?

If you are using an local account you can use the format as below.
"computername\testaccount" so that the install service will know to search
the account in the computername SAM database.
Also, why do I need to specify the domain when I am just installing this
locally? If I am being authenticated accross the network to install
something on my workstation, do I need to make sure of any conditions on the
administration server that would do the authentication?

If you are using the AD account(domain account) the Domain controler will
do the authentication, otherwise the local computer do the authentication.

Windows Service Applications
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vboricreatingconfiguringwindowsserviceapplications.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Schoo

I read your description of where to put the code and I found that. Now I am
trying to add your code to the routine and am having problems with that.
the following are the problems I am having in adding the code:

1) "me.serviceProcessInstaller1.AfterInstall..." -> The 'AfterInstall'
item is not in the list of properties/methods for the
serviceProcessInstaller1 item.
2) "...me.serviceProcessInstaller1_AfterInstall)" -> The
'serviceProcessInstaller1_AfterInstall' item does not show up on the list of
properties/methods. Should this be written differently?
3) "...me.serviceInstaller1_AfterInstall)" -> Same problem as above in #2.
4) I am having problems writting the following code you provided as VB.NET.
It seems to be looking for one value and you appear to be giving it two.
How should this be written in VB.NET?

"this.Installers.AddRange(new System.Configuration.Install.Installer[]
{this.serviceProcessInstaller1, this.serviceInstaller1});"

So, now I know where to put the code, I just can't get the code to go into
the right location. Please let me know what you think and I will put the
code in.

Thanks,

Schoo
 
S

Schoo

Peter,

Thanks for your post. Once I understood where you wanted the code to go, I
put it in and went back to your 9/15/04 posting to check to make sure I
posted everything you suggested. I am attaching my current code for the 2
procedures at the end of this post.

I run a build and place the EXE (after checking the date to make sure it is
the most current) in the C:\ directory. When I run the line
"InstallUtil.exe c:\beepservice.exe" in a command prompt window, it seems to
start installing and then I get the following lines:
-----------------------------------------------
....
An exception occurred during the Install phase.
System.ComponentModel.Win32Exception: The specified service already exists
The Rollback phase of the installation is beginning.
....
-----------------------------------------------

I check the Services list in the Admin Tools section of the Control Panel
and don't see it listed. So, I ran "InstallUtil.exe u/ c:\beepservice.exe"
anyway thinking it would clear out anything that is there and I get the
following lines in the middle of the install:
-----------------------------------------------
Warning: The soure BeepService is not registered on the local machine.
Service BeepService is being removed from the system...
An exception occurred during the uninstallation of the
System.ServiceProcess.ServiceInstallation installer.
System.CoomponentModel.Win32Exception: The specified service does not exist
as an installed service
An exception occurred while uninstalling. This exception will be ignored
and the uninstall will continue. However, the application might not be
fully uninstalled after the uninstall is complete.
-----------------------------------------------

I am working off the Billy Hollis article
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvsm01/ht
ml/vs0112dt.asp) which does not go into any of this detail. Is all this
necessary/caused because my workstation is XP? I will also email Mr. Hollis
and see if he has any ideas on this. Are there any KB articles that have
"how-tos" or sample/demo code on installing a windows service? I have to
get this done and am running low on time.

Thank you for all your help.... Schoo

PS> Here is my code:

<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.ServiceProcessInstaller1 = New
System.ServiceProcess.ServiceProcessInstaller
Me.ServiceInstaller1 = New System.ServiceProcess.ServiceInstaller
'
'ServiceProcessInstaller1
'
Me.ServiceProcessInstaller1.Password = "<my password>"
Me.ServiceProcessInstaller1.Username = "USV3270JFS-9\sschum"

'system.Configuration.Install.InstallEventHandler(me.serviceprocessinstaller
1_After

'ServiceInstaller1
'
Me.ServiceInstaller1.ServiceName = "BeepService"
'me.Installers.AddRange(new System.Configuration.Install.Installer()
'
'ProjectInstaller
'
Me.Installers.AddRange(New System.Configuration.Install.Installer()
{Me.ServiceProcessInstaller1, Me.ServiceInstaller1})
End Sub

#End Region

Private Sub ServiceProcessInstaller1_AfterInstall(ByVal sender As
Object, ByVal e As System.Configuration.Install.InstallEventArgs) Handles
ServiceProcessInstaller1.AfterInstall
Me.ServiceInstaller1.ServiceName = "BeepService"
End Sub

Private Sub ServiceInstaller1_AfterInstall(ByVal sender As Object, ByVal
e As System.Configuration.Install.InstallEventArgs) Handles
ServiceInstaller1.AfterInstall
Me.Installers.AddRange(New System.Configuration.Install.Installer()
{Me.ServiceProcessInstaller1, Me.ServiceInstaller1})
End Sub
 

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