Running a batch program

Hi,
I would like to run a batch program from a java class. plz advise me how to do it. Thanks in advance

hi ,
I tried this exact piece of code for running a bat file but it didn't work, only exes worked!!!
I got:
Exceptionjava.io.IOException: CreateProcess: c:\WINNT\system32\RemoteSend.bat error=2
Any suggestions why this happens!!!!
noha

Similar Messages

  • DATASET_TOO_MANY_FILES  exception while running a  batch program

    Hi Pals,
    Can you pls help on the exception above?
    When we run a particular batch daily, this ABAp dump with exception occurs. There are many file transfers and accesses happening while this job runs. COuld that be a problem?
    We tried changing the job timing, but still encountering the same problem.
    Hope you will help urgently.
    Thanks
    Leeza Thalakottur

    First check that you are doing a "close dataset" on any files you have finished with in your code... I've seen a lot of programs that don't do this specifically... you could also open a dataset, load the contents into an internal table, and close the dataset and then process the internal table (rather than having the dataset open for a long time during processing). 
    You can also stick a "catch exception" after the "open dataset" which may pick up the problem you are having e.g. something like (not syntax checked):
    open dataset p_fname
      for input in text mode encoding default. "Unicode
    catch system-exceptions dataset_cant_open = 4.
      do.
        read dataset p_fname into l_data.
        if sy-subrc eq 0.
          append l-data to lt_data.
        else.
          exit.
        endif.
      enddo.
    endcatch.
    if sy-subrc = 4.
    *" etc
    Jonathan

  • Running a java program via a batch file

    I am unable to run a java program from a batch file that I created.
    spiderpackage.EntryPoint is a class file which I am trying to run with a -v option to output something.What should I do to get the output?
    echo ^<html^>^<body^>
    echo hello^<br^>
    call java spiderpackage.EntryPoint -v
    echo ^</body^>^</html^>

    This has nothing to do with java programming. Have a look at the windows help for the call command.
    The echo <html> stuff doesn't make sense. What's it for?
    The command in you batch file should be:
    java -cp . spiderpackage.EntryPoint -v
    assuming that java is in the system path, and the EntryPoint.class is in a directory called spiderpackage which is a subdirectory of your current working directory

  • To run a java program via a batch file,when called from a web server

    REM This batch file runs the Spider with the [-v] option.
    REM Lines 51 through 54 are simple DOS commands..they call the Spider
    REM The location of the Spider package is the important piece of information here...
    REM a batch file has access to the whole computer where the server resides.
    setlocal
    set JDK=C:\j2sdk1.4.1_01
    set PATH=%JDK%\bin;.;%PATH%
    CLASSPATH=%JDK%\jre\lib\*.jar;.;%JDK%\jre\lib\ext\*.jar;.;%CLASSPATH%
    java spiderpackage.EntryPoint -v
    endlocal
    I am trying to run this batch file from my web server.I can see nothing on my browser.I can run the same program from my machine but unable to run from web server.what should I do?

    I am making my question more clear...
    I have a Windows batch (*.bat) file that echoes some html, then calls a java program the output of which is html as well, then echoes the final html.
    To make sure that the java program gets properly executed, I set the necessary environment variables (e.g., JDK, PATH, CLASSPATH, etc.). The script looks something like this:
    setlocal
    set JDK=path_to_JDK
    set PATH=path_to_java
    set CLASSPATH=path_to_java_classes
    echo ^<html^>^<body^>
    call java foo
    echo ^</body^>^</html^>
    endlocal
    The idea, of course, is to call this script through a browser, on a web server.
    Curiously, both echo lines return to the browser just fine, but any output from
    the java program (which just writes html to STDOUT) does not make it back.
    Can someone explain to me why this is happening? How do I set things up so that the output (STDOUT and STDERROR) from the java program make it back to the browser?

  • Windows task scheduler to run batch file running a java program

    I have created a batch file that runs my SendEmail program. The batch file is in the same directory as the java program. The only line in the batch file is
    java SendEmail
    This works fine from the command prompt but from the windows task scheduler it fails to function. Any help on how I can overcome this problem will be greatly appreciated.
    THanks

    Looks okay. The classpath is set, too, I guess? Btw, try running javaw instead of java. I may err, but I think it can show a console, so you can watch any error messages.

  • Attaching a document from program running in batch

    Hi experts,
    i need to find a way, to attach a document (e. G. a CV) to an applicant via object services. Problem is, the document will be provided by a program, running in batch-mode without front-end access. I tried to debug the manual action, but unsuccessful.
    My initial idea was, to find out what happens directly after uploading and then using the same function modules in my prog.
    Shed your light on me please.
    regards
    Jörg

    Hi Jorg,
    In a way when the batch job runs it polls that document and you need to attach that doc to an applicant. Firstly , I don't know whether debugging can help. But normally I had almost the same situation wherein I needed to change something to the file that was being used by the batch job and I didn't know where the file was.
    There's a T-Code 'FILE' that I had used which gives you the location of all the files from where the batch job or the program picks them whenever they get executed.
    But in my case even this didn't help. Then I had to ask the respective guys as to where it was stored. Maybe you could try the above t-code or if you do have time, again check using de-bugging for any logical path mentioned in the code.
    Please let me know if this could help.

  • How to run a ABAP Program in Batch JOB

    How to run a ABAP Program in Batch JOB ?

    Hello Manish,
    Using transaction SM36 you can define the batch job along with the start conditions for that job.
    1. Transaction SM36.
    2. Give the Z name of the job in the 'Job Name' input field.
    3. Click on 'Steps' button from the application toolbar.
    4. On the 'Create Step 1' dialog box, give the name of the ABAP program in the 'ABAP Program' section' along with the variant.
    5. Click on 'Check Input' button from the dialog box.
    6. Click on 'Save' button from the dialog box once the check is successful.
    7. One list will be shown. Click on Back button from the standard toolbar.
    8. Click on 'Start Conditions' button from the application toolbar. Specify the start condition e.g. immediate. Click on save.
    9. The job staus is now scheduled.
    10.Click on Save button from the standard toolbar of SM36. The job status will be released.
    Using SM37 you can monitor the status of the job.
    This will sort out your problem.
    PS If the answer solves your query, plz reward points.
    Regards

  • How to run batch programs using SUBMIT command without any interaction need

    Hello ABAP gurus,
    I have created a batch program in SE38 which calls many other SE38 Programs (Reports).
    I have used the command SUBMIT to call the sub programs. There are about 15 sub programs that this main batch program is calling.
    It works fine, but after calling each subprogram it stops and I have to manually click on 'Back Button' in green on the sap screen to run the next program in the list. Like this I have to do 15 times to run all the programs in the batch.
    Is there a way to avoid this manual intervention and make the program run all the sub programs on its own.
    Your feedback will be highly appreciated.
    Thanks
    Ram

    Thanks Sampath for the response.
    Yes I am using the option "AND RETURN". So it is coming out of each sub program, and it is at this stage it waits for me to click on 'backward green arrow' to continue to the next.
    Here is the code I have used
      SUBMIT Z_AS_BI_F0005_EXTRACT WITH S_DATE IN S_DATE WITH P_TEST = 'N' AND RETURN.
      SUBMIT Z_AS_BI_DIVISION_EXTRACT WITH S_DATE IN S_DATE WITH P_TEST = 'N' AND RETURN.
      SUBMIT Z_AS_BI_COMPANY_EXTRACT WITH S_DATE IN S_DATE WITH P_TEST = 'N' AND RETURN.
      SUBMIT Z_AS_BI_CUSTOMER_EXTRACT WITH  S_DATE IN S_DATE WITH P_TEST = 'N' AND RETURN.
      SUBMIT Z_AS_BI_BRANCH_EXTRACT WITH S_DATE IN S_DATE WITH P_TEST = 'N' AND RETURN.
      SUBMIT Z_AS_BI_BUS_UNIT_EXTRACT  WITH S_DATE IN S_DATE WITH P_TEST = 'N' AND RETURN.
      SUBMIT Z_AS_BI_ADDRESS_EXTRACT WITH S_DATE IN S_DATE WITH P_TEST = 'N' AND RETURN.
      SUBMIT Z_AS_BI_CUSTOMER_GROUP_EXTRACT  WITH S_DATE IN S_DATE WITH P_TEST = 'N' AND RETURN.
      SUBMIT Z_AS_BI_GROUP_EXTRACT  WITH S_DATE IN S_DATE WITH P_TEST = 'N' AND RETURN.
      SUBMIT Z_AS_BI_PMT_TERMS_EXTRACT  WITH S_DATE IN S_DATE WITH P_TEST = 'N' AND RETURN.
      SUBMIT Z_AS_BI_REGION_EXTRACT  WITH S_DATE IN S_DATE WITH P_TEST = 'N' AND RETURN.
      SUBMIT Z_AS_BI_TERRITORY_EXTRACT  WITH S_DATE IN S_DATE WITH P_TEST = 'N' AND RETURN.
    Any other suggestions or feedback will be appreciated.
    Tks
    Ram

  • Running an External Program from Batch on Windows Server 2008R2 Failing

    Hi,
    I am trying to run an external program from a batch job and it is failing with this error message:
    Ext. prog.: ERROR: Input redirection is not supported, exiting the process immediately.
    Ext. prog.: External program terminated with exit code 1
    The program I am trying to run is:  timeout
    This command works on the OS: timeout -t 30
    I have setup the step to look like this:
    Under External Program:
    -Name: timeout
    -Parameter: -t 30
    I have also tried:
    -Name: timeout -t -30
    -Parameter:
    I am running ECC 6.04 on top of Windows Server 2008R2 with SQL Server 2008R2. 
    When we were running in Server 2003 on ECC 6.0 I was able to use the Sleep program just fine in the same manner.  I have found out that sleep is not available in server 2008.  It was replaced with timeout.
    After an update to EHP4 and moving to Windows Server 2008R2, Is there any pre-work that needs to be done on the SAP or Windows side before we can run external programs?
    Thank you,
    Neil

    > SAPService<SID> and <SID>ADM both have Administrator rights for the server.
    > That means they should have full access.
    No - this is no more true like that since Windows 2008, it's a bit more complex:
    http://en.wikipedia.org/wiki/User_Account_Control
    > Where would you setup the permission/policy to "interact with the desktop"?
    Add the policy using group policy editor (gpedit.msc)
    Markus

  • Cannot run batch program from Java Application

    Hi All,
    Im trying to run a batch file under windows from my Java Program. The batch file is located in the following path:
    C:\Program Files\MyApp\runme.bat
    The above-entioned path contains white space which is not allowed in NT.
    Im trying following code:
    import java.io.*;
    public class Exec {
    public static void main(String args) {
    try {
    Runtime.getRuntime().exec("cmd /c start C:/Program Files/MyApp/runme.bat");
    }catch(Exception ex){ ex.printStackTrace();}
    How to run this file?
    Thanks in advance.
    Ketan Malekar

    or use the overload that takes an array of strings as argument
    String[] command = {"cmd", "/c", "start", "C:/Program Files/MyApp/runme.bat");
    Runtime.getRuntime().exec(command);

  • Batch program run

    Hi Gurus,
    Can anybody please provide details on batch program run? How do we set these program? Is there any dcoumentation which I can use?
    thnaks,
    Khan

    Hi
    You can execute any program through background.
    Initially you need to create a variant using SE38
    In se38, give the program name and execute,
    In the screen, enter your required parameters and save them as variant
    with a name and description.
    Some parameters, you may require as dynamic, eg. range of dates,
    for which, select the "Selection variable - check box" against the parameter.
    and press Selection variable button on left hand top.
    here select the date form, it will chagne to green.
    Then, you may give the date range from the pull down menu. and Save the variant.
    Then enter SM36,
    Give the batch job name.
    Press on steps button,
    Give Program and select variant.
    Give user , Spool recepient and print specifications etc., to your requirement.
    and for second program, pick the earlier program line item and again pick STEPs icon.You may proceed with the same step and save.
    The batch job will be scheduled now.
    Then enter SM37 - here you can monitor the batch jobs.
    Here, you may give program name and execute,
    In next screen, select the batch job and press"start conditions"
    Give, batch job run date, and time and its frequency.
    In case of repeat batch job, please select periodic values and save.
    and save the batch job.
    Now, batch job is released and will run in the time and date specified.
    Hope this helps you
    Regards
    Sasi

  • How to run the Batch input session(SM35) in background thru Report program

    Hi Experts,
    I am working in one modification report requirement ,the report is Mass upload will update and run the file via batch input session. The client requirement is to implement the report execution in background mode , the batch input session will process automatically (ie. the job runs the batch input session in background and process the session ends).
    Currently, the report calls SM35 to write a batch input session and the user manually selects the session and record the transactions.
    Once the Transaction enters and the selection-screen inputs are given, then the transaction executed in background mode and all the above batch input process to be implemented.
    Please advise and guide me, how to proceed.
    I need your guidance to proceed via Call transaction using bdcdata statement, if it can be achieved the requirement.
    Thanks & Regards
    San.

    Hi Arabind Prasad,
    Thanks for your inputs.
    I know the process of the report Execution in background and job steps.
    I want the inputs for how to upload thru Batch input session in background job and the session should also processed automatically
    Currently the report logic declared like call transaction 'SM35' and skip first screen.Once the report (tcode) executed (not in background) It writes one session in SM35. The user should select the session and process the transaction manually.
    The new requirement is, if the report (tcode) executes in background mode...what and how the batch input session should be declared and how it process automatically (like you said mode 'N').
    Hope I am clear in my query.
    Please advise.
    Regards
    San.
    Edited by: San Learner on Mar 1, 2011 7:16 PM

  • Running a batch file in a java servlets programme

    this is what i have
    Process p = Runtime.getRuntime().exec("C:\\sync.bat");
    Now i need a way for the program to wait until this is finished running. I dont want to print anything until this is done. Is there a way to do this

    Will this even run sync.bat or do i have to do more.Here is my entire code
    import java.io.*;
    import java.io.File;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.swing.*;
    public class index_test extends HttpServlet
         public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
              res.setContentType("text/html");
              PrintWriter out = res.getWriter();
              out.println("<HTML>");
              out.println("<body>");
              try
                   Process p = Runtime.getRuntime().exec("C:\\sync.bat");
                   String dir = "C:\\Perforce";
                   File what = new File(dir);
                   String [] listy = new String [100];
                   String [] products = new String[5];
                   String lists;
                   listy = what.list();
                   out.println("<form action =getBuilds Method = get>");
                   out.println("Please select which Product you wish to search in: ");
                   out.println("<br>");
                   int j = 0;
                   if(listy[j] != null)
                        products[j] = listy[j];
                        j++;
                   int i =0;
                   for(i = 0; i<listy.length && listy[i] !=null;i++)
                        out.println("<input type ='radio' name = 'product' value='"+dir+"\\"+products[i]+"\\build'>");
                        out.println(products);               
                        out.println("<br>");
                   out.println("<input type ='submit' value ='Submit'>");
                   out.println("<br>");
              catch(IOException e){}
              out.println("<img src='C:\\tomcat4\\webapps\\Tracker\\dancing2.gif'>");
              out.println("</form></body></html>");
    What i need is to run sync.bat, wait till its finished then print out the folders in the Perforce directory. I can print out the contents of Perforce grand i just dont know how to run the batch file and get the progeam to wwait until its finished

  • Running a batch file

    String path = "";
    path = "cmd /c start FCall.bat";
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(path);
    //proc.destroy() ; The code works fine, however, I need some help in exiting the command window. After executing the batch file the window should close. I have tried "destroy" didnt work it kills the entire process. Is there a function I am missing to accomplish this ?

    warnerja,
    I am compiling my program through command prompt. One of my method that contains the above mentioned code, runs the batch file. In doing so, it opens cmd.exe window. I want that window to be closed once the batch file ends running.
    The path associated with the cmd.exe is the same as the path where I am compiling my java code.
    Any suggestion ?

  • Running a Batch file through SCCM

    I have an installed Endpoint security program installed on 1800 systems in our domain. I have a batch file that is succesfully when run on a system. The batch is below. I've starred the sensitive info and path, (thing to remember is this batch
    works on a target system).
    REG ADD HKLM\SOFTWARE\***\***\Input /v PSUrl /d "*********" /f
    REG ADD HKLM\SOFTWARE\***\***/v *******/d 1 /f
    SC control *****232
    SC control *****225
    msiexec /x {*********************} /qn UNINSTALL_PASSWORD=******** REBOOT=ReallySuppress
    Exit /B 0
    The first 4 lines migrate where the software points to a new server, the second phase removed the software (permitted following the move). following the msiexec /x is the msi registry key of the software to be uninstalled.
    I can see the job has been sent to the test clients and been accepted by them however thats it nothing happens after that.
    Question 1 - can anyone give me a step by step of running this batch through SCCM as I'm obviously doing something wrong.
    Question 2 - Which Client SCCM logs do I look in to see what happens after the batch hits the client.

    Hi Jason,
    Yes to all of the questions above:
    Created Package; set distribution point, linled the programs (command line "programname.bat" also tried "programname.cmd"
    Created advertisment and schedule targeting collection. Nothing appears in execmgr.log
    Something should appear in execmgr.log.  I'm assuming the client is a member of the collection, the advertisement available time has passed, and the mandatory assignment time has passed?  I'm also assuming that other advertisements are working
    on that client? 
    If so, that information should be in execmgr.log.  You should be able to search for the advertisement ID and the package ID.  Otherwise, no there are no special tricks to make a batch file run via SCCM advertisements.  You should see that
    command line launched in execmgr.log.

Maybe you are looking for

  • Garageband sounds goes missing in the middle of the project

    in the middle of my projects I get a "file not found result error = -43" when I click on garageband sounds. I copied the sampler instrument folder from garageband and placed it in the sampler instruments folder in logic. But they still load up and in

  • Box in MAIN window of sapscript keeps misaligning...

    Hello Experts, I am currently modifying a sapscript and inside the MAIN window, there is a box command that 'boxes' a static text. But the problem is, the box misaligns since the number of line items is dynamic. So, how can I make the box command to

  • Recovering a project in iMovie 3???

    So I was working on a project and saving often. iMovie 3 then quit unexpectedly, and when I reopened it, my clips were all still there, but back in the clip panel (not in the project)? How can I restore my work without having to re-order my clips? An

  • Transferring Plans from SOP to CO-PA

    Dear Friends I am working on the integration of SOP and CO-PA, can you plz let me know the configuration relating to the transfer of SOP(Flexible planning) plans to CO-PA an Vice versa, if possible also the steps(transactions with codes) for transfer

  • Apps installed but won't let me access them

    i have installed a couple apps onto my computer that is a windows 8 computer and whenever I got to access them it will not let me access them. It takes me to the description page.