18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

_execute command cannot run batch file

yanyan Members
edited November -1 in Sahi - Open Source
Hi!

I'm new to sahi and am having a problem running a batch file using the _execute command. I tried

_execute("C:\sahi\scripts\call.bat")

but it will not work.

The batch file contains an executable file that I want to run in sahi. I tried to run the batch file only and it works just fine.

Is there another way to run an executable file in sahi that does not anymore include the need of a batch file?
Do the batch and .exe files have to be in the same directory as the script?

Would really appreciate help.

Thanks!

Comments

  • narayannarayan Administrators
    Escape the backslashes and check.

    _execute("C:\\sahi\\scripts\\call.bat");

    Since Sahi's working directory is sahi/bin, make sure that the batch file runs correctly from there.
  • yanyan Members
    Hi Narayan,

    Thanks for the advice. Unfortunately, your suggestion still could not run the batch file. :( Is there any other way to execute a batch file in a sahi file?

    Thanks!
  • narayannarayan Administrators
    Can you tell me what the output on the Sahi console is when you execute this?
  • DonnaMooresDonnaMoores Members
    edited October 2008
    I use
    __setGlobal("resetDir", "C:\\\\Users\\\\");
    _execute(_getGlobal("resetDir") + "compileClearDatabase.bat", "true");

    the execute command is defined as:
    _execute(command, isSynchronous)
    
    The parameters are:
    
        * command: command to be executed
    
        * isSynchronous: true or false.
          Set this to true if you want the script to wait till the process returns. Setting this to false will execute the command in a thread and continue.
    
    Hope this is of help.

    Donna
Sign In or Register to comment.