• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 407
  • Last Modified:

retrieve messages from batch files

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
AlHal2
Asked:
AlHal2
  • 3
  • 3
1 Solution
 
Miguel OzSoftware EngineerCommented:
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
 
AlHal2Author Commented:
Please let me know what you need beyond what's in the attachment.
0
 
Miguel OzSoftware EngineerCommented:
I need:
1) The code that runs the batch file you save in the attachment
2) Answer to my question above.
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
AlHal2Author Commented:
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
 
Miguel OzSoftware EngineerCommented:
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
 
AlHal2Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now