473,289 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

Shell from Timer.Elapsed in Windows Service?

I have a Windows Service with a timer that use the .NET 2.0 Shell command.
The Shell command returns a non-zero number but Task Manager shows the
shelled exe running but there is NO visible interface (there should be
one) -- I pass AppWinStyle.NormalFocus.

If I execute the exact same in a Windows form test app, the Shell works
flawlessly.

I've tried Diagnostics.Process approach rather than Shell but have the same
results -- my app appears to run but with no visible interface??

If I run my shelled app stand alone it works fine.

Is there some kinda bizarre problem with Shell or Diagnostics.Process where
it can't be executed in timer.elapsed event due to some threading conflicts
or something? Shell is asynchronous (not wait or timeout value set) so I
don't think this would be any issue at all.

I've done the usual diagnostics and put in trace code that is logged to my
event log and following execution of both my service code and shelled app --
all indicates functioning correctly, just no visible interface (form will
not show). Like I said for Shell I've got AppWinStyle.NormalFocus and for
the Diagnostics.Process approach I set StartInfo.WindowStyle =
ProcesssWindowStyle.Normal.

I'm at a complete stand still -- Any suggestions?

Rob.
Jul 7 '06 #1
3 1866
It's because it is running as a service. Services are not being run on your
active desktop :)

There are some hacks you can implement to allow this to happen (such as
connecting to the existing desktop or *argh* enabling desktop interaction)
but I highly recommend not doing these things. If a service needs a GUI or
to spawn a GUI, that part of the service should probably not be a service.
As an example what happens when the service wants to spawn this GUI but
there is no logged in user?

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
"Rob R. Ainscough" <ro*****@pacbell.netwrote in message
news:O1**************@TK2MSFTNGP04.phx.gbl...
>I have a Windows Service with a timer that use the .NET 2.0 Shell command.
The Shell command returns a non-zero number but Task Manager shows the
shelled exe running but there is NO visible interface (there should be
one) -- I pass AppWinStyle.NormalFocus.

If I execute the exact same in a Windows form test app, the Shell works
flawlessly.

I've tried Diagnostics.Process approach rather than Shell but have the
same results -- my app appears to run but with no visible interface??

If I run my shelled app stand alone it works fine.

Is there some kinda bizarre problem with Shell or Diagnostics.Process
where it can't be executed in timer.elapsed event due to some threading
conflicts or something? Shell is asynchronous (not wait or timeout value
set) so I don't think this would be any issue at all.

I've done the usual diagnostics and put in trace code that is logged to my
event log and following execution of both my service code and shelled
app -- all indicates functioning correctly, just no visible interface
(form will not show). Like I said for Shell I've got
AppWinStyle.NormalFocus and for the Diagnostics.Process approach I set
StartInfo.WindowStyle = ProcesssWindowStyle.Normal.

I'm at a complete stand still -- Any suggestions?

Rob.

Jul 7 '06 #2
That is probably because the shelled application runs under the same user
account as the service, and not the user account of the logged on user.
Maybe you can try to run the service with the same user account with which
you are logged on and see if that helps?

Joris

"Rob R. Ainscough" wrote:
I have a Windows Service with a timer that use the .NET 2.0 Shell command.
The Shell command returns a non-zero number but Task Manager shows the
shelled exe running but there is NO visible interface (there should be
one) -- I pass AppWinStyle.NormalFocus.

If I execute the exact same in a Windows form test app, the Shell works
flawlessly.

I've tried Diagnostics.Process approach rather than Shell but have the same
results -- my app appears to run but with no visible interface??

If I run my shelled app stand alone it works fine.

Is there some kinda bizarre problem with Shell or Diagnostics.Process where
it can't be executed in timer.elapsed event due to some threading conflicts
or something? Shell is asynchronous (not wait or timeout value set) so I
don't think this would be any issue at all.

