Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

C# - Cant run old .exe files?

  • 21-10-2009 7: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