CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2011
    Posts
    16

    [RESOLVED] Problem while calling .exe file from VS2008

    Hi everybody,

    I have an issue in my project, and I hope you can help me.

    I am programming in both Matlab (Matlab2011a) and Visual Basic (VS2008).

    I've created a .exe file from my matlab code. It works well when I click on it with my mouse.

    But I need to run it within Visual Basic. I know it's possible to call .exe files with Shell() or Process.Start(), and it works well for files such as firefox.exe or notepad.exe.

    However, it doesn't work when I call my own .exe file ...
    It's weird because when I look to the Task Manager while trying to call it (within VB), I can see the process starting and ending, but its output doesn't appear.

    I hope you've understood my problem, and you'll be able to help me.

    Many thanks,

    Did

  2. #2
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Problem while calling .exe file from VS2008

    #1 : Does your Matlab App accept or require any command line arguments..

    #2 : How exactly are you calling the App from VS2008 ... (post code please)

    lets see if we can sort this one out...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  3. #3
    Join Date
    Aug 2011
    Posts
    16

    Re: Problem while calling .exe file from VS2008

    Hi GremlinSA,

    Thanks for your answer.
    Finally, i have solved my issue asking to many people in several forums.

    The problem was that by default, the working directory for the new process will be the same as the first app. If the new app assumes that its own program folder is the working directory then it will fail to find one or more files.

    Here is my final code, it works well. I hope it can help anybody !


    Dim callExe As New ProcessStartInfo

    callExe.WorkingDirectory = "C:\Documents and Settings\Tobii\Desktop\Outputs Eye-tracking"
    callExe.FileName = "FixationFiltering.exe"
    Process.Start(callExe)

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: [RESOLVED] Problem while calling .exe file from VS2008

    Ask the USER to find the folder...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: [RESOLVED] Problem while calling .exe file from VS2008

    Okay - You've marked this resolved however you could still end up with problems once distributed..

    It's not advisable to use hardcoded directories ... ESPECIALLY ones related to users desktops..
    C:\Documents and Settings\Tobii\Desktop\Outputs Eye-tracking is for the user Tobii..

    What if this gets installed on another PC that there is no user Tobii ... it will not work and the user will battle to figure out why...

    Rather ask the user to find it the first time your app starts (or if the app cant find it) and store that location either in the Reg or even the App config file..

    Or else Put both applications in the same directory (with all supporting files) and you can use Application.startuppath ...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  6. #6
    Join Date
    Aug 2011
    Posts
    16

    Re: [RESOLVED] Problem while calling .exe file from VS2008

    Hi,

    Yes of course it won't work if the program is used on another computer. But for my application, it's ok. I'll never use it with another pc.

    Thanks for your answers!

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

Featured