Connecting Tech Pros Worldwide Forums | Help | Site Map

Windows Service having UI form

Asutosha's Avatar
Newbie
 
Join Date: Sep 2007
Posts: 2
#1: Nov 17 '08
Hi,
i want to create a Windows Service which will starts autometically when windows OS starts.
it will show a Login form.
if you give correct username and password it will do nothing
else
if will delete a pre-define folder..

i search in the website and codeproject also.
i di not find any proper solution, please some one help me to solve this problem.

regards
Asutosha

balabaster's Avatar
Moderator
 
Join Date: Mar 2007
Location: Canada
Posts: 757
#2: Nov 17 '08

re: Windows Service having UI form


There are a couple of things you have to do here - you have to set up the service so that it can interact with the desktop. This is done in the service applet in Control Panel/Administrative Tools.
  • Double click the service to open it
  • Select the Log On tab
  • Make sure the service is set to "Local System Account" (otherwise it cannot interact with the desktop"
  • Check "Allow service to interact with desktop"

Now, in your service onstart event, new up your login form:

Expand|Select|Wrap|Line Numbers
  1. Dim MyLoginForm as new frmLogin '(or whatever its called)
  2. Dim ValidUser As Boolean = False
  3.  
  4. If MyLoginForm.ShowDialog() = vbOK Then
  5.        'Check username/password, set ValidUser
  6. End If
  7.  
  8. If Not ValidUser Then
  9.       'Do what you have to in order to delete the folder
  10. End If
  11.  
  12. MyLoginForm.Close
Reply