Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application Launches from Scheduled Task but not a Win Service

Status
Not open for further replies.

becks774

Programmer
Jun 25, 2007
14
Hello All,

My requirement is to launch a 3rd party application providing that application with a file name in its command line so it can process it whenever a file gets drop in a specific directory.

I wrote a windows service to watch the directory then launch the 3rd party application with file creates. But the 3rd party application does not run. In testing and running out of options, I decided to test the code to see if it would run as a Scheduled Task to see if it would launch and it did. Does anyone know why it would launch as a Scheduled Task but not from a Windows Service?

Any input or ideas around this (cause I still haven't figured out how I am going to solve this) would be greatly appreciated!
Thanks in advanced!
Becca
 
Services cannot interact with the desktop. This is because they start before anyone logs into the computer, and so there's no desktop for them to run on. There is an exception to this rule, and Microsoft regrets ever allowing it. Be looking for it to be closed in a future Windows or service pack release.

One other thing is that by default, Windows Services run as either LocalSystem or LocalService, and the permissions for those accounts are pretty restrictive.

(don't change permissions for those accounts -- you'll be opening yourself up for attack. Instead create a new user that has just the permissions you need)

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Hi Chip,

Thanks for responding!

I use a service account so I can control the permissions rather than the built in accounts. The service account is an admin on its box and the other application and all files are also on that same box.

What is odd is that you can see the service opens the application in task manager, it just hangs at that point in time. We have created other services that ran other applications without problem.

Thanks!
Becca
 
Are you using Process.Start() to launch the third party app? If so, you can try launching it under a different user account. Be aware though that this could be a security risk to have a username/password hard-coded into the application.
 
Hi RiverGuy,

Thanks for the suggestion! I'll give it a try.

I have tried Process.Start, Shell and creating a bat file to launch the app and running that. Same result with all three.

Becca
 
My guess is the third party app has a dialog open waiting for the user to click "OK". And since this is happening on a restricted WindowStation/Desktop (which is how Microsoft got around the security flaw of allowing a program running under another account to interact with *your* desktop), you are not able to see it nor click on it.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top