Run tricky bat files

I am trying to run a bat file which also runs a ksh script;The bat file is a bit tricky because it contains the following:
set PATH=%CYGWIN_PATH_AGL%\bin;%PATH%
%NUTC_PATH_AGL%\sh -c a.ksh %1 %2 %3 %4 %5 %6 %7 %8 %9
These lines call Nutcracker, which is a UNIX-simulator on WindowsXP;
When I double-click the bat file,it runs ok...but:when i try to call it with:
try
Runtime runtime = Runtime.getRuntime();
String[] cmd =
{"D:/Documents and Settings/stud6/jbproject/untitled3/a.bat"};
Process p =runtime.exec(cmd);
catch(Exception ex)
ex.printStackTrace();
...it does absolutely nothing!
Running an usual bat file also works fine;
Please help me!Thanks in advance!

...it does absolutely nothing!It does something, just not what you thought it would. It probably aborts with a "bad command or filename", since you need the command shell to run a batch file.

Similar Messages

  • Running a Bat file from a stored procedure

    This is part II of Re: Need to run bat file from application express
    I thought I would open a new thread
    I thought I had this fiqured out but it still doesn't work
    1) I granted CREATE EXTERNAL JOB to my user
    2) startup the OracleJobScheduler Service
    3)
    create or replace
    PROCEDURE RUN_OS_COMMAND(p_cmd IN varchar2)
    is
    v_job_exists pls_integer:=0;
    begin
      select count(1)
      into  v_job_exists
      from  all_scheduler_jobs
      where job_name='JAVA_EXE';
      if v_job_exists>0 then 
        dbms_scheduler.drop_job(job_name =>'JAVA_EXE');
      end if;
      dbms_scheduler.create_job
      (   job_name          =>'JAVA_EXE'
        , job_action        =>p_cmd
        , job_type          =>'executable'
        , enabled           =>false
        , auto_drop         =>false
        , start_date        =>systimestamp
      dbms_scheduler.run_job(job_name =>'JAVA_EXE');
    end;test.bat is del test.csv
    I run this
    begin
      RUN_OS_COMMAND('C:\temp\test.bat');
    end;
    / anonymous block completed
    It runs with no errors but does not run the bat file... what am i missing, thanks Doug

    LLUSERSPROFILE=C:\Documents and Settings\All Users
    APPDATA=C:\Documents and Settings\wblincoe\Application Data
    CLASSPATH=.;[ORACLE_HOME]\jdbc\lib\ojdbc6.jar;c:\myjar\xdocore.jar;c:\myjar\i18nAPI_v3.jar;c:\myjar\xdoparser.jar;c:\myjar\xmlparserv2.jar
    CommonProgramFiles=C:\Program Files\Common Files
    COMPUTERNAME=WBLINCOELT
    ComSpec=C:\WINDOWS\system32\cmd.exe
    DEFLOGDIR=C:\Documents and Settings\All Users\Application Data\McAfee\DesktopProtection
    FP_NO_HOST_CHECK=NO
    HOMEDRIVE=C:
    HOMEPATH=\Documents and Settings\wblincoe
    LDMS_LOCAL_DIR=C:\Program Files\LANDesk\LDClient\Data
    LOGONSERVER=\\03N-DAYT-DC01
    NUMBER_OF_PROCESSORS=2
    OS=Windows_NT
    Path=C:\OraHome_1\jre\1.4.2\bin\client;C:\OraHome_1\jre\1.4.2\bin;C:\app\wblincoe\product\11.1.0\db_1\bin
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
    PERL5LIB=C:\oracle\product\10.2.0\http_1\sysman\admin\scripts;C:\oracle\product\10.2.0\http_1\perl\site\5.6.1\lib;C:\oracle\product\10.2.0\http_1\perl\site\5.6.1;C:\oracle\product\10.2.0\http_1\perl\5.6.1\lib\MSWin32-x86;C:\oracle\product\10.2.0\http_1\perl\lib\5.6.1;C:\oracle\product\10.2.0\http_1\perl\lib\5.6.1\MSWin32-x86;
    PHPRC=C:\Program Files\PHP\
    PROCESSOR_ARCHITECTURE=x86
    PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 2, GenuineIntel
    PROCESSOR_LEVEL=6
    PROCESSOR_REVISION=0f02
    ProgramFiles=C:\Program Files
    PROMPT=$P$G
    SESSIONNAME=Console
    SystemDrive=C:
    SystemRoot=C:\WINDOWS
    TEMP=C:\DOCUME~1\wblincoe\LOCALS~1\Temp
    TMP=C:\DOCUME~1\wblincoe\LOCALS~1\Temp
    USERDNSDOMAIN=CACI.COM
    USERDOMAIN=CACI
    USERNAME=wblincoe
    USERPROFILE=C:\Documents and Settings\wblincoe
    VSEDEFLOGDIR=C:\Documents and Settings\All Users\Application Data\McAfee\DesktopProtection
    windir=C:\WINDOWS

  • Error when running a bat file

    Can someone tell me what this error means; "ORA-12560: TNS:protocol adapter error"
    I had Oracle XE on my Windows XP Pro SP3, but I also install the EE of Oracle which I haven't setup yet. Originally when I run this .bat file by double clicking on it, "setup_distran_database.bat", everything worked fine. But now, I am getting tghe above error. Not sure if it was because I installed Oracle EE.
    This is the .bat file:
    *@ECHO off*
    *:: Ayo Ojikutu*
    *:: Using Murach's Oracle SQL and PL/SQL*
    *:: and Mike Murach & Associates, Inc. example*
    *:: Nov 11, 2011*
    *:: Uses SQL*Plus utility to run the SQL scripts that create*
    *:: and populate the tables in the AP, OM, and EX schemas.*
    *:: If necessary, edit the username/password*
    sqlplus system/passwordhere @setup_distran_database*
    *:: Display a message about the log file*
    ECHO.
    ECHO For details, check the setup_distran_database.log file in the current directory.
    ECHO.
    *:: Display 'press any key to continue' message*
    PAUSE

    "ORA-12560: TNS:protocol adapter error"
    Not sure if it was because I installed Oracle EE.Most probably yes, Windows has the last installed product environment. Try setting XE environment before running sqlplus, something likeset ORACLE_SID=XE
    set ORACLE_HOME=<XE Oracle Home>
    set PATH=<XE Oracle Home\bin>;%PATH%
    sqlplus .....

  • Trying to run a bat file from oracle

    I have followed these steps, see bottom for results, everything is valid but the bat file does not run???? PLease need your help. Doug
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "getbatx" AS
    class getbatx //class pdfopen
    public static void execmd(String c) //main function
    try
    System.out.println("Executing:" + c);
    Runtime.getRuntime().exec("C:\\WINDOWS\\system32
    cmd.exe /c "+c);
    System.out.println("Executing:" + c + " ...done");
    } catch (Exception e) //catch any exceptions here
    System.out.println("Error" + e ); //print the error
    CREATE OR REPLACE PROCEDURE host_command2 (p_command IN VARCHAR2)
    AS LANGUAGE JAVA
    NAME 'getbatx.execmd (java.lang.String)';
    /Then as sysdba I put in in the following.
    exec dbms_java.grant_permission( 'CAPRS', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'execute' );
    EXEC Dbms_Java.Grant_Permission('CAPRS', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    EXEC Dbms_Java.Grant_Permission('CAPRS', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');Then I make the call.
    SET SERVEROUTPUT ON SIZE 1000000
    CALL DBMS_JAVA.SET_OUTPUT(1000000);
    BEGIN
    host_command2 (p_command => 'c:\mybook.bat');
    END;
    /***** I run this, it completes but does not run the bat file and there is no error message
    SQL> BEGIN
    2 host_command2 (p_command => 'mybook.bat');
    3 END;
    4 /
    Executing:mybook.bat
    Executing:mybook.bat ...done
    PL/SQL procedure successfully completed.

    Yes it should open a dos box, but you forgot to add the .bat file witch you like to run: String[] command = {"cmd", "/c", "start", "c:/Batch files/Cardiobackup/cardiobackup_v1.4"}

  • Not able to view the window when I run cim.bat file

    I have installed ATG web Commerce 10.0.3 and I need to configure MySql. For that I need to Start CIM by running the following file: <ATGdir>\home\bin\cim.bat and later I have to Type P to choose the products to configure, at a minimum ATG Platform and ATG Content Administration. But when I am not able to view the window to proceed further when I run thecim.bat file.Please let me know if anyone has any idea about this.

    Hi,
    Please find the error log while running in the command prompt.
    C:\Documents and Settings\******>c:\ATG\ATG10.0.3\home\bin\cim.bat
    Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version n
    umber in .class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
    4)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at atg.core.util.BeanUtils.instantiate(BeanUtils.java:427)
    at atg.core.util.BeanUtils.getBeanInfo(BeanUtils.java:395)
    at atg.nucleus.SimpleComponentState.getComponentClassDescriptor(SimpleCo
    mponentState.java:547)
    at atg.nucleus.SimpleComponentState.<init>(SimpleComponentState.java:91)
    at atg.nucleus.SimpleConfigurationState.<init>(SimpleConfigurationState.
    java:93)
    at atg.nucleus.PropertyConfiguration.configureService(PropertyConfigurat
    ion.java:756)
    at atg.nucleus.Nucleus.<init>(Nucleus.java:832)
    at atg.nucleus.Nucleus.<init>(Nucleus.java:717)
    at atg.nucleus.Nucleus.startNucleusCheckLicense(Nucleus.java:4144)
    at atg.nucleus.Nucleus.startNucleus(Nucleus.java:4021)
    at atg.cim.SessionContext.startNucleus(SessionContext.java:632)
    at atg.cim.SessionContext.startNucleus(SessionContext.java:610)
    at atg.cim.flow.CimFlowCreator.startDefaultCimFlow(CimFlowCreator.java:7
    4)
    at atg.cim.Launcher.startCimFlow(Launcher.java:168)
    at atg.cim.Launcher.main(Launcher.java:68)

  • How to run a .bat file with string arguments?

    Hi,
    I have a problem in running a .bat file with string arguments
    - the file is XPathOverlap.bat with 2 stringarguments like: "/a" and "//a"
    - the cmd: c:\Downloads>XPathOverlap "//a" "/a" works fine.
    - here is my code:
    public static void test(){
         try{
              String loc1 = "//a";
              String loc2 = "/a";
              String[] cmdarray = {"c:\Downloads\XPathOverlap", loc1, loc2};
              Process p = Runtime.getRuntime().exec(cmdarray);
              p.waitFor();
              System.out.println("Exit Value: "+p.exitValue());
              //code to print command line replies
              InputStream cmdReply = p.getInputStream();
              InputStreamReader isr = new InputStreamReader(cmdReply);
              BufferedReader br = new BufferedReader(isr);
              String line = null;
              while((line=br.readLine())!=null){
                   System.out.println(line);
         }catch(Throwable t){
              t.printStackTrace();
    How can i run this bat file with 2 string arguments?

    Hi,
    thanks thats good and helpfully
    so this code works:
    String loc1 = "\"/a\"";
    String loc2 = "\"//a\"";
    String path = System.getenv("MuSatSolver");
    String[] cmdarray = {"cmd.exe","/C",path+"XPathOverlap.bat", loc1, loc2};
    Process p = Runtime.getRuntime().exec(cmdarray);
    p.waitFor();
    System.out.println("Exit Value: "+p.exitValue());
    InputStream cmdErr = p.getErrorStream();
    InputStreamReader isrErr = new InputStreamReader(cmdErr);
    BufferedReader brErr = new BufferedReader(isrErr);
    String line2 = null;
    while((line2=brErr.readLine())!=null){
         System.out.println("Error: "+line2);
    but now i have another problem, this is the output:
    Exit Value: 0
    Error: java.lang.NoClassDefFoundError: fr/inrialpes/wam/treelogic/_xml/XPathOverlap
    Error: Exception in thread "main" The Exit value is 0, so the process terminates normally.
    I have tested this bat file in cmd and there it works correctly.
    Why do i get this error message?

  • 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.

  • Unable to run script (.bat file) on a windows server

    Hi,
    I have a job definition which execute cmd command (such as cd, echo, etc) through a platform agent installed on a Windows server but when I try to execute scripts (i.e. .bat file) it doesn't work.
    Can someone help, please ?
    Regards.

    Hi,
    The PA is running with the same account executing the .bat file on the server.
    Yes, the bat file can be executed with that user outside of CPS.
    Regards

  • Running scripts, bat files, etc from a jar file

    Hello,
    Does anyone know of a way, or even if it is possible to run a script or batch file from a jar file?
    For instance, lets say I have a batch file that I can run from the command prompt by typing :
    myBatchFile.bat
    and now I write a very simple java app that will do the same:
    public class Test {
    public static void main(String[] args) {
    try {
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec(�myBatchFile.bat�);
    } catch (Exception e) {
    e.getMessage();
    The above app will work as long as the batch file is in the current directory, but how or can I make it work if I stick the batch file in a jar file along with the app?
    I tried using the manifest file with no luck.
    I tried creating a URI to the jar file, wrapping it in a File and then passing that File to the exec method also with no luck.
    I searched all the forums on Sun but came up with nothing.
    I performed a google search also with no luck.
    Does anyone have the answer to this? Even if I can get a definitive �No it can�t be done� answer. Although I would think that it should be able to be done.
    Thanks

    Hi,
    you cannot execute anything being inside a jar-file. The OS doesn't know anythig about jar-files and cannot look inside one to find the program/script/batch you want to execute.
    You could do a workaround by extracting the file from the jar-file before calling exec(). But normally OS dependent files should not be inside a jar-file and remain in a own directiory.
    Andre

  • How can I run a .bat file from an html/javascript adobe air installation package?

    I write an html/javascript code which works completely true
    but when I made the installation package by air-sdk
    it dosent work properly
    my code is:
    <html>
    <head>
        <title>Hello World</title>
              <script type="text/javascript">
            function appLoad() {
                air.trace("Hello World");
        </script>
    </head>
    <body onLoad="appLoad()">
        <h1>Hello World</h1>
              <br />
    <button onclick="window.open('file:///C:/Windows/notepad.exe')"> Launch notepad </button>
    <button onclick="window.open('file:///D:/opennotepad.bat')"> Launch batnote </button>
    </body>
    </html>
    Chapter 5: Creating your first HTML-based AIR application with the AIR SDK

    Seems to be security violation. You can't execute bat or cmd

  • How to run a bat file in java

    Hi, my program needs to use an outside batch file command, for instance, its name is "generateXML", its syntax is
    [command prompt] : generateXML sourceFile.dtd XMLFile.xml
    I want to include this command into my code so that do that and other things at one go.
    Thanks

    On Windows 98 try something like this:
    Process process = Runtime.getRuntime().exec( "command.com /c generateXML sourceFile.dtd XMLFile.xml" );

  • Error while running C:\Program Files\Adobe\Flex Builder 3\sdks\3.0.0\samples\explorer\build.bat

    Hello
    I am a flex beginner, when i run the  C:\Program Files\Adobe\Flex Builder 3\sdks\3.0.0\samples\explorer\build.bat file the following error is displayed
    Loading Configuration file C:\Program Files\Adobe\Flex Builder 3\sdks\3.0.0\frameworks\flex-config.xml
    C:\Program Files\Adobe\Flex Builder 3\sdks\3.0.0\samples\explorer\loaderPanel.mxml
    Error :-1
    Please help me to run the bat file, as it will help me to learn flex independently.
    error message is attached as bmp.
    Thanks in advance.

    Hi,
    Take a look at this report: https://bugs.adobe.com/jira/browse/FB-11626 It might be of help.
    With best regards,
    Barna Biro
    Blog: http://blog.wisebisoft.com

  • Running bat files in java code

    Hi,
    I am trying to run a .bat file within java code like this.
    Runtime.getRuntime().exec("c:\\Test.bat");
    but no success. Could you please suggest how to run .bat file or simply a
    DOS command from java code.
    thanx in advance
    Deepak Garg.

    try this...
    n reply whether it worked or not......
    import java.util.*;
    import java.io.*;
    import java.net.*;
    try
    Runtime runtime = Runtime.getRuntime();
    Process process ;
    process= runtime.exec("./temp_install");
    //code to print command line replies
    InputStream stderr = process.getInputStream();
    InputStreamReader isr = new InputStreamReader(stderr);
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    while((line=br.readLine())!=null)
    System.out.println(line);
    catch(Throwable t)
    t.printStackTrace();
    }

  • How to run sql query in bat file in task schedular at every 10 seconds

    This is my sql script :
    DECLARE @countRows INT,
    @currDate DATE,
    @checkForTasks INT,
    @created_by_id INT,
    @gst_ID int;
    SET @currDate = Getdate()
    SET @countRows = (SELECT Count(*)
    FROM [dbo].[sd_gst_effective_table]
    WHERE isapplied = 0)
    IF @countRows > 0
    -- Check for those GST''s who are not applied yet : if they are greater than 0 then perform next task
    BEGIN
    SET @checkForTasks = (SELECT Count(*)
    -- Check is current date equals to task date or not
    FROM [dbo].[sd_gst_effective_table]
    WHERE effect_date = @currDate AND isapplied = 0)
    IF @checkForTasks > 0
    -- If current date = task date then perform this task
    BEGIN
    SET @created_by_id = (SELECT TOP 1 createdby FROM [dbo].[sd_gst_effective_table] WHERE effect_date = @currDate AND isapplied = 0)
    SET @gst_ID = (SELECT gst_id FROM [dbo].[sd_gst_effective_table] WHERE effect_date = @currDate AND isapplied = 0)
    -- STEP 1 :: InActivate the existing GST according to createdbyID
    UPDATE sd_gst_rate
    SET isactive = 0,
    inactivedate = Getdate()
    WHERE isactive = 1
    AND createdby = @created_by_id
    -- STEP 2 :: Activate the New GST according to implementation date and gstID
    UPDATE sd_gst_rate
    SET isactive = 1,
    activedate = Getdate()
    WHERE id = @gst_ID
    -- STEP 3 :: Inactivate the applied GST from sd_gst_effective_table
    UPDATE [dbo].[sd_gst_effective_table] SET isApplied = 1 WHERE gst_id = @gst_ID
    END
    END
    DECLARE @Text AS VARCHAR(100)
    DECLARE @Cmd AS VARCHAR(100)
    DECLARE @value nvarchar(1000);
    SET @value = (SELECT CONVERT(TIME,GETDATE()) AS HourMinuteSeconds);
    SET @Text = 'File Writed ' + @value
    SET @Cmd ='echo ' + @Text + ' > E:\AppTextFile.txt'
    EXECUTE Master.dbo.xp_CmdShell @Cmd
    This is resided in videos folder of windows , i have created a task schedular in windows 8.1 to run daily at every 10 seconds , but it is not working ... Please tell me how to deal with it.
    Please note : This sql query is running perfectly in sql server. Query have no errors. Please check whats wrong with my time schedular. I just want my schedular to run every 10 seconds regardless of date.

    Hi Emad,
    Is your script in a ".sql" file? May I know how you configure the schedule task action?
    Since you didn't mention how you configure the schedule task, can you confirm you have followed the below step correctly?
    Save your script in a ".sql" file.
    Create a ".bat" file and call the sql file above inside with
    sqlcmd.exe, you can reference
    here.
    Configure a schedule task to run the ".bat" file in a certain interval.
    Have you tried to run the script in you bat file in a standalone commandline window? Please post the script in your bat file, It can help to diagnose the issue.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • How to get the erroe message, if i run java program using .bat file

    Hi,
    I have a java file which accepts two inputs as command line argument. I want to make this pgm a tool. So have created a *.bat file which has the following command
    java myprogram arg1 arg2
    I'm gonna share this program with others. So i'll keep the class file and the .bat file in a commaon folder. All the users have to do is, edit the .bat file to give his/her args and run the .bat file. The pbm is, if the user input is not valid, I have put displays in the pgm to show it.
    But if i run thru .bat, I'm not getting the error message or I don't know where it is getting displayed.
    Can anyone help me with this ?
    Thanks,
    Mary

    When i run from the console, I can see the output.
    But, when i double click on the .bat file from the
    folder, it runs fine and i couldn't see the output.
    nullThat's because the error message is printed, and then the console is closed. The message is there but you need to read really really fast :)

Maybe you are looking for

  • Print a form page to PDF

    Hi all, I need to create a PDF from a form, creating a Report Layout and Report Query. Use Apache Cocoon as a print server. With Microsoft Word and a complement of BI Publisher document loading design that gives me APEX data in XML and XSL, then expo

  • Problem in insert image function

    Hi there...I'm brand, spanking new to Dreamweaver CS3, and I just started working through tutorials to try to learn the software. I'm having a little issue with something that is problem very easily fixable to the gurus here. When I tell Dreamweaver

  • Multiple Graphs

    Ok i have hit a bit of a snag, I have essentially three seperate graphs, each displayed individually. What i woudl like to do is to change the x-axis (time in my case) Programatically... so if i set the time to 5000 all the x axis changes to 5000....

  • ISE Time Profiles

    I have successfully setup my guest authentication through ISE but when I change the time profile from Default Eight Hours to Default Start End the user cannot login.  If I change the profile to Eight Hours, the access is granted.  Has anyone run into

  • Help needed with itemrenderers

    hey, I need some help with a couple of things. 1. In one of the columns of an advanced datagrid i need only the text appearing in brackets "( )" to be italicised. The data is fed in from an xml file. I am using the following code but not able to get