just_a_programmer
just_a_programmer

Reputation: 341

Visual Basic Windows Form - Running Python script w/ button

I have a simple visual basic window (or 'form'), and at the click of a button on the form, I want my Python script to run. How would I go about this?

Upvotes: 4

Views: 7939

Answers (3)

TheWhiteHood
TheWhiteHood

Reputation: 117

Edit to answer this question. Some referenced the used of the command "shell". This is not a good practice, rather, use Process.Start().

Upvotes: 4

Virtual Vengance
Virtual Vengance

Reputation: 31

If you just want to run it, then double click the button, then once you see the code responsible for your button once you click it, enter this code, but with your specific location and script name;

obj = CreateObject("WScript.Shell")
obj.run("C:\Directory\File.py")

Hope this helps!

Upvotes: 3

JustGreat
JustGreat

Reputation: 561

You can do something like :

Dim ReturnValue

ReturnValue= Shell("C:\python23\python ""C:\Myscripts\Mypythonscript.py"" ", vbHide)

Upvotes: 4

Related Questions