Solved

Problem with Windows Service Project

Posted on 2006-11-16
9
317 Views
Last Modified: 2008-02-01
I’ve created a C# Windows Service project whose service main function instantiates a class library that spawns a new thread to create a new process with which to launch osk.exe (the Windows on-screen keyboard).  The purpose for creating this service is to have the on-screen keyboard appear immediately after startup (before the login screen) on a system that will have no keyboard hardware.

I had first built a test program (C# console application) to call the class library and test its functionality and it worked fine.  Then I created the Service Project including its installer classes and installed the service with installutil.  [Incidentally, all three projects—the class library that launches the osk in a new thread, the test console application, and the windows service—are in the same solution.]

Each time I manually start the service (using the MMC snap-in) I get the following message:
" The service <name> on Local Computer started and then stopped.  Some services stop automatically if they have no work to do…"

Strange... The class library contains the necessary start and stop methods, and I copied the same code from the test program to the OnStart () method of the service class. Can anyone help?
0
Comment
Question by:cityofcocoabeach
9 Comments
 
LVL 15

Expert Comment

by:ozymandias
Comment Utility
I don't think you can do this.

You can create a service from any executable using the sc command :

sc create OnScreenKeyboard binpath= c:\windows\system32\osk.exe

This will create a service based on the on screen keyboard.
You can then go into the service control snap-in and set it to interact with the desktop, start automatically etc
However, even when you start the service its status never gets passed starting, even theough the keyboard appears and eventually it will just quit.
0
 
LVL 15

Expert Comment

by:ozymandias
Comment Utility
If all you ned to do is display the osk at logon/startup there are two methods detailed here :

Starting On-Screen Keyboard Automatically When Windows Starts
http://www.microsoft.com/enable/training/windows2000/startkeyboard.aspx

Also, check out the accepted answer here......
http://www.experts-exchange.com/Operating_Systems/Q_21998064.html?query=osk&clearTAFilter=true
0
 
LVL 14

Expert Comment

by:existenz2
Comment Utility
The Windows Service needs to have the appriorate rights to execute the osk.exe. Most likely it doesnt have them. If it tries to runs under the User account you also need to be logged in to get it to work.
0
 

Author Comment

by:cityofcocoabeach
Comment Utility
Thank you both for responding.

Ozymandias,
The first link doesn't work for us since the Option described doesn't exist on Windows XP.
Also, we had tried the steps mentioned in the other link, but it's not working for us.  I can successfully get the osk to appear before the log-in but after logging in using the osk, the osk is no longer visible although a look at the running processes shows it running under the system account.  I can only get it to appear by typing CTRL+ALT+DEL with an external keyboard. ?!?
Even so, it goes away when logging off, so I'm forced to use an external keyboard to log in after which it reappears but this time running under my user account.

This is the reason I'm attempting to create a proper service application that will startup and persist unlike with the sc.exe option.
I've succeeded in getting the service (that launches the osk) to start and stop successfully, but the osk still shuts down when logging off.  A post in another forum suggested the application may be displaying on the wrong WinStation, but I'm not sure what this is about.  Any ideas?
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 15

Expert Comment

by:ozymandias
Comment Utility
>>The first link doesn't work for us since the Option described doesn't exist on Windows XP.
Yes it does...or at least it does in my windows xp.
If you have a "windows" key on your keyboard (the one with the little windows flag) hold it and "u" down togetehr and you will get the dialog up that allows you to set that option.

No other ideas at present I'm afraid, unless you write your own osk program that behaves properly and doesn't shut down all the time.

0
 

Author Comment

by:cityofcocoabeach
Comment Utility
>>Yes it does...or at least it does in my windows xp.

The only options I have are:
Start automatically when I log in
Start automatically when I lock my desktop
Start automatically when Utility Manager starts

All of these require some keyboard strokes before the osk appears.
Thanks anyway.
0
 

Author Comment

by:cityofcocoabeach
Comment Utility
Found a solution…

It appears the process of logging off kills any non-service type processes, even though it was spawned by a service which is still running.  Now I’m having the service poll the running process at regular intervals to see if the osk was exited by other than the service itself, and if so restart it.  
0
 

Accepted Solution

by:
PashaMod earned 0 total points
Comment Utility
Closed, 500 points refunded.
PashaMod
Community Support Moderator
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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

8 Experts available now in Live!

Get 1:1 Help Now