Results 1 to 4 of 4

Thread: 2 different tasks

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Location
    Wellington, NZ
    Posts
    267

    2 different tasks

    I have a program that is to behave in 2 different ways. Each scenario is 80% the same. The program determines at the outset which scenario it is to work under. I don't want to ask the user what scenario to use. Can I execute then like xxx.exe/one and xxx.exe/two ? If so, how to I know which one was used ? I tried to make a copy with a different name, like xxx.exe and yyy.exe, but Me.ProductName in yyy.exe still thinks it is xxx.exe. Any ideas ?

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

    Re: 2 different tasks

    You would pass an argument on the commandline, for at least one but maybe both cases, e.g.
    Code:
    myApp.exe /x
    
    myApp.exe /y
    The arguments themselves can be anything you want because they don't really mean anything except to you. Within the app you get the commandlline and test the number and value of the arguments and then decide what to do based on the results. You can either use the e.CommandLine property in the app's Startup event handler or else use the Environment.GetCommandLineArgs method anywhere you like. There are examples of both already posted on the forum so you should search if you feel you need them.
    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Location
    Wellington, NZ
    Posts
    267

    Re: 2 different tasks

    Just what I needed. Thanks.

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

    Re: 2 different tasks

    I just noticed your location Robert. I'm working in St Leonards at this very moment! Not exactly next door but close enough in Internet terms. Small world, huh?
    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