Trouble starting process from IIS

M

Mike

Inside a HttpHandler I'm trying to spawn an EXE (console app).
Although it shows up in the process list, it doesn't seem to do
anything. (And even if I specify ProcessWindowStyle.Normal, it doesn't
show the cmd.exe box.) I've tried with and without UseShellExecute, and
even using "cmd.exe /c myprog.exe myargs..."
Launching the process from a seperate project (not IIS) seems to work
fine.
Is this a permissions issue? (Though as I said, it does actually start
the process.) Any thougts?

thanks,
mike
 
J

John Timney \(ASP.NET MVP\)

Your web application has no concept of a desktop, so has no where to create
your exe window.

When you spawn exe's from asp.net you have to ensure they have no window -
or setup your web system to run as a user with a profile somehow.......time
for some fishing about on google methinks.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
M

Mike

Well, I don't *want* the window (I want it hidden anyway, I was just
using Normal as a debugging aid, which appears to have been misguided).

I want the app for its side-effect (creating some files) -- If there's
any stdio in this app., I'm free to ignore it.
Are you saying it should be a WinForm app with no .Show, as opposed to
a console app. which as a by-product creates a dos-box?
(I don't have the source at the moment.)
BTW, I did RTFM and Google before posting and didn't see much, though I
could have missed something -- if you have specified pointers, please
let me know.

thanks
 
M

Mike

BTW, it also turns out that the EXE creates a (hidden) IE control
instance to do it's work.
So, even if I don't use and EXE and code what's in the EXE directly in
code-behind, is that going to be an issue becuase the IE control has
hidden windows and expects an event loop even when hidden?
 
M

Mike

I found this, which doesn't look promising:

"Don Kiely recently pointed to an article on CodeProject with C# code
to run a process in a new security context. The code PInvokes
CreateProcessWithLogonW, but doesn't work under ASP.NET.

CreateProcessWithLogonW is one of those tricky APIs that doesn't pick
up and move well from one environment to the next. Unfortunately, there
is no way with .NET 1.1 to start a new process under alternate
credentials without PInvoke. A spawned process always inherits the
token of the creator process, so even if a thread is impersonating when
it calls Process.Start, the new process always has the same identity of
the current process. The good news is that Microsoft makes it easy in
..NET 2.0. "

I can't beleive this isn't a solved problem...
 
S

Scott Allen

Hi Mike:
I can't beleive this isn't a solved problem...

It is sort of a rare problem. Did we talk before about this topic? I
seem to remember pointing you to some code.
 
M

Mike

No, I don't think you've helped me with this before...
Why is it always the "rare" problems that appear after only 10 lines of
code?...

This article you pointed me to seems similar, but not identical, to:
http://support.microsoft.com/?id=306158
Which didn't work. (The loginAsUser called failed -- but it could be
becuase my test machine in not part of any domain.)
I'll give this a try.

I'm thinking about switching gears completely, and instead of launching
a process from IIS doing the following: Adding a entry to a SQL server
table which is a command queue, then having one-of-N macines remove an
entry, spawn the worker process, and stick results back on the
filesystem of the requesting machine, and having the server continue
after the file is ready. This way the IIS processes doesn't have to
start a process or access an external file -- the worker machine writes
back to the server. (Sounds like a good candidate for Asp.net 2.0 async
pages when they are available.)
Do you see any problems with this plan? Does remote resource access
needing delegation only appear for a \\share\dirve, or does a
letter-mounted drive appear still count as "remote"?

thanks,
m
 
S

Scott Allen

No, I don't think you've helped me with this before...
Why is it always the "rare" problems that appear after only 10 lines of
code?...

This article you pointed me to seems similar, but not identical, to:
http://support.microsoft.com/?id=306158
Which didn't work. (The loginAsUser called failed -- but it could be
becuase my test machine in not part of any domain.)
I'll give this a try.

I'm thinking about switching gears completely, and instead of launching
a process from IIS doing the following: Adding a entry to a SQL server
table which is a command queue, then having one-of-N macines remove an
entry, spawn the worker process, and stick results back on the
filesystem of the requesting machine, and having the server continue
after the file is ready. This way the IIS processes doesn't have to
start a process or access an external file -- the worker machine writes
back to the server. (Sounds like a good candidate for Asp.net 2.0 async
pages when they are available.)
Do you see any problems with this plan? Does remote resource access
needing delegation only appear for a \\share\dirve, or does a
letter-mounted drive appear still count as "remote"?

Yes, a mapped drive will still appear as remote - what's worse is
mapped drives aren't loaded for most background processes and service
- only for the interactive user.

Switching gears once again - how about running in a COM+ server
package. There you can run with a fixed identity easily by deriving
from ServicedComponent.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top