By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,562 Members | 1,264 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,562 IT Pros & Developers. It's quick & easy.

command line arguments and references for service

P: n/a
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 I end
up having to do is modify the registry directly from a separate
installer program, which from a deployment perspective is--let's just
say less than optimal.

The second problem I have is that when the Win2K service control
manager runs the service, .Net loader can not locate the dependent
references (several dlls), even though they are in the same directory.
I have to sign the DLLs and install them with a strong name into the
GAC. Again, running gacutil on these DLLs has to be done from the
separate installer, which from a deployment perspective is--let's just
say roundabout.

I am using the command-line utilities directly to build this service
and its modules.

From the Installer class:

Me.ServiceProcessInstaller1.Account = _
System.ServiceProcess.ServiceAccount.LocalSystem
Me.ServiceProcessInstaller1.Password = Nothing
Me.ServiceProcessInstaller1.Username = Nothing
'
'ServiceInstaller1
'
Me.ServiceInstaller1.ServiceName = "Maintenance Service"
Me.ServiceInstaller1.DisplayName = "Maintenance Service"
Me.ServiceInstaller1.StartType = ServiceStartMode.Automatic
' No command line argument property?

Shailesh
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Shailesh,

Thanks for posting.

As far as the command line argument is concerned, it is a pity that
currently we still don't have this property for the ServiceInstaller class.
I understand that it is reasonable that we have this property here.
Hopefully it will be added in the future release of .Net Framework. On the
other hand, the String array argument (ByVal args() As String) for the
"OnStart" method of the Service will capture the "Start parameters" of the
service, instead of the command line argument of the EXE. If you view the
property of the service under "Services" MMC snap-in, you will notice the
text box labelled "Start parameters". It is different from the command line
argument here.

If we would like to customize the starting of the service, we may have to
consider registry or the XML file "app.config". In fact, I believe that we
can achieve this within the same MSI file that installs the service. If you
need assistance on authoring the MSI file, please feel free to let me know.

Regarding the second problem, I have also tried to deploy a service with
dependency on an assembly. The situation you described did not happen on my
side. Except from adding an addtional class library, generally I follow the
steps described in the following KB article:

HOW TO: Create a Setup Project for a Windows Service in Visual Basic .NET
http://support.microsoft.com/?id=317421

After installing the MSI file, the class library assembly is in the same
folder as the EXE file. Although when we start a service, the current
working directory is the system32 directory. This does not affect the
loading of the class library on my side.

I hope the information is useful to you.

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #2

P: n/a
I also noticed the start parameters, but those arguments can only be
used when the service is started manually. Start parameters can not
be saved there, and once the service is started that box becomes
grayed out. This is why a command-line argument property would be so
useful. In the scheme of things, this is a quibble, because the .Net
Framework has cut my development time for this service from weeks to days.

I am not familiar with the process of authoring MSI files or the
app.config files. I will have to look into these further.

I am getting an "Access is Denied" error when calling a function from
the class library. Since you have not seen this, I'll have to
investigate it further on my end, and then maybe describe it in more
detail here if I can't resolve it.

Thanks for your kind response,

Shailesh

Nov 20 '05 #3

P: n/a
Hi Shailesh,

Thanks for your feedback. You are correct regarding the "Start parameters"
and they are not very convenient to use. I hope that the future .Net
Framework will add support for customizing command line arguments for the
service.

As far as the "access denied" is concerned, it is most likely caused by
permission issues. I am not sure if the error is related to the setting of
"ServiceProcessInstaller.Account" on you side.

If you need further assistance from the community or us, please feel free
to post here.

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.