473,592 Members | 2,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Nor malFocus.

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

I've tried Diagnostics.Pro cess 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.Pro cess 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.Nor malFocus and for
the Diagnostics.Pro cess approach I set StartInfo.Windo wStyle =
ProcesssWindowS tyle.Normal.

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

Rob.
Jul 7 '06 #1
3 1920
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*****@pacbel l.netwrote in message
news:O1******** ******@TK2MSFTN GP04.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.Nor malFocus.

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

I've tried Diagnostics.Pro cess 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.Pro cess
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.Nor malFocus and for the Diagnostics.Pro cess approach I set
StartInfo.Windo wStyle = ProcesssWindowS tyle.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.Nor malFocus.

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

I've tried Diagnostics.Pro cess 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.Pro cess 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.Nor malFocus and for
the Diagnostics.Pro cess approach I set StartInfo.Windo wStyle =
ProcesssWindowS tyle.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.m icrosoft.comwro te in
message news:2F******** *************** ***********@mic rosoft.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.Nor malFocus.

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

I've tried Diagnostics.Pro cess 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.Pro cess
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.Nor malFocus and
for
the Diagnostics.Pro cess approach I set StartInfo.Windo wStyle =
ProcesssWindow Style.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
1488
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, in the handling thread - I am assuming that the elapsed handler is running on a separate thread from the main one - if an exception occurs, it seems to be lost. The exception is not propagated up the chain where the service with AutoLog set to...
2
2077
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? Thanks, Rajesh Abraham -----Code Below------
2
5148
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 I am new to this. Full code below : using System; using System.Collections; using System.ComponentModel;
2
4048
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: The MyService service on Local Computer started and then stopped. Some services stop automatically if they ahve no work to do, for example, the Perforamnce Logs and Alert service. I tried switching to a System.Threading.Timer and that didn't work...
1
3944
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 the tick event does not fire! I tried this other method but the elapsed event does not fire. ---------- Private WithEvents MyTmr As New System.Timers.Timer(1000) Private Sub MyTmr_Elapsed(ByVal sender As Object, ByVal e As
2
1682
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 IE. IE launches OK but crashes when the verb is invoked. Does anybody know how to do a shell print command in IE 6? When I specifically states to open the file using Acrobat, it opens in IE anyway. Code follows: Dim objProcess As...
5
12204
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 event handlers may take longer than the interval for either of the timers, so it's possible for multiple events to fire "simultaneously" and for events to queue up. I'm attempting to get the timers to sync on some reference type object, or use...
10
4274
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 will stop executing after 30 to 40 days. After learning this, I found the same issue had been documented in the the System.Threading.Timer class as well. This limits my options for having a timer based windows service using the .net framework....
8
3363
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 on a network for files and then copies these files to another location (on the network) AND then updates a record in the database. The file copying is performed before the database update because the file system is not transactional. The code...
0
7935
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7871
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8227
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6642
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3893
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2379
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1202
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.