Results 1 to 10 of 10

Thread: Multiple Program Automation

  1. #1

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Multiple Program Automation

    Hi,

    I was wondering if there was a way to launch a string of programs from a button.

    I want to be to launch, say 6 programs. Once the first one is done, the code has to know that the first program is done doing it's automated process and then continue.

    In VB 6, I used the Shell Execute command to launch a program, but it doesn't work in Vb.Net and I wouldn't even know how to make it launch consecutive programs.

    Thanks for any help

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Multiple Program Automation

    Use the Process class and start a new process to run a program. Then check it exit code or HasExited or WaitForExit property to determine when its done.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Multiple Program Automation

    Thanks

    I'll take a look at it and see what I come up with. I'll post some code I come up with


  4. #4

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Multiple Program Automation

    I started playing around with Process.Start and I was wondering if there was a way to open a program without specifying a specific path. If the program or file was located within the same directory, then is there a specific piece of code that could launch it.

    Or is there something else I would have to use?

    I was reading a bit online and found out that if there's a PATH statement in Windows, then you won't have to specify a path. Like the process for Windows Explorer, iexplore.exe. That's why I was thinking that there might have to be something else that is used to launch it.

    Maybe there's a way to link in your resources?

    Thanks for the help

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

    Re: Multiple Program Automation

    If you specify the name of a file without a qualifying folder path and that file can't be found in any of the folders specified in the PATH environment variable then it is assumed to reside in the application's current working directory. For most .NET applications the initial working directory is the folder that contains the executable, but it doesn't have to be and it can change over the course of a session. For those reasons you should never omit the path of a file unless you specifically want to follow the working directory wherever it may be.

    If you specifically want a file in the program folder then you should specify that explicitly:
    vb.net Code:
    1. Process.Start(IO.Path.Combine(Application.StartupPath, "myfile"))
    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

  6. #6

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Multiple Program Automation

    The program that I am making is intended to be used on multiple computers.
    The reason that I don't want to specify an exact path, is because the drive letter is always going to change because this application is going to be used on a flash drive.

    referring to this statement
    If you specify the name of a file without a qualifying folder path and that file can't be found in any of the folders specified in the PATH environment variable then it is assumed to reside in the application's current working directory. For most .NET applications the initial working directory is the folder that contains the executable....
    If I don't specify the path, the file is located in the directory of the executable, and it doesn't work in debug mode, will it work when I compile the program?

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

    Re: Multiple Program Automation

    If the file is in the working directory then it will get executed. If it's not then an exception will be thrown. That's it, plain and simple, whether debugging or not.
    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

  8. #8

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Multiple Program Automation

    You were right, jmcilhinney. I'm not sure why it didn't work before.

    Are you able to name a directory without naming the entire string as long as it is located where the executable is?

    For example:

    I currently have this:
    Code:
    Process.Start("test")
    I want to be able put my files in a sub folder for neatness.

    I tried this:
    Code:
    Process.Start("Files\test")
    But it doesn't work. Probably just something I'm doing wrong :P

  9. #9

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Multiple Program Automation

    Anyone else know what I can do?

    I tried googling it, but I can't seem to find it

    Thanks
    Last edited by weirddemon; Jan 5th, 2009 at 06:36 PM.

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Multiple Program Automation

    How about ...

    Process.Start(Application.StartupPath & "\Files\test\myotherprogram.exe")
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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