Solved

run python script in VB.net

Posted on 2011-02-24
4
2,454 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
Hairbrush earned 500 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

617 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