1

Running the following snippet yields "System.IO.FileNotFoundException: File not found"

Sub Main()
        Dim scriptPath As String = "D:\Programs\Tester.py"
        Dim pythonPath As String = "D:\anaconda3\python.exe"
        If IO.File.Exists(scriptPath) Then
            Shell(pythonPath + " " + scriptPath)
        End If
End Sub

I am at a loss as to why this happens, because there is no problem in finding the file for the If-statement, however, as soon as it has to get executed it "does not exist". My original code featured a python script running as a process (as below), however, for some reason this stopped working: it runs without any errors, the script just doesn't get executed. The paths are copied from each file's "Properties" so I know they are still correct.

...
    Dim scriptPath As String = "D:\Programs\Tester.py"
    Dim pythonExePath As String = "D:\anaconda3\python.exe"
    Dim gzipProcess As New Process()
    Dim gzipStartInfo As New ProcessStartInfo(pythonExePath, scriptPath)
    gzipStartInfo.UseShellExecute = False
    gzipProcess.StartInfo.CreateNoWindow = True
    gzipProcess.StartInfo = gzipStartInfo
    gzipProcess.Start()
...

If I manually open a shell I can simply run the script as "python scriptPath" and it executes normally.

Any suggestions on how to fix this?

pm233
  • 33
  • 2

0 Answers0