I have a web page where in I am calling a batch file to run.This batch file in turn runs an exe which generates an XPS file. Below is the code where I use Process class to run the batch file:
When I run my batch file by double clicking on it, it is calling the exe and generating the XPS file. But, when I call the batch file from the web app, I can see my exe process running in the TaskManager, but it is not creating the XPS file nor it is shutting
down. The process is hanging in there and I need to end the process manually to close it. How can I over come this issue.
when I call the batch file from the web app, nothing is happening.
not true, because you wrote:
hr3
[you] can see [your] exe process running in the TaskManager
TIMTOWTDI =. there is more than one way to do it
you've not shown us your command file run.bat.
first you need to determine whether your run.bat actually runs ... it could be waiting for some console input ...
after creating a directory manually, say c:\hr3_test, you could try somelike like adding this at the beginning of
run.bat:
set thisRandom=%random%
md c:\hr3_test\%thisRandom%
Each time run.bat executes, you'll see a new directory created.
Try that and let us know if you're getting even that far ... if you are, you might want to consider showing us the contents of
run.bat.
g.
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
when I call the batch file from the web app, nothing is happening.
I edited my post for clarification. Thank you for pointing out the error.
I tried your script in my batch file and it is creating the folders and I am seeing my exe process in the taskmanager. Here is the script in my batch file:
@Echo Off
Echo Command Line Value: %1 %2
C:\Inetpub\wwwroot\MyEXEApp\MyApp.exe %1 %2
Echo Successfully completed
on the server, i do not think you will see the echo output because there is no
UI.
test with
@Echo Off
set thisRandom=%random%
Echo Command Line Value: %1 %2 > c:\hr3_test\%thisRandom%.txt
C:\Inetpub\wwwroot\MyEXEApp\MyApp.exe %1 %2
Echo Successfully completed >> c:\hr3_test\%thisRandom%.txt
you need to know whether your code is completing.
Note: you may also be experiencing a rights issue on the server.
One more thing to check on your win2008 server is the event logs.
g.
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
@Echo Off
set thisRandom=%random%
Echo Command Line Value: %1 %2 > c:\hr3_test\%thisRandom%.txt
C:\Inetpub\wwwroot\MyEXEApp\MyApp.exe %1 %2
Echo Successfully completed >> c:\hr3_test\%thisRandom%.txt
I tried it. It is creating the first line in the text file. Calls my exe application and exe process is never ending. Actual functionality of my exe is: it should crate an empty XPS file and then add data to the created XPS file. When I double click the
batch file on ,y server, it is all working good. But when I call the batch file from my web page, it is in turn calling the exe and my exe is creating the empty XPS file and then hangs in there.
Did you check the event logs? if not, please check them ... often one finds clues in the event logs.
hr3, do you have vs on your server? if you do, you should be able to use the technique that i describe in the community content part of this MSDN article:
You may need to lengthen the 120 second delay until you get the feel of this technique; the basic idea is to ensure that you've left yourself enough time to attach to your process.
once you are in the debugger*, you have a better chance of troubleshooting your code.
search videos at Google with debug visual studio 2010
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
i'm not talking about the iis logs ... i'm talking about the event logs ... you use
Event Viewer to examine the event logs.
hr3
i do not have VS on my server.
are you allowed to install it?
g.
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
I checked Event Viewer too. Below is the information
i do not see your event log information ... did it give you any clues?
Note: you can filter event logs by time and copy relevant event log details to the clipboard as text. Example:
Log Name: Application
Source: Outlook
Date: 2012-11-28 14:49:30
et cetera
g.
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
hr3
Member
15 Points
32 Posts
Issue in running a batch file from ASP.NET web page
Nov 27, 2012 04:34 PM|LINK
Hi all,
I have a web page where in I am calling a batch file to run.This batch file in turn runs an exe which generates an XPS file. Below is the code where I use Process class to run the batch file:
When I run my batch file by double clicking on it, it is calling the exe and generating the XPS file. But, when I call the batch file from the web app, I can see my exe process running in the TaskManager, but it is not creating the XPS file nor it is shutting down. The process is hanging in there and I need to end the process manually to close it. How can I over come this issue.
Thanks.
gerrylowry
All-Star
20577 Points
5721 Posts
Re: Issue in running a batch file from ASP.NET web page
Nov 27, 2012 05:06 PM|LINK
@ hr3
not true, because you wrote:
TIMTOWTDI =. there is more than one way to do it
you've not shown us your command file run.bat.
first you need to determine whether your run.bat actually runs ... it could be waiting for some console input ...
after creating a directory manually, say c:\hr3_test, you could try somelike like adding this at the beginning of run.bat:
set thisRandom=%random%
md c:\hr3_test\%thisRandom%
Each time run.bat executes, you'll see a new directory created.
Try that and let us know if you're getting even that far ... if you are, you might want to consider showing us the contents of run.bat.
g.
hr3
Member
15 Points
32 Posts
Re: Issue in running a batch file from ASP.NET web page
Nov 27, 2012 05:42 PM|LINK
@
I edited my post for clarification. Thank you for pointing out the error.
I tried your script in my batch file and it is creating the folders and I am seeing my exe process in the taskmanager. Here is the script in my batch file:
I am passing in the parameters from my code as:
proc.StartInfo.Arguments = string.Format("{0} {1}", param1, param2);This whole setup is working fine in my local XP system, but it is not when I deployed onto my WS 2008 server.
gerrylowry
All-Star
20577 Points
5721 Posts
Re: Issue in running a batch file from ASP.NET web page
Nov 27, 2012 08:10 PM|LINK
@ hr3
on the server, i do not think you will see the echo output because there is no UI.
test with
you need to know whether your code is completing.
Note: you may also be experiencing a rights issue on the server.
One more thing to check on your win2008 server is the event logs.
g.
hr3
Member
15 Points
32 Posts
Re: Issue in running a batch file from ASP.NET web page
Nov 27, 2012 08:39 PM|LINK
I tried it. It is creating the first line in the text file. Calls my exe application and exe process is never ending. Actual functionality of my exe is: it should crate an empty XPS file and then add data to the created XPS file. When I double click the batch file on ,y server, it is all working good. But when I call the batch file from my web page, it is in turn calling the exe and my exe is creating the empty XPS file and then hangs in there.
gerrylowry
All-Star
20577 Points
5721 Posts
Re: Issue in running a batch file from ASP.NET web page
Nov 27, 2012 09:49 PM|LINK
@ hr3
Did you check the event logs? if not, please check them ... often one finds clues in the event logs.
hr3, do you have vs on your server? if you do, you should be able to use the technique that i describe in the community content part of this MSDN article:
http://msdn.microsoft.com/en-us/library/7a50syb3(v=vs.100).aspx
"How to: Debug Windows Service Applications"
You may need to lengthen the 120 second delay until you get the feel of this technique; the basic idea is to ensure that you've left yourself enough time to attach to your process.
once you are in the debugger*, you have a better chance of troubleshooting your code.
g.
* walking your code with your debugger:
video, c. 8 minutes: http://msdn.microsoft.com/en-ca/vstudio/ee672313.aspx
"How Do I: Step with The Debugger in Visual Studio?"
Debugging: http://lmgtfy.com/?q=debug+visual+studio+2010
example: http://www.codeproject.com/KB/cs/MasteringInDebugging.aspx
videos: http://www.youtube.com/watch?v=z5gBIizwsY0
search videos at Google with debug visual studio 2010
hr3
Member
15 Points
32 Posts
Re: Issue in running a batch file from ASP.NET web page
Nov 28, 2012 03:04 PM|LINK
I checked the IIS logs, but didn;t find any useful information and i do not have VS on my server.
gerrylowry
All-Star
20577 Points
5721 Posts
Re: Issue in running a batch file from ASP.NET web page
Nov 28, 2012 06:00 PM|LINK
@ hr3
i'm not talking about the iis logs ... i'm talking about the event logs ... you use Event Viewer to examine the event logs.
are you allowed to install it?
g.
hr3
Member
15 Points
32 Posts
Re: Issue in running a batch file from ASP.NET web page
Nov 28, 2012 06:11 PM|LINK
I checked Event Viewer too. Below is the informatio I have from there. Also, I am not allowed to install VS on the server.
gerrylowry
All-Star
20577 Points
5721 Posts
Re: Issue in running a batch file from ASP.NET web page
Nov 28, 2012 06:54 PM|LINK
@ hr3
i do not see your event log information ... did it give you any clues?
Note: you can filter event logs by time and copy relevant event log details to the clipboard as text. Example:
Log Name: Application
Source: Outlook
Date: 2012-11-28 14:49:30
et cetera
g.