Executing a program

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

I am trying to execute a program from my web page on a 2003 server.

Both the program and the web application are on the same server.

The program normally runs as a scheduled task but we need to allow the
inhouse users to be able to manually start the program which just reads a
file and fills various tables with it.

When I run it on my workstation, it works fine. We have a user defined to
run the program and I am using impersonation to run the program.

The problem is that it doesn't seem to execute on the server.

Is there something special I need to set up this up?

My code to execute the program is (with program containing the path and
executable name):

// Impersonate, automatically release the impersonation.

using (new Impersonator("User", "server", "password"))
{
Process p = new Process();
p.StartInfo.FileName = program;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = false;
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
p.Start();
}

This runs on my laptop running IIS without any problem (without the
impersonation).

Thanks,

Tom
 
The errors I am getting in the event log are:



Event Type: Error

Event Source: .NET Runtime 2.0 Error Reporting

Event Category: None

Event ID: 5000

Date: 10/13/2009

Time: 3:29:24 PM

User: N/A

Computer: OBERON

Description:

EventType clr20r3, P1 autoups.executable.exe, P2 1.0.0.0, P3 4ad3e1e5, P4
autoups.executable, P5 1.0.0.0, P6 4ad3e1e5, P7 1, P8 5f, P9
system.typeinitialization, P10 NIL.



Event Type: Error

Event Source: VsJITDebugger

Event Category: None

Event ID: 4096

Date: 10/13/2009

Time: 3:29:29 PM

User: NT AUTHORITY\NETWORK SERVICE

Computer: OBERON

Description:

An unhandled exception ('System.TypeInitializationException') occurred in
AutoUPS.Executable.exe [3692]. Just-In-Time debugging this exception failed
with the following error: Debugger could not be started because no user is
logged on.



Thanks,



Tom
 
tshad said:
I am trying to execute a program from my web page on a 2003 server.

Both the program and the web application are on the same server.

The program normally runs as a scheduled task but we need to allow the
inhouse users to be able to manually start the program which just reads a
file and fills various tables with it.

When I run it on my workstation, it works fine. We have a user defined to
run the program and I am using impersonation to run the program.

The problem is that it doesn't seem to execute on the server.

Is there something special I need to set up this up?

I would suggest looking up how to make an ASP.NET UI call a Windows NT
Service and have the code in the WS or make the WS execute the exe in
question.


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4504 (20091013) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
while the thread starting a process needs enough permission to start
one, the new process will not run as the thread impersonation account,
but rather as the process owner account (probably system on your
workstation, but locked down on the server).

you probably need the program to do the impersonation, also the default
dir will be system32, not the vdir.

-- bruce (sqlwork.com)
 
Actually, there is exception handling in it.

It seems to happen when trying to start the program before it gets to my
TRY.

On the web side, it just starts the program and goes on and assumes it
started fine.

Tom

Mark Rae said:
Event Source: .NET Runtime 2.0 Error Reporting
Event Source: VsJITDebugger
An unhandled exception ('System.TypeInitializationException') occurred in
AutoUPS.Executable.exe [3692]. Just-In-Time debugging this exception
failed with the following error: Debugger could not be started because no
user is logged on.

Pretty self-explanatory - "an exception has occurred but you don't have
any exception handling in your code so I can't tell you about it and
instead I'm going to try to launch the JIT Debugger so you can investigate
but unfortunately no user is logged for me to do this".

Put some exception handling in your code, find the error, and then fix
it...
 
Mr. Arnold said:
I would suggest looking up how to make an ASP.NET UI call a Windows NT
Service and have the code in the WS or make the WS execute the exe in
question.

Actually, I will just have change the program to run as a WS and handle it
from there.

Thanks,

Tom
 
bruce barker said:
while the thread starting a process needs enough permission to start one,
the new process will not run as the thread impersonation account, but
rather as the process owner account (probably system on your workstation,
but locked down on the server).

you probably need the program to do the impersonation, also the default
dir will be system32, not the vdir.
Not sure how I would do that.

I am not running as a thread. I thought that Process would start a new
process to run by itself. How would you give the credentials to the process
(.exe) that would allow it to run.

We already set up a specific User with enough permissions to run. And it
works fine on my desktop machine, just won't work on the Server.

Thanks,

Tom
 
Back
Top