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.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

C# Process Problem

  • 20-02-2009 02:30PM
    #1
    Registered Users, Registered Users 2 Posts: 165 ✭✭


    Hi guys,

    I created a new Process in my C# program which calls a batch file which in turn runs a jar. This works fine until I want to redirect standard output and whenever I close the process, it kills the bat file but not the underlying jar.

    After reading up I saw you could call the java.exe itself and pass in the jar as a parameter and it would fix my problems. The trouble with this is I get a "Access is denied" error on the line:
    process.Start()
    

    So, after further reading up I, I realised that I could use Impersonation to as the account I was using might not have permissions to execute the file. Firstly, I added the following line to see what was being logged in:
    WindowsIdentity.GetCurrent().Name;
    

    When debugging, it was filled with my windows authentication details, for instance; DOMAIN\\name. When I check the permissions of the the file java.exe my details are down as DOMAIN\name (note only one backslash) so I think that is stopping me from accessing the file.

    Any ideas on how I can fix this or is there an easier way of getting around my original problem?

    All ideas most welcome,
    ViperMAN


Comments

  • Closed Accounts Posts: 2,268 ✭✭✭mountainyman


    ViperMAN wrote: »
    Hi guys,

    I created a new Process in my C# program which calls a batch file which in turn runs a jar. This works fine until I want to redirect standard output and whenever I close the process, it kills the bat file but not the underlying jar.

    After reading up I saw you could call the java.exe itself and pass in the jar as a parameter and it would fix my problems. The trouble with this is I get a "Access is denied" error on the line:
    process.Start()
    

    So, after further reading up I, I realised that I could use Impersonation to as the account I was using might not have permissions to execute the file. Firstly, I added the following line to see what was being logged in:
    WindowsIdentity.GetCurrent().Name;
    

    When debugging, it was filled with my windows authentication details, for instance; DOMAIN\\name. When I check the permissions of the the file java.exe my details are down as DOMAIN\name (note only one backslash) so I think that is stopping me from accessing the file.

    Any ideas on how I can fix this or is there an easier way of getting around my original problem?

    All ideas most welcome,
    ViperMAN

    cast to a string find the character "/" and strip out everything to the left of that.


  • Registered Users, Registered Users 2 Posts: 165 ✭✭ViperMAN


    cast to a string find the character "/" and strip out everything to the left of that.

    Yes I thought of that too. Using the Impersonation LogonUser method but it returned invalid username or password.


Advertisement