How to call/Execute a dos batch file via LAN

Hello,
Can i execute remotely dos batch files?
I have to execute bat file via LAN ex
IP\dir\batfile.bat from abap code, is that possible?
thanks in advance,
Michal

Hi,
Use CL_GUI_FRONTEND_SERVICES=>EXECUTE method to run any application in your case batch file..
The batch file you are trying to run should be accessible on presentation system i.e. user's machine.
Regards,
Vishal

Similar Messages

  • How could I have a VI execute a DOS batch file?

    I need to update the PC's hardware timeclock and the Windows clock via a VI front panel. If I can update hardware and windows timeclocks from a DOS prompt (TIME/NEW TIME), is there a way to provide a LV interface for the same operation? If a VI could run a DOS batch file, having the operator enter a new time in a DOS prompt window is the next best thing.
    Thanks,
    Jeff Bledsoe
    Jeffrey Bledsoe
    Electrical Engineer

    tst wrote:
    The syntax is that of the operating system.
    Have you tried right clicking the VI and selecting Help?
    I found the online example by selecting help. I'm using LV 5.1 and I've noticed that offline help is not as detailed as it is with LV 7 Student Edition (I have student edition at home).
    In my latest attempts, I have the string "command.com /c time" wired to the command line input of system exec.vi. I get the dos prompt and a request for a new time.
    To avoid the operator having to enter the time in the DOS window, I tried passing carriage returns and a time update value in the command line input. It didn't work. Do I have to add a system exec.vi for each command line entry and concatenate the vi's somehow?
    Thanks,
    Jeff
    Jeffrey Bledsoe
    Electrical Engineer

  • Irregular delay while running a dos batch file using a servlet class

    i used RunTime( ) class to execute a dos-batch file containing some commands like changing the directory, running an exe(executable.exe) file...etc in a servlet class. while this servlet class is invoked, the exe file(executable.exe) is run after irregular delay at different trials.
    Note: When this batch file is run in a stand alone java class, it is working fine.
    what can be the possible cause of this prob? Help me in this.

    It's ok - I've found the answer.
    I'll post it here for anyone else who is interested.
    The problem stemmed from the fact that I had to put the path to javaw.exe in quotes, as the batch file is dynamically generated from the user's environment, and then run. The user's system properties gives a path to java home using a full path name, which WinNT/Win2K doesn't like.
    The following batch file content solves it, closing the DOS box after starting javaw.exe. Before this part of my batch file, there is just some file copying that goes on for the autoupdate process.
    set PATH=%PATH%;"D:\Program Files\JavaSoft\JRE\1.3.1\bin"
    start /B javaw.exe -Dmyapp.home=C:\myapp myapp.client.MyAppClient subSys
    exit
    The parameter subSys is just a command line parameter that MyApp.java looks for, so not relevant for everyone.
    /B prevents a second DOS box from opening.
    exit simply closes the DOS box once the javaw.exe process has started.
    Too easy! Although I can't believe how difficult it was to find information about this. Hopefully it will be of benefit to others.

  • DOS batch file

    Hi techies,
    Is there any way we can execute Ms-DOS batch file from a java program.
    Thanks..

    Runtime.exec("cmd /c thebatch.bat");
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • How do I stop ODI if my DOS BATCH file flags an error?

    I have a DOS batch file as the first step in my ODI package. How do I send a code to ODI to tell it that it has failed and to stop processing the rest of the package? I was told I could use an ODI variable to accomplish this but not sure how.
    Also, how do I pass a semaphore/flag an error in my DOS batch file to ODI ?
    Thanks in advance for your help.
    I tried to search for this info in John's blog: http://john-goodwin.blogspot.com/search?q=error
    but was not able to find it.
    :)

    In your package 1st step is OS Command then some other steps involved, right ?
    In that case you can have your package like this
    OS Command (first step) ---------OK--------------> 2nd step -------------------> 3rd step
    So your 2nd step will run only when the 1st step is successful, it will not start 2nd step as 1st itself has failed .
    Thanks,
    Sutirtha

  • Executing batch files via ODI cmd line tool

    Hi,
    I'm experiencing an issue when trying to run batch files via the ODI Cmmmand line tool with any agent that isn't the local agent. My call is simply the full filepath of the batch file. When I run with local agent everything works fine. However when I run with an agent configured in the Topology the process just hangs in the operator indefinately in a running state but never executes or produces any output and I have to kill it. Any ideas? The agent is installed on the same server as the ODI Studio instance I use when running the local agent

    Sounds like that on the remote agent, the batch job is waiting for a user key input and hence it appears in a hung state. You can add try to trace from Agent logs and echo combinations to know where is this happening
    In unix environment you can send keys programmatically. Not sure how to do that in the Windows environment.

  • Run a MS DOS batch file from the client

    Hi,
    I created a java source to run a bat file, the folder is loacted in the Database server.
    (Not in application server)
    create or replace and compile java source named execcommand as
    import java.io.*;
    import java.util.*;
    public class ExecCommand{
    public static void run(String cmdstr) throws IOException, InterruptedException
    try {
    int rtn;
    cmdstr = "cmd /c " + cmdstr;
    Process prcs = Runtime.getRuntime().exec(cmdstr);
    while (prcs.getInputStream().read() != -1 ) {}
    catch (IOException e) {
    e.printStackTrace();
    I called the java source from the procedure
    create or replace procedure run_batfile is
    begin
    execcommand(cmdtext => 'e:\services\genPDF.bat');
    dbms_output.put_line('file created successfully');
    exception
    when others then
    dbms_output.put_line(sqlcode || sqlerrm);
    end run_batfile;
    But the bat is not executing (The bat file is to generate a PDF file ). Bu when i executing this from my PC (Client PC) directly on the RUN , its generating the PDF file in the server.
    What could be the problem, What should be the path in the procedure,
    Shall i create any virtual directory ?
    Thanks in advance,
    Rizly

    Hi Justin ,
    Sorry for the late replay.
    I am running Oracle on Windows.
    The MS DOS Batch file is to convert XML file to PDF format. It is a Java Application.
    also it is a batch process, thats why i created a batch file for that. I am using FOP to convert XML to PDF.
    FOP is in the e:\services folder of the Database Server machiene. XML file is also in the same forlder and I need to generate the PDF file also in the same machiene.
    <<- You have a client machine. What do you mean by "executing this from my PC (Client PC) directly on the RUN , its generating the PDF file in the server.">>
    I have mapped the e:\services folder in my client machience, so i am accessible to the genPDF.bat file that is in the 'e:\services' folder of the DB Server. When i run the bat file from my PC as Start > Run e:\services\genPDF.bat . The PDF file has generated in the DB Server machien.
    I dont have the copy of the batch file in client machiene, but i have mapped to my client machiene.
    Thanks again,
    Rizly

  • How to call a exe or bat file from java program

    hi,
    i actually want to know that how to call a exe or bat file from program so that i can run them parallely.

    Try this :
    String strCmd = "myFile.bat";
    try
         Runtime rTime = Runtime.getRuntime();
         Process process = rTime.exec(strCmd);
         InputStream p_in = process.getInputStream();
         OutputStream p_out = process.getOutputStream();
         InputStream p_err = process.getErrorStream();
         p_in.close();
         p_out.close();
         p_err.close();
    catch(Exception e) {
         throw new Exception("Unable to start, "+strCmd);
    }

  • Scheduling unix shell scripts from windows using DOS batch files

    Hi,
    I want to schedule unix shell scrips using windows scheduled. I have the option of scheduling the DOS batch files. But not able to connect to telnet using DOS. Please let me know if there is an option.
    Regards,
    -Anand

    Drive letters are user specific. When you run jboss it runs as you, with your shared drives. When you run it as a service, it runs as guest or another user so your drive letters are meaningless.
    Either setup the user or use UNC

  • Execute a sql command in a DOS batch file

    hi
    can anyone help let me know if there is any way to
    achieve this objective.
    objective is as below
    There will be a batch file run from a DOS prompt
    This will generate a CSV file for a SQL query
    and dump it on the local machine.
    thanks and regards
    Ashish

    hi Ashish,
    try using this
    at the command prompt:
    sqlplus username/password@connect_string @scriptfile
    and the contents of the scriptfile should be
    spool file.csv
    sql select statement;
    spool off
    exit
    HTH
    Naveen

  • How to pass arguments to a batch file from java code

    Hi
    I have a batch file (marcxml.bat) which has the following excerpt :
    @echo off
    if x==%1x goto howto
    java -cp C:\Downloads\Marcxml\marc4j.jar; C:\Downloads\Marcxml\marcxml.jar; %1 %2 %3
    goto end
    I'm calling this batch file from a java code with the following line of code:
    Process p = Runtime.getRuntime().exec("cmd /c start C:/Downloads/Marcxml/marcxml.bat");
    so ,that invokes the batch file.Till that point its ok.
    since the batch file accpets arguments(%1 %2 %3) how do i pass those arguments to the batch file from my code ...???
    %1 is a classname : for ex: gov.loc.marcxml.MARC21slim2MARC
    %2 is the name of the input file for ex : C:/Downloads/Marcxml/source.xml
    %3 is the name of the output file for ex: C:/Downloads/Marcxml/target.mrc
    could someone help me...
    if i include these parameters too along with the above line of code i.e
    Process p = Runtime.getRuntime().exec("cmd /c start C:/Downloads/Marcxml/marcxml.bat gov.loc.marcxml.MARC21slim2MARC C:\\Downloads\\Marcxml\\source.xml C:\\Downloads\\Marcxml\\target.mrc") ;
    I get the following error :
    Exception in thread main java.lang.Noclassdef foundError: c:Downloads\marcxml\source/xml
    could some one tell me if i'm doing the right way in passing the arguments to the batch file if not what is the right way??
    Message was edited by:
    justunme1

    1 - create a java class (Executer.java) for example:
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    public class Executer {
         public static void main(String[] args) {
              try {
                   for (int i = 0; i < args.length; i++) {
                        System.out.println(args);
                   Class<?> c = Class.forName(args[0]);
                   Class[] argTypes = new Class[] { String[].class };
                   Method main = c.getDeclaredMethod("main", argTypes);
                   // String[] mainArgs = Arrays.copyOfRange(args, 1, args.length); //JDK 6
                   //jdk <6
                   String[] mainArgs = new String[args.length - 1];
                   for (int i = 0; i < mainArgs.length; i++) {
                        mainArgs[i] = args[i + 1];
                   main.invoke(null, (Object) mainArgs);
                   // production code should handle these exceptions more gracefully
              } catch (ClassNotFoundException x) {
                   x.printStackTrace();
              } catch (NoSuchMethodException x) {
                   x.printStackTrace();
              } catch (IllegalAccessException x) {
                   x.printStackTrace();
              } catch (InvocationTargetException x) {
                   x.printStackTrace();
              } catch (Exception e) {
                   e.printStackTrace();
    2 - create a .bat file:
    @echo off
    java -cp C:\Downloads\Marcxml\marc4j.jar; C:\Downloads\Marcxml\marcxml.jar; Executer %TARGET_CLASS% %IN_FILE% %OUT_FILE%3 - use set command to pass variable:
    Open MS-DOS, and type the following:
    set TARGET_CLASS=MyTargetClass
    set IN_FILE=in.txt
    set OUT_FILE=out.txt
    Then run your .bat file (in the same ms dos window)
    Hope that Helps

  • How to capture Java Exceptions in batch file

    I have a batch file that calls java class. When the java class throws exception, how do I capture the exception as an error message in batch file.
    This is the java program
    import java.io.*;
    public class Test{
           public static void main(String []args) {
         String wantThisToFail=null;
              try {
                   if (wantThisToFail.equals("SomeString") ) {
                        System.out.println("Testing");     
              }catch (Exception e){
                   System.out.println("Exception " + e);
    This is the batch file
    @echo off
    echo Testing
    REM execute the java class
    java Test
    set deployError=%ERRORLEVEL%
    echo %deployError%
    IF NOT %deployError% == 0 (
    echo failed
    )else (
    echo succeeded
    )Since the java class throws NullPointerException, i want the batch file to show "Failed" Message.
    Please Help!!

    Try capturing the return value of the command "java Test". If it succeeds, you should get a '0', otherwise you'll get something else. I admit it's been years since I had to do that, but it rings a bell. If it works, and you're on Java 5 or later, you can use the method Thread.setDefaultUncaughtExeptionHandler ( look at the docs ) and from there use System.exit(<your integer value return code here>) for more control over the return value

  • Off topic question in DOS Batch files ...

    Hi,
    I am sorry in advance, for posting an off-topic question. But I had no other known way.
    I need to invoke 8 sessions of a java program on 8 different windows. I use Windows platform. I want to write a batch file that will cause the java program to be invoked on a separate window, so that I can watch the execution of 8 sessions at a time. How can I do this (specifically, how can I open a new window in batch files in DOS)?
    Thanks in advance,
    K
    My java program invocation is like this:
    C:\>java Site i
    where i is a command line argument that will go from 0 to 7.

    Batch files (to my limited knowledge) are just "macros" that procedurally run DOS commands. It's just like opening a new command window and sitting there typing a list of commands, except the computer does it for you. So, for example, to run the commands java HelloWorld and cls, the java program would first have to execute before the screen can be cleared. For your purposes, you may need a small launcher app.

  • Problem while executing batch file via jsp

    Scenario 1+
    I have a batch file(.bat) in which i have the following code
    mkdir d:\test\test1;
    mkdir d:\test\test2;
    mkdir d:\test\test3;
    mkdir d:\test\test4;
    mkdir d:\test\test5;
    mkdir d:\test\test6;
    mkdir d:\test\test7;
    mkdir d:\test\test8;
    mkdir d:\test\test9;
    mkdir d:\test\test10;when i double click on this or execute via cmd all the 10 directories are created successfully.
    Scenario 2+
    But when i try to execute this through a jsp using the following code,Only first 5 directories are created.Please help me in resolving the issue ASAP.Thanks in advance
    <%@page import="javax.swing.*"%>
    <%@page import="javax.swing.JFileChooser"%>
    <%@page import="java.awt.event.*"%>
    <%@page import="java.awt.*"%>
    <%@ page import="java.io.*"%>
    <%@ page import="java.util.*"%>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
        <title>untitled2</title>
      </head>
      <body><%
            Runtime.getRuntime().exec("d:\\test.bat");
                    System.out.println("Inside Try Block");
                  %>
        hi</body>
    </html>I am using Jdeveloper.

    carrera wrote:
    Then can u suggest any other way how i can invoke a batch file from html/jsp.I think what some of the previous posters wanted to make clear is that jsps are not the place to go calling batch files. Jsp's are normally the view part and don't actually trigger these type of actions directly. Call a servlet to do non-view things...
    If all you want to do is execute an ant file, look for examples for running ant through java api. f.i. here

  • Help needed in executing a remote batch file

    I need to execute a batch file which is located on a remote machine through my machine. I have no idea to go about with. Please can someone help me out with can be used to execute the remote bat file. I am at present using Runtime.exec() to execute it on my machine.. But i cant use it to execute teh bat file on teh remote machine.Please help

    Below is an example server that would run on the remote host. You can connect to it using telnet from DOS prompt, it takes a Y/N to run your command in the cmd variable. I haven't included code for a client as it's really not needed for the example below.
    Change the cmd and port variables to what you need. You may need to setup firewall rules to allow your chosen port.
    Once it's running, you can test it by using "telnet localhost 1234" on your machine, localhost would obviously become the remote computer's hostname or IP.
    I am incredibly new to Java (using the forums to learn bits), so excuse any bad coding practises, I'm sure people will point them out.
    Keep in mind that this is totally insecure, so if you're using it on an untrusted network, you may want to look into encryption and providing some kind of password authentication, that, for the moment is out of my league.
    Screenshot here.
    import java.io.*;
    import java.net.*;
    class RemoteServer {
         public static int    port = 1234;           // Port to listen on
         public static String cmd  = "C:\\Test.bat"; // Command to run
         public static void main(String[] args)
              System.out.println("Waiting for connection...");
              try {
                   /* If you want the server to run forever, uncomment the while
                      loop */
                   // while (true)
                        startServer();
              } catch (IOException e) {
                   e.printStackTrace();
                   System.exit(1);
         /* Starts the server */
         private static void startServer() throws IOException
              ServerSocket server = null;
              Socket       client = null;
              String input;
              try {
                   server = new ServerSocket(port);
              } catch (IOException e) {
                   System.err.println("Unable to list on port " + port);
                   System.exit(1); // Can't listen, nothing else to do
              try {
                   client = server.accept();
                   System.out.println("Client connected... awaiting Y/N");
              } catch (IOException e) {
                   System.err.println("Unable to accept connection.");
                   System.exit(1);
              PrintWriter out = new PrintWriter(client.getOutputStream(), true);
              BufferedReader in = new BufferedReader(new InputStreamReader(
                                                     client.getInputStream()));
              out.println("You are connected, ready to launch command: <y/n>");
              while ((input = in.readLine()) != null)
                   if (input.equalsIgnoreCase("y"))
                        Runtime rt = Runtime.getRuntime();
                        rt.exec(cmd);
                        out.println("Command executed... disconnecting.");
                        System.out.println("Command executed... disconnecting client.");
                        break;
                   } else if (input.equalsIgnoreCase("n")) {
                        break;
                   } else {
                        out.println("Please enter Y/N.");
              out.close();
              in.close();
              client.close();
              server.close();
    }

Maybe you are looking for

  • How to make a field unique accross two or more tables?

    Hi Experts, We have a requirement where we need to establish uniqueness for accross two fields of two different tables. Consider the following example: Table Table1 has Field Field1 and Table Table2 has Field Field2. Table1>Field1 have the following

  • Need security management software for OS 8.6 through 9.2

    Are there any security management softwares available these days for OS 8.6 through OS 9.2? Something which lets the computer owner turn off firewire and USB is what I'm looking for. It would be nice to be able to allow only some selected USB devices

  • Firefox is installed, but not working

    from past 6 months am suing Firefox. yesterday morning, when i tried to open, it was not working. i clicked on Firefox logo, but there was no response or any error messages. i reinstalled it. but still not working.

  • How can I get Tiny Tower to work?

    How cn I make Tiny Tower work? It hs hung for nearly two weeks.

  • Leopard 10.5.2 - Mail sent but not recieved

    Hi I upgraded to 10.5.2 and have been having a strange problem with mail since then. I have 5 email accounts (4 yahoo and a gmail account) setup in mail and have checked all pop and smtp settings are correct. Since the upgrade although all messages e