Please help...

  • Thread starter Thread starter adish11
  • Start date Start date
A

adish11

I use Web Application, that stored on some server.

I need to run other application with arguments from the code that stored
on same server with the application. Instead of using command line I need
to run this application from the code.

Can you give me code lines how to run applicaion from the code?

I tried to use System.Diagnostics.Process but it didn't work.

Thanks for your answer.
 
adish11 said:
I use Web Application, that stored on some server.

I need to run other application with arguments from the code that stored
on same server with the application. Instead of using command line I need
to run this application from the code.

Can you give me code lines how to run applicaion from the code?

I tried to use System.Diagnostics.Process but it didn't work.

It would help if you'd show how you tried to use
System.Diagnostics.Process and in what way it didn't work.
 
Let me understand correctly... you want a web application to trigger a
command line application on the same machine. You tried
System.Diagnostics.Process to start the command line application, but it did
not work.

Is this a correct statement of your problem?

You are probably getting a permissions issue. The web application does not
run as a trusted user on your server, and has some fairly limited
capabilities.
We may be better able to help you if you follow Jon's advice, and post the
error message and the code where you attempted to start to other process.

Note: if the application you are trying to start is a windows application, I
would suggest that you need to find another way... the user interface for
the windows application would appear on the console if anyone is logged in
(if you are lucky). Dialog boxes would wait for human input on an
unattended machine, and your web application would freeze up. This is not
reliable.

I hope this helps and I look forward to seeing your follow up post.

--- Nick
 
adish11 said:
I use Web Application, that stored on some server.

I need to run other application with arguments from the code that stored
on same server with the application. Instead of using command line I need
to run this application from the code.

Can you give me code lines how to run applicaion from the code?

I tried to use System.Diagnostics.Process but it didn't work.

Thanks for your answer.

I do something like that in a web application that required PGP. I decided
to use GnuPG ( www.gnupg.org ) which is a line command exec. I found a
class that someone had written that encapsulated the command with it's
switches and turned them into methods. Here's the article and download.

http://www.codeproject.com/csharp/gnupgdotnet.asp

I found that when I implemented this code I needed to make sure that the
ASPNET account was on the subdirectory that the .exe was installed in.

Also, look at his code for how to trap errors from the line command.
 
Hi,

The code as I tried in different versions:

Ver #1:
System.Diagnostics.ProcessStartInfo startupInfo = new
System.Diagnostics.ProcessStartInfo();

startupInfo.FileName = "C:\\psexec.exe";
startupInfo.Arguments = "\\toc2";

startupInfo.UseShellExecute = false;
System.Diagnostics.Process process =
System.Diagnostics.Process.Start(startupInfo);


Ver #2:
Process p = new Process();
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "C:\\psexec.exe";
p.Start();

Ver #3:
System.Diagnostics.Process.Start("C:\\psexec.exe");

Can you see where can be my error?

Thanks for helping me
 
Hi,

The code as I tried in different versions:

Ver #1:
System.Diagnostics.ProcessStartInfo startupInfo = new
System.Diagnostics.ProcessStartInfo();

startupInfo.FileName = "C:\\psexec.exe";
startupInfo.Arguments = "\\toc2";

startupInfo.UseShellExecute = false;
System.Diagnostics.Process process =
System.Diagnostics.Process.Start(startupInfo);


Ver #2:
Process p = new Process();
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "C:\\psexec.exe";
p.Start();

Ver #3:
System.Diagnostics.Process.Start("C:\\psexec.exe");

Can you see where can be my error?

Thanks for helping me
 
Hi Nick,
Yes, you understood my problem correctly.

I'll try to describe you my work environment:

Client works on one machine, web application runs on other(second) machine
and there on more machie(third), where stored batch file that I need to
activate.
All the machines are at the same network.

By running the application I want to run Psexec application that stored on
the same second machine with the application.

PsExec is a light-weight telnet-replacement that lets execute processes
on other systems,I need to run this application with arguments to run
remote file that stored on third machine in the network.
http://www.sysinternals.com/ntw2k/freeware/psexec.shtml

I hope you understood my environment.

While ruuning the code I don't get any exeptions but the file not being
executed.I tried it also with other application like calc.exe or
notepad.exe ,but nothing happends.

The strange thing is that I tried to run same code on Windows Application
and it works fine there.

Do you think it's a permission problem?

Thank you very much for you help
 
The responder "Donny Darko" did a good job of pointing you to a sample that
can show you how to fix this problem.

You need to make sure that the ASPNET account that is running the web
application has the ability to execute the PSEXEC application that you refer
to.

If this is not working for you, an alternative is to tell your web
application that it should impersonate a particular web user (which can be
done in the web.config).

As another alternative, you could change the service that IIS is running
under.

And lastly, if you have IIS6 (windows server 2003), then you can create an
application pool with specific identity properties.

I hope this helps,
--- Nick
 
Back
Top