Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem with Windows Service Project

Posted on 2006-11-16
9
Medium Priority
?
332 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 15

Expert Comment

by:ozymandias
ID: 17960897
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
ID: 17961159
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
ID: 17961312
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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

Author Comment

by:cityofcocoabeach
ID: 17967028
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
 
LVL 15

Expert Comment

by:ozymandias
ID: 17967161
>>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
ID: 17967361
>>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
ID: 17968309
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
ID: 18012828
Closed, 500 points refunded.
PashaMod
Community Support Moderator
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

610 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