Running a batch file - VERY URGENT .. help

Hi people
I am attempting to run a batch file from with a JSP page.
the code i am using is:
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("cmd.exe /c d:\\uploadfiles.bat");
This jsp file is located on the c: of a webserver.
the uploadfiles.bat is located on the d: of the webserver and the code is:
copy d:\videos\008214?.rm d:\blah
copy d:\images\008214.* d:\blah
copy d:\xml\008214.* d:\blah
cd \blah
pkzip -es -m 008214.zip *.*
copy 008214.zip d:\upload\008214.zip
del 008214.zip
If I run this batch file from a command line, it works fine, though when I try and call it through my JSP page, it doesnt do anything .. a command window just pops up for a while, and then closes.
How can I fix this ... I need this quite quickly
Thanks people

1) It is O.K. that you see nothing in that console. Its output is captured by Java and is not displayed on the screen.
In general, that console should not be visible, but actually it behaves differently according to JDK and OS versions (treat that as a feature).
2). Look at this article:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
It it does not answer your problem, try to search the forums:
http://search.java.sun.com/search/java/index.jsp?qp=%2Bforum%3A31&nh=10&qt=%2B%22exec%22+-%22Replies%3A+0%22&col=javaforums
Questions about Runtime.exec() has been asked hundreds of times.
3) runtime.exec() can execute BAT files. It is not necessary to specify that "cmd /C".

