Results 1 to 3 of 3

Thread: Shell (Files not found)

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2009
    Location
    Canada/Quebec
    Posts
    54

    Shell (Files not found)

    Hi there,

    why this doesn't work?


    Shell("wow.exe")

    And... if i do that

    Shell("C:\Program Files\World of Warcraft\wow.exe\")

    It doesn't work too....

    It say File Not Found...

    Srry for my english
    Learning VB2008
    Developer DaneX

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Shell (Files not found)

    You should always check if the file exists before you just shell it off. Also, Process.Start is the preferred way to shell a new process, as it returns you a process object instead of just the PID. Shell is just left in from the VB6 days to make code conversion easier.

    Code:
            If IO.File.Exists("C:\Users\public\games\World of Warcraft\wow.exe") Then
                Process.Start("C:\Users\public\games\World of Warcraft\wow.exe")
            End If

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Shell (Files not found)

    I think you'll find that the problem is not that the WoW file doesn't exist but rather that WoW itself can't find a file that it's looking for once it's running. A lot of games require that their current directory be the same as their startup directory. If you have a desktop or Start Menu shortcut for WoW then check its properties and you'll probably see that its Working Directory is set. You need to do the equivalent in code, e.g.
    vb.net Code:
    1. Dim filePath As String = "C:\Program Files\World of Warcraft\wow.exe"
    2. Dim psi As New PrcoessStartInfo(filePath)
    3.  
    4. psi.WorkingDirectory = IO.Path.GetDirectoryName(filePath)
    5. Process.Start(psi)
    That said, you should still do as -0 says and test that the file you're executing exists too.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width