File not found error using Shell() to execute.


  • I am very new to VB and I am using Visual Studio 2005.
    What I am trying to do is create a simple 'launcher' that opens/runs another file.

    The problem I have is that I can not seem to get the file to run using the Shell() function.  I searched and finally found a way to verify a file exists (because I am using relative paths).  I first do a check to see if the file exists using the code I found, and if it does, I use Shell() to run the exact same file.  The problem is that the file is found only when looking for it, not when trying to run it.  I am guessing it might have something to do with permissions, but really have no clue.  Here is the snipet of what I am doing (and yes test.txt is the file I am trying to run).

            If My.Computer.FileSystem.FileExists(".\test.txt") Then
                MsgBox("File found.")
                MsgBox("File not found.")
            End If

    As I said, I am very new to this so if it is somehow very technical, the more detail the better.  And if there is a better way to run a program that is fine, Shell is just the only method I know so far.  Thanks
    Sunday, July 9, 2006 9:06 AM


All replies

  • Hi,

    Try out this statment ... System.Diagnostics.Process.Start

    System.Diagnostics.Process.Start("path of file to run")



    Hope this help.

    Sunday, July 9, 2006 11:04 AM
  • Shell function only accepts path to executables.

    As suggested before, use Process.Start() instead.

    Sunday, July 9, 2006 4:36 PM