Running a Batch file and having it output in ritchtextbox

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
5 posts Page 1 of 1
Contributors
User avatar
skyteam
Member
Member
Posts: 27
Joined: Thu Apr 28, 2011 1:27 am

Hi guys so I need help I've looked online with no luck

so the code needs to open the batch then hide it and send the out put to the richtextbox

thanks tim


~~~~~~~~~~~~~~~~~~~~~~~~~~edit~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I got it to work but now It will not launch the python part of the batch :3
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Image
Code: Select all
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        p = New Process
        p.StartInfo.FileName = "application.exe"
        p.StartInfo.UseShellExecute = False
        p.StartInfo.RedirectStandardOutput = True
        p.StartInfo.RedirectStandardError = True
        p.StartInfo.CreateNoWindow = False
        AddHandler p.OutputDataReceived, AddressOf p_OutputDataReceived
        p.Start()
        p.BeginOutputReadLine()
    End Sub

    Public Sub p_OutputDataReceived(ByVal sender As Object, ByVal e As DataReceivedEventArgs)
        UpdateTextBox(e.Data)
    End Sub

    Delegate Sub SetTextCallback([text] As String)
    Private Sub UpdateTextBox(ByVal text As String)
        If Me.TextBox1.InvokeRequired Then
            Dim d As New SetTextCallback(AddressOf UpdateTextBox)
            Me.Invoke(d, New Object() {text})
        Else
            If TextBox1.Text = Nothing Then TextBox1.Text = text Else TextBox1.AppendText(vbNewLine & text)
        End If
    End Sub
Example-Catch BatchFile Output.zip
You do not have the required permissions to view the files attached to this post.
Image
User avatar
skyteam
Member
Member
Posts: 27
Joined: Thu Apr 28, 2011 1:27 am

I have that thing is it wont run python scrips for some reason

here's my batch file

"C:\Python32\python.exe" launch.py
"C:\Python32\python.exe" start.py <--- if theres an error then
del /Q start.py <----- this happens
del /Q bot_conf.py


yet it doesnt work
Last edited by skyteam on Fri Mar 08, 2013 12:51 am, edited 1 time in total.
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

skyteam wrote:
I have that thing is it wont run python scrips for some reason
why are you running python scripts on a windows pc?

Did you SET the ENVIROMENTVARABLE for window to the PERL.exe path?
Code: Select all
In short, your path is:

My Computer ‣ Properties ‣ Advanced ‣ Environment Variables
In this dialog, you can add or modify User and System variables. To change System variables, you need non-restricted access to your machine (i.e. Administrator rights).

Another way of adding variables to your environment is using the set command:

set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib
To make this setting permanent, you could add the corresponding command line to your autoexec.bat. msconfig is a graphical interface to this file.

Viewing environment variables can also be done more straight-forward: The command prompt will expand strings wrapped into percent signs automatically:

echo %PATH%
Do you have this line
Code: Select all
#!/usr/local/bin/python
in the .pl script set to the path of your perl install folder?

Did you add the ECHO statement to the .bat file?
Last edited by Scottie1972 on Fri Mar 08, 2013 12:56 am, edited 2 times in total.
Image
User avatar
skyteam
Member
Member
Posts: 27
Joined: Thu Apr 28, 2011 1:27 am

Scottie1972 wrote:
skyteam wrote:
I have that thing is it wont run python scrips for some reason
why are you running python scripts on a windows pc?

because its for my chatango bot it works fine till I try to add that batch file and since all the python gui suck monkie nuts Id like to make it in vb
5 posts Page 1 of 1
Return to “Coding Help & Support”