Skip to Content

External command to execute Batch file in Windows REMOTE desktop

we have to execute a external command from SAP server to trigger a batch file placed in remote desktop.

Our basis consultant successfully created a RFC TCP\IP connection in SM59 by the standalone gateway in the remote desktop.


SAP server running in Linux OS

Batch file placed in Windows OS as a Remote Desktop.

Now the question is how to frame the external command in SM69 to trigger the batch file in the windows machine by using the RFC connection ?

As we tried external commands is runnnig at OS level accepting only Linux commands

if we give a directory path as the external command and executing using the RFC connection it is always failing ... do we need to enable anything or write windows compatible shell command . Please suggest if this is workable ..

Add comment
10|10000 characters needed characters exceeded

  • Why do you need this? What is this mysterious batch file on a remote PC supposed to do? Why must it be triggered from the SAP server?

    Sorry but this kind of "architecture" sounds like something from the 80s. And not in a good way. If you can explain the end goal perhaps an alternative solution could be suggested.

  • Jelena, are you calling me old :) ... I beg to differ about the 80's - through most of the 90's it was still the most reliable way to connect to SAP "real-time"

  • OK, let it be 90s. It's ancient times either way. :)

  • Get RSS Feed

5 Answers

  • Apr 05, 2017 at 10:37 AM


    My suggest is trying to use simple different command as "ls" for unix or "dir" for windows and see what happens. If your problem is your actual working directory you should launch before an other command to change it. What do you mean with "RFC is always failing", what's the message?

    Hope to help


    Add comment
    10|10000 characters needed characters exceeded

    • You mean commands in test.bat?

      In that case I'm agree with Matthew, once you'll have a webservice on windows server that could be consumed, you can get an XML reply in ABAP.

      I put here some screen to show how could be a web-service call from ABAP to Windows System.

      For a windows web service implementation there are lot of documentation on internet.

      Hope to help



  • Apr 05, 2017 at 11:09 AM

    For a similar scenario, we created a web service on the windows server, that could be consumed from an ABAP program. The webservice ran a batch file with supplied parameters.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 05, 2017 at 09:57 PM

    Thanks matthew and Robert, In my case Windows machine is a remote desktop and we installed stand alone gateway for communication. Is this sufficient to create a webservice ? I will create a webservice with the help document and get back

    Meanwhile trying to understand what is the issue in the windows connect RFC connection, Can it not support to execute external commands or in other words just wanted to try that option if there is any workaround available as we already tried with this approach.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 08, 2017 at 09:30 PM

    I remember doing things like this many years ago... here is a little brain dump of what I remember...

    1) The program being executed on the remote system needs to implement an RFC connection back to SAP in order to let SAP know the call was successful

    2) The program could work without #1 above, but SAP wouldn't know

    3) The permissions to execute the program on the remote system were always tricky to setup - If everything else looked ok, I would bet this is your problem

    4) I think Matthew's WSDL idea would be easier to manage in the long run.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 10, 2017 at 12:11 PM

    To connect the external command to an RFC proceed as follows:

    1. Create an RFC (Type T) with the following options:

    a. Program: sapxpg

    b.Target Host: <your remote OS (e.g. IP)>

    c. Gateway Host: <your remote OS (e.g. IP)>

    d. Gateway service: <the gateway service of the installed SAP Gateway on the remote host>

    2. Create the external command in SM69/SM49 ==> Press Save and Press Execute ==> You will see another screen where you can specify the target destination (Target Dest.), created at point 1 ==> Execute the command in Dialog or create a Background job.

    Add comment
    10|10000 characters needed characters exceeded