Solved

run python script in VB.net

Posted on 2011-02-24
4
2,144 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 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Encryption Decryption in Oracle 12 65
Total in textboxes 9 36
Showdialog 8 21
Spacing between controls 4 17
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now