Based on my experience from about 1999, running Excel from a service
is a solution in search of a bunch of problems. I did it
for WebTrends/NetIQ but it was tricky.
The issues you have to deal with are:
1) Hidden desktop/new user issues... If you try to run Excel from a
service there is a good chance that Excel will put up "new-user"
dialogs in a hidden desktop. I had to fool Excel into thinking that
the user was not new by tweaking 'secret' registry keys discovered
by trial and error. The system account that you normally would be
using as a service shows its dialogs in a hidden desktop.
Those "new-user" dialogs appearing in the hidden desktop caused
serious pain. That's why running Excel this way was not recommended
by Microsoft at that time (and probably still isn't).
2) Windows impersonation; which I have not tried with .NET. You'd
have to assume that the user has installed Excel and run it before
that you could be sure your automation would work (unless Excel now
supresses the new user dialogs when automated).
--- In padnug@xxxxxxxxxxxxxxx, "David Cramer" <d_m_cramer@xxxx>
wrote:
> Hi,
>
> I am fairly new to dotnet and windows services so I apologize if
this is
> something you all have already discussed.
>
> I need to start and stop Excel from a windows service. My service
is working
> just fine reading/writing files and other basic tasks. However,
when the
> excel application is created, my service tries to install Excel
when it is
> run as "LocalSystem". When I run it as a user with administrative
privileges
> an error is returned (the error says that no error was returned
but an error
> occurred). I am using C#, .NET 1.1 on windows 2000.
>
> protected override void OnStart(string[] args)
> {
> Excel.Application xl = new Excel.Application (); // code
stops here,
> excel application never created
> // do something, exit excel, clean up
> ...
> }
>
> Is it not possible to start Excel from a Windows Service? I have
tried
> everything I can think of on the adminstration side, now I am
trying to
> solve this programmatically. I have this same code in another
application
> and it works just fine. The UI doesn't come up and isn't needed.
Has anyone
> encountered this problem or have any suggestions?
>
> Thanks
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/dpFolB/TM
--------------------------------------------------------------------~->
|