I've done the usual diagnostics and put in trace code that is logged to my
event log and following execution of both my service code and shelled app --
all indicates functioning correctly, just no visible interface (form will
not show). Like I said for Shell I've got AppWinStyle.NormalFocus and for
the Diagnostics.Process approach I set StartInfo.WindowStyle =
ProcesssWindowStyle.Normal.

I'm at a complete stand still -- Any suggestions?

Rob.
Jul 7 '06 #3
Even if the service runs as the logged in user, it won't display the app on
the desktop.

If you're wanting to launch an application that the user of the computer is
going to interact with, a Windows Service is not the way to go.

"Joris Zwaenepoel" <Jo*************@discussions.microsoft.comwrote in
message news:2F**********************************@microsof t.com...
That is probably because the shelled application runs under the same user
account as the service, and not the user account of the logged on user.
Maybe you can try to run the service with the same user account with which
you are logged on and see if that helps?

Joris

"Rob R. Ainscough" wrote:
>I have a Windows Service with a timer that use the .NET 2.0 Shell
command.
The Shell command returns a non-zero number but Task Manager shows the
shelled exe running but there is NO visible interface (there should be
one) -- I pass AppWinStyle.NormalFocus.

If I execute the exact same in a Windows form test app, the Shell works
flawlessly.

I've tried Diagnostics.Process approach rather than Shell but have the
same
results -- my app appears to run but with no visible interface??

If I run my shelled app stand alone it works fine.

Is there some kinda bizarre problem with Shell or Diagnostics.Process
where
it can't be executed in timer.elapsed event due to some threading
conflicts
or something? Shell is asynchronous (not wait or timeout value set) so I
don't think this would be any issue at all.

I've done the usual diagnostics and put in trace code that is logged to
my
event log and following execution of both my service code and shelled
app --
all indicates functioning correctly, just no visible interface (form will
not show). Like I said for Shell I've got AppWinStyle.NormalFocus and
for
the Diagnostics.Process approach I set StartInfo.WindowStyle =
ProcesssWindowStyle.Normal.

I'm at a complete stand still -- Any suggestions?

Rob.

Jul 7 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jiho Han | last post by:
I have a windows service that creates and starts a timer. And when the timer has elapsed, it performs a few things and resets the timer. (AutoReset = false, so it only executes once). However,...
2
by: Rajesh Abraham | last post by:
I have a timer in my Windows Service project and I am trying to do some processing on the tick event of the timer but this event does not seesms to be raised. Below is some code segment. Any Idea?...
2
by: Besta | last post by:
Hello all, I am having trouble creating a windows service with a timer. Everything seems to go ok but the elapsed event does not fire.Can anyone shed any light on this, may be something simple as...
2
by: John David Thornton | last post by:
I've got a Windows Service class, and I put a System.Threading.Timer, and I've coded it as shown below. However, when I install the service and then start it in MMC, I get a peculiar message: ...
1
by: Manuel | last post by:
Used VS2005 to create a windows service and I can't make a timer trigger the tick/elapsed event. On the form viewer I dragged a timer from the components section of the toolbar, enabled it but...
2
by: Glenn Venzke | last post by:
I'm trying to print an Adobe forms file (.fdf) using system.diagnostics.process in a windows service. The problem is, IE is the program that launches that file type & Verb = "Print" doesn't work in...
5
by: Tony Gravagno | last post by:
I have a class that instantiates two Timer objects that fire at different intervals. My class can be instantiated within a Windows Form or from a Windows Service. Actions performed by one of the...
10
by: igor | last post by:
I have recently discovered that the system.Timers.Timer from.Net Framework v1.1 is not reliable when used on Windows 2003 server. When incorporated into a Windows Service, the timer_elapsed event...
8
by: Ollie Riches | last post by:
I'm looking into a production issue related to a windows service and System.Timers.Timer. The background is the windows service uses a System.Timers.Timer to periodically poll a directory location...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.