locked
ASP.Net buttonclick run .bat file possible ? RRS feed

  • Question

  • User-775831949 posted

    Is ASP.Net buttonclick run .bat file on IIS possible ?

    Thanks

    Tuesday, May 29, 2018 1:02 AM

Answers

  • User409696431 posted

    In the button click code behind, try:

    System.Diagnostics.Process.Start( @"c:\path\to\program.bat" );
    

    This presumes the permissions the webpage is running under has rights to run a bat file on the server.  Getting that sorted out might be the more challenging part of the problem.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 29, 2018 2:40 AM
  • User36583972 posted


    Hi hkbeer,

    Is ASP.Net buttonclick run .bat file on IIS possible ?

    The most for IIS to fail run a bat/EXE file are the following main reasons.

    1: Lack of permissions for IIS Users, such as the application pool user, or the Network service.

    2: x86 EXE running on x64 machine issues.

    3: missing dependencies.

    You can refer the following thread's solution.

    IIS7 does not start my Exe file by Process Start

    Besides, Your issue is more related to the IIS. I suggest you can go to the IIS forum for getting further help.

    Best Regards,

    Yong Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 30, 2018 3:08 AM

All replies

  • User409696431 posted

    In the button click code behind, try:

    System.Diagnostics.Process.Start( @"c:\path\to\program.bat" );
    

    This presumes the permissions the webpage is running under has rights to run a bat file on the server.  Getting that sorted out might be the more challenging part of the problem.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 29, 2018 2:40 AM
  • User465171450 posted

    Normally the account the web application runs under should have limited rights and may not have access to perform the actions the .bat file wants. You may want to look at different architecture and find a way to code the functions the batch file performs into .Net code.

    Tuesday, May 29, 2018 12:39 PM
  • User36583972 posted


    Hi hkbeer,

    Is ASP.Net buttonclick run .bat file on IIS possible ?

    The most for IIS to fail run a bat/EXE file are the following main reasons.

    1: Lack of permissions for IIS Users, such as the application pool user, or the Network service.

    2: x86 EXE running on x64 machine issues.

    3: missing dependencies.

    You can refer the following thread's solution.

    IIS7 does not start my Exe file by Process Start

    Besides, Your issue is more related to the IIS. I suggest you can go to the IIS forum for getting further help.

    Best Regards,

    Yong Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 30, 2018 3:08 AM