Solved

Windows Service

Posted on 2004-04-08
5
328 Views
Last Modified: 2010-04-15
Everytime I build and deploy my windows service I have to redo the required username and password for it to run.

Is there anyway to supply these values programmatically so I don't have to keep typing them in?
0
Comment
Question by:knowlton
5 Comments
 
LVL 12

Assisted Solution

by:dfiala13
dfiala13 earned 50 total points
Comment Utility
Yes, I believe you can...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemserviceprocessserviceaccountclasstopic.asp

You need to build an installer app, but it lets you specificy the account to use when the service is installed.
0
 
LVL 9

Accepted Solution

by:
malharone earned 400 total points
Comment Utility
This is how you'd do that...

Double click on your service to go to "design view" or select the YourServiceFile.cs file from Solution Explorer and press SHIFT+F7.
Go to View > Properties Window (F4).
The properties window'll have a link "Add Installer" to add installer.
Click the link and few moments later, .net IDE will have "ProjectInstaller.cs" file in the solution explorer.
This installer will have two components: "serviceProcessInstaller1" and "YOUR_SERVICE_NAME_Installer"
Right click on "serviceProcessInstaller1" and select Properties.
One of the properties for this object of type "ServiceProcessInstaller" is Account. This is an enumerated list containing "LocalService", "NetworkService", "LocalSystem" and "User". Select "User" from this drop-down.
Then you'll have to programmatically edit the "UserName" and "Password" properties for serviceProcessInstaller1 as neither username nor password are visible in propertie page.

hope this helps
0
 
LVL 5

Assisted Solution

by:AdrianJMartin
AdrianJMartin earned 50 total points
Comment Utility
During Development -- Create the installer once and install it, set the password and username etc. But instead the uninstall/reinstall : Stop the service, and copy or move the executable( and other assemblies (dlls/exes)) from the Debug or Release folder to the programs install location Program Files->Company Name->application or whatever the installer is set to place it. Restart the service. Much quicker then unstalling and reinstalling.......
0
 
LVL 5

Author Comment

by:knowlton
Comment Utility
actually....I have the uninstall and install running in a batch file......works pretty fast.
0
 
LVL 5

Author Comment

by:knowlton
Comment Utility
malharone:  Your suggestion worked just fine.  I no longer have to provide UserName and Password.....very nice.....that was getting a bit tedious.

Tom
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now