get the service name passed by command line argument --servicename in code

111 views
Skip to first unread message

dom...@gmail.com

unread,
Jun 21, 2013, 12:45:56 PM6/21/13
to topshelf...@googlegroups.com
Hi guys,
 
In the place where we set the Windows service settings, I need to replace all spaces in the DisplayName and put an underscore (_) instead.
 
I would like to do something like that:
 
x.SetServiceName(string.Join("_", x.GetServiceName().Trim().Split(' ')));
 
But I don't find any GetServiceName() method, I would like to have a way to get the service name passed by command line (If I could avoid to parse the command line (args[]) it would be great).
 
Thanks
 

Dru Sellers

unread,
Jun 21, 2013, 1:56:24 PM6/21/13
to topshelf...@googlegroups.com
you can set the service name and the display name on the command line.

my.exe -servicename:bob -displayname:"jim bob"

-d


 

--
You received this message because you are subscribed to the Google Groups "topshelf-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topshelf-discu...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dru Sellers

unread,
Jun 21, 2013, 1:56:38 PM6/21/13
to topshelf...@googlegroups.com
would that work for you?

dom...@gmail.com

unread,
Jun 21, 2013, 8:06:50 PM6/21/13
to topshelf...@googlegroups.com
I could set both on command line but for some technical reasons, I would like to only set the display name in the argument and in code set the service name with the display name without spaces because it seems that topshelf is unable to install a Windows service if the service contains spaces so I need a way to get the display name by code ...

Dru Sellers

unread,
Jun 21, 2013, 8:21:18 PM6/21/13
to topshelf...@googlegroups.com
I believe it is a limitation of Windows rather than topshelf.

It appears after looking at the code that what you want is not currently supported.

We are always open to pull requests, if you would like to implement this yourself.

sorry, that's not the answer I like to give. :(

-d

dom...@gmail.com

unread,
Jun 24, 2013, 4:05:22 AM6/24/13
to topshelf...@googlegroups.com
Thanks for your answer, it's not a big issue for us we still have other options.
 
By the way, about the spaces in service name, I can say that installutil is able to create Windows service with spaces in the service name.
 
see screenshot (this service is install with installutil) :

Reply all
Reply to author
Forward
0 new messages