Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

C# - Cant run old .exe files?

  • 21-10-2009 08:08PM
    #1
    Closed Accounts Posts: 21


    Hi guys,

    I am currently working on a project involving c#.

    My problem is I am trying to replace a batch file with c# code.

    All the programs are stored in a folder programs_used. Some of the programs are pretty old (pre 1995). I know my code is ok visa vie running programs in general from this directory as I have ran some already to test the function (only works on the newer programs) .

    The old programs in question work fine in the batch file with the usual programName.exe

    Is there any reason why these old programs wont work with the following c# code:

    Note I pass in a variable programName from the main method - it's actually comprised of the path and program name. This does work for all the newer programs just not the old ones.


    public static void run(string programName)
    {
    System.Diagnostics.Process Proc = new System.Diagnostics.Process();
    Proc.StartInfo.FileName = programName;
    Proc.Start();
    }


    Thanks a million!


Comments

  • Registered Users, Registered Users 2 Posts: 981 ✭✭✭fasty


    Does Start return true or false? Is an exception thrown?


  • Registered Users, Registered Users 2 Posts: 721 ✭✭✭TheTubes


    This is the way I do it:
    public static void run(string programName)
            {
                          System.Diagnostics.Process Proc = System.Diagnostics.Process.Start(exe, args);
                          Proc.WaitForExit();
            }
    

    this may just be a different way of writing the code, sorry if it dosen't help.

    your filename is the full path to the exe? like "c:\tmp\myexe.exe" ?


Advertisement