Similar Messages

  • Create a batch file "very urgent"

    i want to create a batch file that run every hour to update the user_status table fields according to the following formula
    if login = 1 and login_time status = 0 then login =3

    Write this statement into a text file and name it as
    say test.sql
    UPDATE user_status
       SET login = 3
    WHERE login = 1
       AND login_time = 0;Then write a script in UNIX as following
    $vi test_script.ksh
    !# /bin/ksh
    sqlplus `@test.sql`save it
    write a crom job for every hour.
    Codes not tested...
    Hope this helps
    Ghulam

  • Running a batch file in Java. Urgent!!

    I want to run a batch file present at a particular location in Java.Although I am running two codes suggested by many people, i am still not able to run the batch file. My codes run as below :-
    CODE 1
    Process P;
    Runtime rt = Runtime.getRuntime();
    P = rt.exec("C:\\test.bat");
    CODE 2
    Process P;
    Runtime rt = Runtime.getRuntime();
    P = rt.exec("C:\\WINNT\\System32\\cmd.exe C:\\test.bat");
    I have tried both these codes but without success. But I have observed that in the Task Manager, whenever i run the above codes in a servlet, a "CMD.EXE" is being created in the "Processes" Bar each time but the batch file neither opens up nor it runs.
    Please suggest me some method to run this batch file in Java.
    Or if u can suggest the reason behind the above observation and any corrections i can make to run the batch file. Thanks in advance.
    Ankit

    i want to get more than one command prompt while running the program
    am giving the problem
    import java.io.*;
    class CmdDemo
         CmdDemo(String ls) {
              try
              Process p;
              Runtime rt=Runtime.getRuntime();
              p=rt.exec(ls);
              catch(IOException ioe)
                   System.out.println(ioe);
         void showcmd(){
    new CmdDemo("cmd");
         public static void main(String args[])
              new CmdDemo("cmd");
              new CmdDemo("C:/WINDOWS/System32/cmd.exe");
              new CmdDemo("cmd");
              new CmdDemo("regedit");
              new CmdDemo("regedit");
              new CmdDemo("notepad");
              new CmdDemo("notepad");
              //CmdDemo cd=new CmdDemo("cmd");
              //cd.showcmd();
    here am getting two notepads ,two registry editors
    but only one command window
    i would be very greateful if u could help me
    plz reply to my id [email protected] too

  • Running a batch file : URGENT

    I want to run a batch file on click of a button. Please inform if it is possible and if yes then how.

    yes it's possible.
    look at Runtime.exec() in java documentation. If you can't figure it out, try posting in New To Java Technology Forum

  • How to run a batch file as windows Nt service

    Hi friends
    I want to know how to run a batch file as windows NT service.
    I got some information in the following link
    http://support.microsoft.com/kb/q243486/
    I tried it but i want to know what we need to include in Autoexnt.bat
    And one thing i need Instexnt.exe file. I cannot find tht file.
    Please search tht file and send me tht file or else send the link in which this file is present
    Please give me reply fast.its very urgent.
    Thanks in advance.

    Hi,
    My aim is to run a MS-DOS Batch file, that I created to run a Java Prgram.
    I need to call the Batch File from the Oracle Procedure, Also I may need to change the content of the Batch File (Argument to the Java JAR File ).
    I can keep the JAR FIle either in the Oracle Server or in the Application Server.
    The Java program is to convert XML Format FIle to PDF and MS Word format.
    Oracle Version : 10g 2.0.1.0.
    Thanks in advance
    Rizly

  • 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 inside a jar

    HI all
    I created a jar file , in which i need to run a batch file , so i wrote a main class to execute the run the batch file , but when iam running the jar it is searching for the given batch file out side the jar.
    my code is some thing like below
         public static void main(String args[])
              try
                   Runtime rt=Runtime.getRuntime();
                   Process process=rt.exec("%DIRNAME%/start.bat");
       InputStreamReader reader =
                      new InputStreamReader ( process.getInputStream () );
                   BufferedReader buf_reader =
                       new BufferedReader (  reader );
                    String line;
                    while ((line = buf_reader.readLine ()) != null)
                                 System.out.println (line);
              catch (IOException e) {
                    System.out.println (e);
         }so please help me.. is it the problem in specifing the path...?
    are does it have any other method to read the stream functions ..
    thanks in advance
    sam

    I don't think this will work. You could not go to a command line and enter, "%DIRNAME%/start.bat" if start.bat was inside a jar - the CLI doesn't know how to read a batch file inside a jar.
    I think it would work to programmatically read the lines of start.bat (when it is inside the jar) into an array of Strings and use Runtime.exec with the array as the argument.
    It would also work to extract the start.bat file, then execute it using Runtime.exec.

  • Running a batch file on  a web server

    hi,
    i am facing a problem regarding running a batch file(with a java command in that file) on a web server.
    i am having a batch file which is running a chatapplication (this file is having a single line -- "java ChatServer 8080")
    i want to execute this command ( file ) on my web server
    can u help me plz ( i think u can)
    thanx 4 reading my problem...
    -ashish

    thanx 4 replying
    but as i am a developer and i am developing the aplication for a client, so should i speak to the client for this or can i do this without interrupting them?
    -ashish

  • Run a batch file from demantra workflow

    I am trying to run a batch file from demantra's workflow by creating an executable step.
    I am getting the following error.
    Error description ’’Invalid command line:’’"D:\Oracle Demantra Spectrum\Collaborator\demantra\sop\populate_staging.bat"
    I am giving the following value in command line of executable step.
    "#application_root#\sop\populate_staging.bat"
    The batch file exists in the appropriate folder.
    Following code is in the batch file.
    sqlldr userid=msdem/msdem@demsbx control=load_item_hier.ctl
    Please help me.
    Thanks

    This should work for you-
    Create a batch file on your current server (ODI) and write in the path to the other batch file on the other server.
    //Server2completename/D$/Path/yourbatchfile.bat
    From ODI call your batch file that you created on the same machine.. which will inturn call the other batch file on a different machine to execute batch client.
    Also can you paste the errors that you may be getting.. need to check if you are getting any specific issue related to this.
    Thanks
    Denzz

  • Unable to run a Batch File Operating System Command

    Using XI 3.0, I am unable to run a Batch File Operating System Command After Message Processing.
    My Batch file:
    gpg -se -r BOA3RSKY --armor --passphrase-fd 0 %1 < C:\Progra~1\GNU\GnuPG\gpgin
    My Command Line (ID scenario)
    exec "cmd.exe /c C:\Progra~1\GNU\GnuPG\boagpg.bat %F"
    If I execute
    exec "cmd.exe /c type C:\Progra~1\GNU\GnuPG\boagpg.bat >xis.txt"
    It displays the contents of boagpg.bat file in xis.txt.
    I just don't understand why when I run the batch file, I would expect an %F.asc encrypted file in the same directory as the %F unencrypted file.
    Any ideas?
    or will I need Basis to create commands that will allow me to run GPG from XI Command Line?

    Check this links if its helpful
    http://help.sap.com/saphelp_nw04/helpdata/en/bb/c7423347dc488097ab705f7185c88f/frameset.htm
    /people/sap.user72/blog/2004/01/30/command-line-help-utility
    Check this thread a similar problem
    Process Integration (PI) & SOA Middleware
    Note 841704 - XI File & JDBC Adapter: Operating system command
    http://service.sap.com/sap/support/notes/841704
    Try to see the below links
    /people/michal.krawczyk2/blog/2005/08/17/xi-operation-system-command--error-catching
    OS Command on FTP
    OS command line script - Need help
    FTP - Run OS Command before file processing
    Note: reward points if solution found helpfull
    Regards
    Chandrakanth.k

  • How to run a batch file from within an Oracle 9i Form?

    Hi, I would like to execute a batch file from within an oracle form - I'm assuming there's some PLSQL command I can use? I am not allowed to use any third party libraries, and I'm hoping I can get away without having to progam any C or Java to do it. I don't want to run my java program from my form, but my lecturer is insisting on it.
    Can anyone help?
    Thanx
    Adam

    Can u give me an example
    I need to run a batch files that does a series of step doing dir ( in 3 different folders)
    after each one it shows on screen with a pause & user press enter
    can this work out ?

  • Run a batch file ones a month

    Hello there,
    i made a batch file and I want to run this batch file once a month on every client computer.
    is it possible to deploy the batch file with such an option?
    thanks in advance.

    The "Deployment" has a the option to schedule it on a recurring basis such as once per month.
    Nash Pherson, Senior Systems Consultant
    Now Micro -
    My Blog Posts
    If you've found a bug or want the product worked differently,
    share your feedback.
    <-- If this post was helpful, please click "Vote as Helpful".

  • How to run a batch file in a continous loop

    Hi.  PS noob.  I need to run a batch file frequently -- possibly every one minute.  Correct me if I'm wrong, but Task Scheduler can only schedule a task to run as frequently as every 5 minutes.  What would a PS script look like that would
    run a batch file, sleep for a minute or two, then loop?  Thanks.

    Hi District,
    I‘m writing to check if the suggestions were helpful, if you have any questions, please feel free to let me know.
    If you have any feedback on our support, please click here.
    Best Regards,
    Anna
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • Run a batch file by passing parameters

    Hi all,
    I want to pass a parameter(a filename) to an antivirus batch file.
    I then want to run that batch file.
    All of the above should be accomplished through a Java program.
    Pls help.

    hi
    u can do one thing
    read batch file and replace filename with your filename object as much times you want
    u need to read and write file in java
    see io and file api

  • Problems Force Running a batch file

    Hi There,
    I am trying to force-run a batch file to copy files from a local NBO Appliance to the C:\tmp directory on the user's workstation. The batch file lives at c:\tmp\branding.bat.
    I cant get the batch file to force run. Zen reporting advises that the batch file has distributed and launched successfully, however the files do not copy.
    However, if i click on the icon for the batch file app - the files copy no problem. I have tried running Workstation Associated and (Unrestricted) User Associated as well as Workstation - Force Run as User.
    Path to executable file:
    %*WinSysDir%\cmd.exe
    Parameters:
    /c "c:\tmp\branding.bat"
    Any ideas? The batch file has to refer to the P: drive as the application covers 40 different sites each with their own appliance containing source files.
    Running NBO2 - ZFD 4 Agent 4.0.1.60 - Clientless
    Desktop XP Workstations
    Thanks
    Thax

    Have the app object copy the batch file to the hard drive from the
    server and then run it locally. This should work with a Middle Tier server.
    thax wrote:
    > Hi there,
    >
    > I cant use the actual server name as this is an application which runs
    > through a middle tier server for multiple NBO sites so therefore needs to
    > use the P: reference...
    >
    >>>> kokoo<[email protected]> 9/03/2006 12:37 >>>
    >
    > TRY edit Scrirts:
    > #\\FS_SERVER_name\VOL\BATCH.BAT
    >
    > edit batch file:
    > xcopy "p:\nal\wxp\ZenPolicies\Branding\*.*" "C:\tmp\ZenPolicies\Branding\"
    > /s /v /e /y
    > ==>
    > xcopy p:\nal\wxp\ZenPolicies\Branding\*.* C:\tmp\ZenPolicies\Branding\ /s
    > /v /e /y
    >
    > "thax" <[email protected]>
    > *******:[email protected]...
    > Hi Jeremy,
    >
    > xcopy "p:\nal\wxp\ZenPolicies\Branding\*.*" "C:\tmp\ZenPolicies\Branding\"
    > /s /v /e /y
    > pause
    >
    > Thax
    >
    > >>> Jeremy Mlazovsky<[email protected]> 8/12/2005 00:20
    >
    > Can we see the contents of your batch file?
    >
    > thax wrote:
    > > Hi There,
    > >
    > > I am trying to force-run a batch file to copy files from a local NBO
    > > Appliance to the C:\tmp directory on the user's workstation. The batch
    >
    > > file lives at c:\tmp\branding.bat.
    > >
    > > I cant get the batch file to force run. Zen reporting advises that the
    >
    > > batch file has distributed and launched successfully, however the files
    >
    > > do not copy.
    > >
    > > However, if i click on the icon for the batch file app - the files copy
    >
    > > no problem. I have tried running Workstation Associated and
    > > (Unrestricted) User Associated as well as Workstation - Force Run as
    > User.
    > >
    > >
    > > Path to executable file:
    > >
    > > %*WinSysDir%\cmd.exe
    > >
    > > Parameters:
    > >
    > > /c "c:\tmp\branding.bat"
    > >
    > > Any ideas? The batch file has to refer to the P: drive as the
    > > application covers 40 different sites each with their own appliance
    > > containing source files.
    > >
    > > Running NBO2 - ZFD 4 Agent 4.0.1.60 - Clientless
    > >
    > > Desktop XP Workstations
    > >
    > > Thanks
    > >
    > > Thax
    > >
    >
    >
    Jeremy Mlazovsky
    Senior System Engineer - Enterprise Desktop
    UDit-Central Hardware Systems & Network Storage
    University of Dayton
    http://forge.novell.com/modules/xfmod/project/?udimage
    http://vmpconfig.sourceforge.net/
    http://regeditpe.sourceforge.net

Maybe you are looking for