using System.Diagnostics.Process.Start

B

Bali

Hi

I have an ASP.NET application. I am on the server side and trying to
start an application which is on the server. The process gets
started(can be seen in the Task Manager) but doesn't do anything(00
CPU cycles).

System.Diagnostics.Process.Start("c:\\Code\\testExe\\test.exe");

Now I have gone to the testExe folder and given both ASPNet and
Network Service Read & Execute \ Modify rights to the folder and I
also added these two users to the Debugger group on my computer. I am
currently getting the error JIT Debugging exception -
System.UnauthorizedAccessException has occured.

Any ideas on this would be greatly appreciated. Also I read in one of
the forums that if you run an application this way which has GUI then
the GUI doesn't show up. Is that true? What could be a way around it?

Please let me know

Thanks

Sumeet
 
J

Juan T. Llibre

re:
!> The process gets started(can be seen in the Task Manager) but doesn't do anything(00 CPU cycles)

Could that be because you haven't instructed test.exe to do anything ?

You need to pass an argument to test.exe :
System.Diagnostics.Process.Start("c:\\Code\\testExe\\test.exe", "argument");

See several code examples here :
http://msdn.microsoft.com/en-us/library/h6ak8zt5.aspx

Also, remember to kill the test.exe process when you're done.
That will prevent accumulating memory usage with each process instance started.




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
B

bruce barker

asp.net runs as a service, as do any processes its starts. a service process
does not have access to the desktop, so any open window will fail. most gui
apps do not check if open window failed, so they just hang

if you need to run a gui app, then you should create a proxy process that
starts the app. you would need to run the proxy every time you log in (put ii
in start up). then asp.net can call this proxy to start the app.

-- bruce (sqlwork.com)
 
B

Bali

Hi

Thanks for responding.

My exe is simply creating a file on the c drive and I have tested it
successfully.

I went under services -> IIS Admin -> Properties -> Log On, selected
Allow service to interact with desktop and still got the same error. I
read that I might have to change the settings under which the ASP.NET
account operates in Machine.Config. I think that that would make the
machine much more vulnerable and is a security issue.

Any ideas?

Is proxy process another name for a windows service because to me in
concept it is sounding the same?

Please let me know.

Thanks

Sumeet
 
1

1234 Ali

Please help me.

I added a macro to MS WinWord to print any DOC file to default printer that is a PDF writer. (mPrintDefault is macro name)

Now I write a simple code in ASPX page, to convert a sample DOC file to PDF format. (Using System.Diagnostics)

The problem is that every time I run the page, winword.exe is called by Network Service account and is remained in task bar and nothing else!

I can run below line in RUN command prompt with success:

"c:\Program Files\Microsoft Office\OFFICE12\WINWORD.EXE" "C:\test\sample.doc" /mPrintDefault /q /n"

But in ASPX page no success.

Before this, I used some other components to do this conversion. (DOC2PDF).

With local users like Administrator it was OK but within ASPX pages was unsuccessful. Every time, winword.exe was called by IUSER or NetworkService and remained in taskbar without success or result.

How I can fix this problem?
I changed all permissions for target directory to WRITE, but no success.

Best Regards
Ali

OS is Windows 2003
Code is:
====================
Partial Class test_diag
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim psi As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo()

psi.FileName = "c:\Program Files\Microsoft Office\OFFICE12\WINWORD.EXE"
psi.Arguments = "C:\test\1.doc""/mPrintDefault /q /n"

System.Diagnostics.Process.Start(psi)

End Sub
End Class
 

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

Top