By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,732 Members | 1,388 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,732 IT Pros & Developers. It's quick & easy.

Shell from Timer.Elapsed in Windows Service?

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.