Error : How to execute *.BAT file

Some of the friend said me to execute any file following code
Runtime rt=Runtime.getRuntime();
Process pr=null;
pr = rt.exec("cmd.exe /c start " + "myfilename");
I get error as
CreateProcess: cmd.exe /c start myfilename error=0
Press any key to continue . . .
what is cmd.exe /c start in exec().
Thanks..

hi Bhavin
try this code because i had the same problem an d this thing works for me here is the code
    // Get file name
    String File_Name = // What ever yr file name get as String
    // Get Operating System Name
    String os_name = System.getProperty("os.name");
    os_name = os_name.toUpperCase();
    // Declare command as array of string
    String[] command ;
    // on Windows XP, NT, 2000 command is different and on win 98, 95 is different
    if(os_name.indexOf("XP") != -1){
         command = new String[] {"cmd", "/C", "start", "\"\"", File_Name};
    else if(os_name.indexOf("NT") != -1){
         command =new String[] {"cmd", "/C", "start", "\"\"", File_Name};
    else if(os_name.indexOf("2000") != -1){
         command = new String[] {"cmd", "/C", "start", "\"\"", File_Name};
    else  {
         command = new String[] {"start", "\"\"", File_Name};
    try
        // Run the commands using Runtime
        Process process = Runtime.getRuntime().exec(command);
    catch(IOException ioe)
        //show Error message
              JOptionPane.showMessageDialog((Component) null,
                                      "Unable to Locate the file..."+
                                      "\n"+ioe.getMessage(),
                                      "Error...",
                                      JOptionPane.ERROR_MESSAGE);
    }Regards
Satinderjit

Similar Messages

  • How to execute .bat file within pl/sql block

    Hi,
    I want to execute a batch file (.bat) file withing a pl/sql procedure. Please guide me for it.
    Regards

    There are several possible ways to make a call-out from a PL/SQL program to the OS on the database server (but not to the client computer).
    You could use java or an external procedure (you'll need to code it in C) for example.
    You might be able to make use of UTL_HTTP to talk HTTP to another server or UTL_TCP to talk TCP to another server.
    What is it you are trying to do?

  • How to execute *.BAT file from  the Java Application

    Hello to all.
    I wants to run *.BAT file form my applicaion.
    Can u give the code of that two-four line,please
    Wating four your replay.
    Yours Friend
    Bhavin Shah.....

    pr = rt.exec("cmd.exe /c start " + yourProgramName)The exec() method executes the command you specify in the argument and returns a process. In this example, it's telling Windows to run "yourProgramName".
    HTH

  • How to execute .bat file through java?

    I already create a batch file to pull & push file. Now, i want to execute this .bat file java.I got this example but it doesnt work. Did i missed something or do we have the better one?
    import java.lang.*;
    import java.io.*;
    public class Loadfile
    public static void main(String args[]) throws IOException
    Runtime load = Runtime.getRuntime();
    r.exec("C:\\pull.bat");
    }

    For Runtime,i'd change it to:
    Runtime load = Runtime.getRuntime();
            String cmd = "C:\\javaclass\\copytemp.bat";
            Process proc = load.exec(cmd.toString());Is it right? But still can't work.
    Here is the .bat file:
    @echo off
    c:
    cd "c:\Inetpub\ftproot\Debitin"
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo open localhost
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo Administrator
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo password
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo cd ftpScript
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo binary
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo lcd C:\
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo lcd "C:\Inetpub\ftproot\infile"
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo prompt n
    pause
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo mget *.txt::@rem >> C:\Inetpub\ftproot\Logrecord\pullscript.txt echo mdel *.*
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo byeftp.exe -s:C:\Inetpub\ftproot\Logrecord\pullscript.txt
    ::del C:\Inetpub\ftproot\Logrecord\pullscript.txt
    pause
    exit
    [\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to execute Bat Files using Jobs?

    Hello, can anyone help me?
    I have created a job like this, but it's not working:
    begin
    dbms_scheduler.create_job(
    job_name => 'job_test'
    ,job_type => 'EXECUTABLE'
    ,job_action => 'C:/temp/test.bat'
    ,start_date => '01/DEC/2006 08:30 AM'
    ,repeat_interval => 'FREQ=DAILY'
    ,enabled => TRUE
    ,comments => 'Demo for job schedule.');
    end;
    begin
    DBMS_SCHEDULER.run_job (job_name => 'job_test',use_current_session => false);
    end;
    Thx!

    Hi,
    This will not work because a batch file is not directly executable. It is executed using cmd.exe .
    So what you need to do is to set c:\windows\...\cmd.exe as the job_action and then as your arguments set
    /q
    /c
    c:\test.bat
    then enable the job. This should work.
    Also make sure the job scheduler service is setup and started (it needs to be started for external jobs to run).
    There is an example given by scotttig in this thread
    Re: dbms_scheduler
    Hope this helps,
    Ravi.

  • How to execute batch file from JSP

    hi frens !
    i wanna know how to execute batch file from my JSP.i am using exec() method to get call the batch file. but its not working ....plz help
    here mine code:-
    File F = new File("C:/var.bat");
         try{
          if (F.exists())
            Runtime rt = Runtime.getRuntime();
            String url=F.getAbsolutePath();
             Process proc = rt.exec(url);
            proc.waitFor();
            proc.destroy();
            catch(Exception IOEx){
           System.out.println(IOEx);
      }Thanks and Regards
    Allwyn

    You might improve your chances of getting help if you do two things:
    1) Explain what "not working" means.
    2) ChangeSystem.out.println(IOEx); to IOEx.printStackTrace(); (in the eventhat is in fact related to "not working").

  • Executing bat file without using Runtime.exec()??

    Hi all
    From my java App ,I am running a bat file. This is what I did:
    When I press 'execute' button inside my App, it runs a bat file through Runtime.exec() method. Since exec() runs it through cmd.exe, get a DOS window when I press Execute button. If I manually runs my app from command promt , I dont get it. But I have to create a short cut of my main class in the desktop. This is happening when I run my app from desktop icon.
    Now I want to eleminate DOS popup everytime I press execute button. Would anyone pls give an idea how to run bat file without using Runtime.exec()? Any suggestion will be helpful.
    Thanks

    jscell
    Thanks for taking time to answer to my problem .
    Here is what my problem: I create a shortcut of my main class in the desktop. Through this shortcut ,I run my java App. My App has a execute button, When I press this button , It run another bat file through Runtime.exec() method, and show some result in the result PAnel. NOw what happen , I get a DOS command window , everytime I press execute button. , Which is very annoying . But If I run my App thorugh command promt by executing: "java myApp", then I dont get this DOS popup. But I have to create a shortcut in the desktop, so other can use it conveniently.
    NOw I am not sure why I am getting this DOS window in the middle of my Application. IS it for using Runtime.exec() method? or for running bat file through my application? Can anyone pls tell me? I am kind of new to java, and I am learning lot of stuff from this forum .
    Would u pls suggest me about how to eleminate this DOS popup when I press execute button.
    Regrds

  • APEX: How to execute Script file from APEX

    Hello All,
    Can anyone tell me how to execute script file from APEX?(Step by Step process)
    Thanks & Regards,
    Jiten Pansara

    http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21677/sql_rep.htm#AEUTL193
    Regards,

  • Executing *.bat file from PL/SQL

    Is there anyway for Executing *.bat file from PL/SQL ?
    Thanks

    Try here:
    asktom.oracle.com/pls/ask/f?p=4950:8:15427268967155079552::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:952229840241

  • Variable not set (error 91)/Error during import (error 102)/execut bat file

    We are on BO 11.5.0.0 and using the COM SDK with Visual Basic to run multiple reports (sometimes multiple flavors of the same report) through a bat file.
    If we run the reports single-threaded through the bat file, the reports run fine.  However, if multiple versions of the bat file start at approximately the same time, we get one of two errors:
    91 Object variable or With block variable not set
    102 Error during import document -
    Here's the part of the code with the problem:
    Dim BOapp As busobj.Application
    Dim receiveDoc As busobj.Document
    Set BOapp = New busobj.Application
    BOapp.Interactive = False
    BOapp.Logon strUser, strPass, strFromSystem, "Enterprise", False, False
    BOapp.Visible = False
    Set receiveDoc = BOapp.Documents.OpenFromEnterprise(strFromRep, strFromFolder, boFolder)
    receiveDoc.SaveAs (strDocumentPath & strFromRep & ".REP")
    Values for the following variables are passed in from the bat file:
    strUser
    strPass
    strFromSystem
    strFromRep
    strFromFolder
    strDocumentPath
    If it fails on the OpenFromEnterprise statement, we get the 102 error.
    If it fails on the SaveAs statement, we get the 91 error.
    Running it through debug hasn't helped, since we are running only one report.
    Any thoughts on what could be going wrong?
    Thanks in advance

    I have tried this running the VB code on my desktop (outside of the bat file) and nothing out of the ordinary occurs.  The VB code runs fine with only one occurrence.
    I had seen on other posts "ThisDocument" and didn't know if it would be applicable in this situation.  I also wasn't sure how it should be used based on the rest of my code.  Would "ThisDocument" make a difference?
    Thanks again

  • Getting error while running ua.bat file of Oracle Data Integrator 12cR1 (12.1.2.0.0) version

    Hi,
    I am using windows 7 professional(service pack 1) 64 bit operating system.
    After installing the odi 12c (enterprise edition) by executing the odi_121200.jar file I am getting the following error while trying to run the ua.bat file.
    [2013-10-24T16:49:07.861+05:30] [Framework] [INCIDENT_ERROR] [UPGAST-00056] [upgrade.Framework] [tid: 1] [ecid: e9250ad8-50dc-45fe-83f5-5c01e7a7dcb4-00000001,0] error initializing upgrade plug-in for ODI.ODI1
    [2013-10-24T16:49:07.861+05:30] [Framework] [INCIDENT_ERROR] [] [upgrade.Framework] [tid: 1] [ecid: e9250ad8-50dc-45fe-83f5-5c01e7a7dcb4-00000001,0] Cause: An unexpected error occurred initializing an upgrade plug-in.
    [2013-10-24T16:49:07.861+05:30] [Framework] [INCIDENT_ERROR] [] [upgrade.Framework] [tid: 1] [ecid: e9250ad8-50dc-45fe-83f5-5c01e7a7dcb4-00000001,0] Action: Contact Oracle Support Services.  See the secondary error message for additional details.
    [2013-10-24T16:49:07.861+05:30] [Framework] [INCIDENT_ERROR] [] [upgrade.Framework] [tid: 1] [ecid: e9250ad8-50dc-45fe-83f5-5c01e7a7dcb4-00000001,0] [[
    java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
      at oracle.ias.update.plugin.Plugin.instantiatePlugin(Plugin.java:248)
      at oracle.ias.update.plugin.Plugin.<init>(Plugin.java:229)
      at oracle.ias.update.plugin.Plugin.getPlugin(Plugin.java:180)
      at oracle.ias.update.plan.PlanStep.getPlugin(PlanStep.java:335)
      at oracle.ias.update.plan.PlanString.<init>(PlanString.java:66)
      at oracle.ias.update.plan.PlanCustom.<init>(PlanCustom.java:74)
      at oracle.ias.update.plan.PlanStep.<init>(PlanStep.java:189)
      at oracle.ias.update.plan.PlanComponent.<init>(PlanComponent.java:203)
      at oracle.ias.update.plan.Template.load(Template.java:161)
      at oracle.ias.update.plan.Template.loadAllTemplates(Template.java:102)
      at oracle.ias.update.UpgradeDriver.loadConfiguration(UpgradeDriver.java:838)
      at oracle.ias.update.UpgradeDriver.main(UpgradeDriver.java:257)
      at oracle.ias.update.UpgradeDriver.main(UpgradeDriver.java:175)
    Caused by: java.util.MissingResourceException: Can't find oracle.ias.update.plugin.odi.bundle.ODIResourceBundle bundle
      at java.util.logging.Logger.setupResourceInfo(Logger.java:1518)
      at java.util.logging.Logger.<init>(Logger.java:265)
      at java.util.logging.Logger.<init>(Logger.java:260)
      at oracle.ias.update.UpgradeLogger.<init>(UpgradeLogger.java:60)
      at oracle.ias.update.UpgradeLogger.getLogger(UpgradeLogger.java:93)
      at oracle.ias.update.LoggingManager.create(LoggingManager.java:249)
      at oracle.ias.update.plugin.UpgradePlugin.createPluginLogger(UpgradePlugin.java:195)
      at oracle.ias.update.plugin.UpgradePlugin.<init>(UpgradePlugin.java:181)
      at oracle.ias.update.plugin.odi.ODIPlugin.<init>(ODIPlugin.java:136)
      ... 17 more
    [2013-10-24T16:49:07.869+05:30] [Framework] [ERROR] [UPGAST-00259] [upgrade.Framework] [tid: 1] [ecid: e9250ad8-50dc-45fe-83f5-5c01e7a7dcb4-00000001,0] The getInitialValue method for plug-in ODI.ODI1 will not be called due to a previous error.
    [2013-10-24T16:49:07.869+05:30] [Framework] [ERROR] [] [upgrade.Framework] [tid: 1] [ecid: e9250ad8-50dc-45fe-83f5-5c01e7a7dcb4-00000001,0] Cause: An error occurred when loading or initializing the plug-in which prevents the getInitialValue method from executing.
    [2013-10-24T16:49:07.869+05:30] [Framework] [ERROR] [] [upgrade.Framework] [tid: 1] [ecid: e9250ad8-50dc-45fe-83f5-5c01e7a7dcb4-00000001,0] Action: Review the log file for additional details.
    [2013-10-24T16:49:07.870+05:30] [Framework] [INCIDENT_ERROR] [] [upgrade.Framework] [tid: 1] [ecid: e9250ad8-50dc-45fe-83f5-5c01e7a7dcb4-00000001,0] UPGAST-00251: An error occured reading Upgrade Descriptor file ODI\INSTALLATION\odi12cInstallation_1\odi\plugins\upgrade\odi.xml
    [2013-10-24T16:49:07.870+05:30] [Framework] [INCIDENT_ERROR] [] [upgrade.Framework] [tid: 1] [ecid: e9250ad8-50dc-45fe-83f5-5c01e7a7dcb4-00000001,0] The file does not conform to the expected syntax.
    [2013-10-24T16:49:07.870+05:30] [Framework] [INCIDENT_ERROR] [] [upgrade.Framework] [tid: 1] [ecid: e9250ad8-50dc-45fe-83f5-5c01e7a7dcb4-00000001,0] See the secondary message for additional information. Contact Oracle Support.
    [2013-10-24T16:49:07.871+05:30] [Framework] [INCIDENT_ERROR] [] [upgrade.Framework] [tid: 1] [ecid: e9250ad8-50dc-45fe-83f5-5c01e7a7dcb4-00000001,0] UPGAST-00259: The getInitialValue method for plug-in ODI.ODI1 will not be called due to a previous error.
    [2013-10-24T16:49:07.871+05:30] [Framework] [INCIDENT_ERROR] [] [upgrade.Framework] [tid: 1] [ecid: e9250ad8-50dc-45fe-83f5-5c01e7a7dcb4-00000001,0] [[
    oracle.ias.update.exception.UpgradeException: UPGAST-00259: The getInitialValue method for plug-in ODI.ODI1 will not be called due to a previous error.
      at oracle.ias.update.plugin.Plugin.getInitialValue(Plugin.java:317)
      at oracle.ias.update.plan.PlanString.<init>(PlanString.java:67)
      at oracle.ias.update.plan.PlanCustom.<init>(PlanCustom.java:74)
      at oracle.ias.update.plan.PlanStep.<init>(PlanStep.java:189)
      at oracle.ias.update.plan.PlanComponent.<init>(PlanComponent.java:203)
      at oracle.ias.update.plan.Template.load(Template.java:161)
      at oracle.ias.update.plan.Template.loadAllTemplates(Template.java:102)
      at oracle.ias.update.UpgradeDriver.loadConfiguration(UpgradeDriver.java:838)
      at oracle.ias.update.UpgradeDriver.main(UpgradeDriver.java:257)
      at oracle.ias.update.UpgradeDriver.main(UpgradeDriver.java:175)
    Thanks and Regards
    Sunil

    ok - I think I've got it figured.  Appears to be a known issue.  You need to apply patch p17073913_121200.
    I downloaded that and applied to my Linux version - then re-ran the UA.  This time the GUI started and so now I'm going through the upgrade steps.
    The patch is generic, so should work for your windows environment too.  Good luck.

  • How to execute .msi files from java program

    Hi friends,
    i have written a java program which invokes and thereby execute any executable files like .exe and .bat.
    So its working fine with .exe and .bat files, but it is not working with .msi files.......can you please help me how can i execute .msi files as well??
    public class Executeexe {
         public static void main(String ar[])
              try
              Process p=null;
              Runtime rt=Runtime.getRuntime();
              p=rt.exec("D:\\mysql-essential-5.0.83-win32.msi");
              p.waitFor();
    catch(Exception e)
    }here is the program

    Make sure that the command that's being exec'd works from the cmd line.
    Then read this article and do what it says:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    Then if you still are having problems explain what "...it is not working with .msi files..." really means, and provide a [SSCCE Example program|http://mindprod.com/jgloss/sscce.html]

  • How to execute batch files or command in JSP environment

    Hi,
    I am new to Java in general and JSP too.
    I have an application that uses JSP code i need to make it run or execute a number of batch files that run under command prompt (ms-dos)?
    Can you provide me with sample code on how to do this?

    Simply put, you can't do that.
    (Outputs from executing .BATs can be used in a response strings, though.)
    Learn Java and JSP/Servlet basics.

  • Error: can not execute binary files SAP on Linux

    Dear Gurus.
    I have installed SAP test drive netweaver 2004 on my Linux. when ever i am trying to get the hardware key by the command Saplicense - get, I am getting the error message that " can not execute binary file."
    pls do let me know how to get rid of this.
    Abhishek

    > I have installed SAP test drive netweaver 2004 on my Linux. when ever i am trying to get the hardware key by the command Saplicense - get, I am getting the error message that " can not execute binary file."
    Please post the output of the commands (as use <sid>adm):
    file `which saplicense`
    uname -a
    Markus

  • Execute bat file with cfexecute

    Hello,
    this is a newbie question but I'm stuck. I have a .bat that
    runs fine through the command prompt but won't run with
    <cfexecute>, it merely seems to read the .bat but not execute
    it. The .bat reads:
    java -classpath
    ".;C:\CFusionMX7\wwwroot\i-recall\javaClasses\GATE-3.1\bin\gate.jar"
    AnnieAPI
    When I run <cfexecute
    name="C:\CFusionMX7\wwwroot\i-recall\javaClasses\GateClasspathRun.bat"
    variable="myVar" timeout="100">
    </cfexecute>
    The output looks like this:
    C:\CFusionMX7\runtime\bin>java -classpath
    "C:\CFusionMX7\wwwroot\i-recall\javaClasses\GATE-3.1\bin\gate.jar"
    AnnieAPI
    It simply reads it and doesn't execute the java AnnieAPI
    command. I didn't write this .bat file so maybe I need to add
    something to make it run. Any help is appreciated.
    -Kalen G

    Same thing, just without the classpath in the output:
    C:\CFusionMX7\runtime\bin>java AnnieAPI
    Even if I remove the class path and simply leave java
    AnnieAPI it doesn't run. It should get an error message without the
    classpath or something but I don't And the page loads so quickly
    it's obvious that Coldfusion is just reading the code and not
    executing it.
    Thanks

Maybe you are looking for

  • Animated .gif in HTML article won't upload

    Hello! I have an article built with HTML; although largeish and complicated (js, video, blah blah blah), it imports from the Folio panel just fine.....until I put the animated .gifs back into the layout. With animated .gifs, the folio panel spins (sl

  • An app to search photos by file name in ipad..

    Hello Everyone, Hi this is romit. I am looking for an application in which one can search all images in ipad by its name. For instance: in Mac we have spotlight to find an app by its name, no matter whats the location or type of app it is. provided t

  • Why does the new beta speed teste only show downlo...

    As the title says i went to use the old one which gives you a lot more data but had an error so went to do it again but you can't do 2 in an hour so thought i'd try the beta but only download speeds! no upload,what you should be getting, ping etc! se

  • Working with groups programatically

    Hello all, I have a need to add users to groups, set default group etc.. via sqlplus. I have tried using the wwsec_apis and encountered numerous problems. 1) wwctx_api.set_context needs to be set to use the functions, but this procedure generates use

  • Looking for ASD 3S139 Mac mini (mid 2010)

    Where download this one ? Thank you Best regards