Spawning exe under different user name not working

K

kris_scheyer

Hi,

I have a little .exe file that I want the C# code behind of my web
application to execute as a different user. The executable is supposed
to take a screenshot of the server's display and save the image and it
has to be run under the currently logged on user otherwise the
generated image just turns out black.

My problem is when I click the button on the browser thats supposed to
run the exe file a message box appears on the server saying that the
file failed to initialise properly:

The application failed to initialize properly (0xc0000142). Click on OK
to terminate the application.

That's the exact error message I'm getting with no other details. I've
tried giving the ASP account on the server full permissions with no
luck. The user account that is currently logged on, which is the user
account the exe is supposed to run under has full permissions as well.

What I'm using is ASP.Net2.0 and the new ProcessStartInfo.UserName and
ProcessStartInfo.Password arguments to run the exe under a different
user account.

If anyone has any alternative solutions on how to get this done or know
any way to fix this please let me know.

Thanks!

Kris
 
G

Guest

You are trying to execute an EXE on the Client?
Good luck. Seriously though, the only way you are going to be able to do
this is to either cripple the security on the client or have them install a
Component of some sort.
If you need a screenshot of the client you will have to ask the client to do
this and then upload it... you cant really automate this.
 
D

Damien

Hi,

I have a little .exe file that I want the C# code behind of my web
application to execute as a different user. The executable is supposed
to take a screenshot of the server's display and save the image and it
has to be run under the currently logged on user otherwise the
generated image just turns out black.

My problem is when I click the button on the browser thats supposed to
run the exe file a message box appears on the server saying that the
file failed to initialise properly:

The application failed to initialize properly (0xc0000142). Click on OK
to terminate the application.

That's the exact error message I'm getting with no other details. I've
tried giving the ASP account on the server full permissions with no
luck. The user account that is currently logged on, which is the user
account the exe is supposed to run under has full permissions as well.

What I'm using is ASP.Net2.0 and the new ProcessStartInfo.UserName and
ProcessStartInfo.Password arguments to run the exe under a different
user account.

If anyone has any alternative solutions on how to get this done or know
any way to fix this please let me know.
Hmm. Unfortunately, that error is kindof generic, and may not help us
much with diagnosis. A route I might take in attempting to do this
would be to create a "Snapshot" service that is permanently running,
and has an open socket. When the website wants to cause the snapshot,
it connects to the socket and instructs the service to perform the
snapshot (possibly passing parameters such as a destination filename,
etc). This also allows the possibility that the service can decide on
snapshot names and pass the data back.

The socket approach may not be necessary - it's possible to use other
techniques/technologies to achieve the same aims - For instance, I've
not done anything yet with Remoting, but I believe that it would be a
possibility.

A final note - be VERY careful with this. Have you fully considered the
security implications of allowing any random person who connects to
your site being allowed to snapshot the current users desktop (and view
the resulting image?)

Damien
 
K

kris_scheyer

No no no! The exe is executed on the server. The client just clicks a
button on the webform to start the program on the server. I tried to be
as clear as possible but again what im trying to do is this:

An executable file on the server is supposed to capture the screen of
the server.
The executable file is launched from c# code of the web application.
(which is stored on the server)
All the client does is access the web page and click a button that
tells the c# code to execute this file on the server.

There i hope thats a bit clearer. And the problem I am having with this
is that when the exe is run (on the server) it immedialtely crashes and
displays the above error message (on the server).
 
K

kris_scheyer

Thanks Damien, the thought of having a service that listens for socket
connections and takes screenshots on command on the server has crossed
my mind and I'm thinking of saving that for last if nothing else works.

As for security the web application has a login page so only authorized
users will be able to get images of the server's display and the web
app will be running on the company intranet.

Kris
 
K

kris_scheyer

Thanks Damien, the tought of running a service that listens for socket
connections and takes screen captures has crossed my mind but I want to
save that for last if all else fails.

Also the web app will be running on the company intranet and will have
a login page to only allow authorized users to access this.

Kris
 
B

Bruce Barker

you problem is that any process spawned by asp.net (or any service) does not
have access to the desktop, so it can not snapshot the screen.

the best approach is to create a nt service, and setup the service
permission to allow access to the desktop (requires running the sevice as
local systemn account and checking interact with desktop in service
properties). then use remoting from the asp.net page to call the service.

-- bruce (sqlwork.com)
 
K

kris_scheyer

Yeah I just found that out the long way.. i changed the user the asp
worker process runs under to the logged on user.. the application I'm
trying to spawn runs but doesn't have access to the desktop. Spawning
an application or running code on the server that sends a print screen
keypress doesn't seem to work as well. I guess I'll just make a service
to do this for me.

Thanks guys!

Kris
 

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,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top