在中运行python脚本VB.net版按钮式cli

2024-09-30 05:23:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在单击按钮时在cmd中运行Python脚本VB.Net. 您需要在批处理文件中调用Python脚本吗?或者你可以直接用VB来做吗?在

我试过了

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

但这只会打开cmd窗口,而不执行bat文件。在


Tags: 文件脚本cmdnewnetas按钮exe
1条回答
网友
1楼 · 发布于 2024-09-30 05:23:26
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")

相关问题 更多 >

    热门问题