News from this site

 Rental advertising space, please contact the webmaster if you need cooperation


+focus
focused

classification  

no classification

tag  

no tag

date  

no datas

Run python script in VB.net on button click

posted on 2024-12-02 22:09     read(974)     comment(0)     like(25)     collect(4)


I want to run a Python script in cmd when a button is clicked in VB.Net. Do you need to call the Python script in a batch file? Or can you do it directly in VB?

I tried this

Dim ps As New ProcessStartInfo("cmd.exe")
    ps.Arguments = "C:\yourbatfile.bat"
    Process.Start(ps)

But that only opens the cmd window and doesn't execute the bat file.


solution


Dim psi = New ProcessStartInfo("c:\python27\python.exe", "myPythonScript.py")
Dim proc = Process.Start(psi)
proc.WaitForExit()
If proc.ExitCode <> 0 then throw new Exception(" Script Failed")


Category of website: technical article > Q&A

Author:qs

link:http://www.pythonblackhole.com/blog/article/247240/849c5cbf01376f796d59/

source:python black hole net

Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.

25 0
collect article
collected

Comment content: (supports up to 255 characters)