Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

run python script in VB.net

Posted on 2011-02-24
4
Medium Priority
?
2,662 Views
Last Modified: 2013-11-05
I need to run a python script in VB.net.  The script itself works perfectly but will not run when I try to do it withing VB.net.  I get the error "The specified executable is not a valid application for this OS platform."
Label2.Text = String.Empty

        If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
            Dim p As Process = New Process

            txtSD.Text = FolderBrowserDialog1.SelectedPath
            p.StartInfo.FileName = "WinCombineLogs.py" 'set path of current antivirus product.
            p.StartInfo.Arguments = " -d " + DateTimePicker1.Text + " -f " + txtSD.Text 'set arguments of current antivirus product.

            p.StartInfo.UseShellExecute = False 'required for redirect.
            p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden 'don't show commandprompt.
            p.StartInfo.CreateNoWindow = True
            p.StartInfo.RedirectStandardOutput = True 'captures output from commandprompt.
            p.Start()
            p.WaitForExit()
        End If
    End Sub

Open in new window

0
Comment
Question by:NevSoFly
  • 2
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
Hairbrush earned 2000 total points
ID: 34978516
When you run the WinCombileLogs.py file from your command line, Windows will look in your registry to find out what program is associated with the ".py" file extension, and will then pass the filename as a parameter to that program.

Your code tries to call WinCombineLogs.py as if it was a program directly executable by Windows, but that isn't the case.  What you'd need to do is set StartInfo.FileName to the filename of your Python script interpreter, and pass "WinCombineLogs.py" as the first argument.
0
 

Author Comment

by:NevSoFly
ID: 34980794
where would I find the interpreter for Win XP or Win 7?
0
 
LVL 12

Expert Comment

by:Hairbrush
ID: 34981384
As you said that "the script itself works perfectly" I presume you already have the software installed on your PC.  Try looking for C:\Program Files\Python\python.exe

(http://docs.python.org/faq/windows.html#how-do-i-make-python-scripts-executable)
0
 

Author Closing Comment

by:NevSoFly
ID: 35010780
thank you
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Loops Section Overview
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question