Solved

retrieve messages from batch files

Posted on 2013-12-17
7
358 Views
Last Modified: 2013-12-19
I'm using vb 2008 with asp.net 3.5.  The program writes a batch file on the server using a streamwrite like this.  It then runs the batch file using a shell command as per the last line.
There are two errors I want to trap.
The ID and password are incorrect.
The file was not present on the server being accessed by the batch file.

If an error happens I want to display a meaningful message in Internet Explorer.  How do I do this?
The batch file is attached (with hostname, ID and password changed).
Attachment.txt
0
Comment
Question by:AlHal2
  • 3
  • 3
7 Comments
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 39725595
Please post the code that runs your batch file. I need to see what you are using.
Basically you need to capture the screen output and display it in a label in your page. Is this OK for you?
0
 

Author Comment

by:AlHal2
ID: 39726254
Please let me know what you need beyond what's in the attachment.
0
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 39726316
I need:
1) The code that runs the batch file you save in the attachment
2) Answer to my question above.
0
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 

Author Comment

by:AlHal2
ID: 39726356
The code in the attachment is generated when the user presses a button.
I would like to capture the screen output and display it as a label in the page.
Hope this clarifies things.
0
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 250 total points
ID: 39727887
The attached code only shows how to generate the batch file, not how the file is executed.
Any way, you can use Process StartInfo.RedirectStandardOutput property  = true to run your batch file as shown in the link below:
http://www.dotnetperls.com/redirectstandardoutput
0
 

Author Closing Comment

by:AlHal2
ID: 39728738
Thanks.  I used the shell command at the bottom of the attachment to execute the batch file, but I think your method is better.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question