How to include commandline options in Batch File

Hi i have following code for batch file now i want to include one more optionas -savemndl
command is
loader.bat -savemndl (savedmndl file) (inputmndl file) (output Logfile)
@echo off
set JAVAOPTS= -Xms20m -Xmx500m %JAVAOPT%
set FILE=
set OPTIONS=
:loop
  if "%1" == ""             goto break
  if "%1" == "-v"           goto setOptions
  if "%1" == "-print_mndl"  goto setOptions
  if "%1" == "-verbose"     goto setOptions
  if "%1" == "-seed"        goto setJavaOpt
  if "%1" == "-help"        goto help
  goto break
:setOptions
  set OPTIONS=%OPTIONS% %1
  shift
  goto loop
:setJavaOpt
  shift
  set JAVAOPTS=%JAVAOPTS% -Drandom.seed=%1
  shift
  goto loop
:break
if not exist "%1" goto notFound
native2ascii %1 > %1.tmp
set FILE=%1.tmp
shift
java %JAVAOPTS% -classpath classes;lib\simcore.jar;lib\loader.jar jp.go.nict.msf.loader.MNDLParser %OPTIONS%  %FILE% %1
del %FILE%
goto end
:help
echo usage: loader -help
echo usage: loader [-v] [-seed value] [-print_mndl] filename.mndl [traceLogFile]
java -classpath classes;lib\simcore.jar;lib\loader.jar jp.go.nict.msf.loader.MNDLParser -help
goto end
:notFound
echo loader: Error "%1" is not found.
echo usage: loader -help
echo usage: loader [-v] [-seed value] [-print_mndl] filename.mndl [traceLogFile]
:end

And what is the actual quesion then? Because the batch file given above is itself a good example how to use parameters.
Mike

Similar Messages

  • 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 write sql command in batch file

    hi,
    i m using oracle 9i on windows. i want to know how can i write sql command on batch file. i want to use a batch file to use sql command like shutdowm & startup command and any select command too.
    so plz tell how can i do it ?
    thxs

    superdba wrote:
    thxs u all , i got it at i wanted to do.
    thaks u all for yr precious time.
    thxsYou've 67 questions with 63 UNanswered. Please mark this question as "answered" and give points to the users whose answer you accept as "helpful" or "correct"
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • 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

  • How to check a checkbox in batch file

    Hello Guys,
    Heres an easy for you guys but nightmare for me question: I'm writing a batch file to login to sharepoint site. But I need to be able to check the "keep me signed" box also. How do I make my batch file to auto check that?
    I will attach my codes and site link for you guys to find out what the "checkbox" is called...
    Thank You in advance..
    The link is http://fwmc.sharepoint.com
    Here is my code: 
    set WshShell = WScript.CreateObject("WScript.Shell")
    call WshShell.Run("http://fwmc.sharepoint.com", 1, false) 
    WScript.Sleep 2000
    WshShell.SendKeys "[email protected]"
    WScript.Sleep 2000
    WshShell.SendKeys "{TAB}"
    WScript.Sleep 2000
    WshShell.SendKeys "userpassword"
    WshShell.SendKeys "{TAB}"
    WScript.Sleep 2000
    WshShell.SendKeys "{ENTER}"
    WScript.Quit()

    Heres an easy for you guys but nightmare for me question: I'm writing a batch file to login to sharepoint site. But I need to be able to check the "keep me signed" box also. How do I make my batch file to auto check that?
    This is a nightmare for you because the SendKeys method cannot be relied upon. Why? Because you can never be sure where the current focus is. While it is possible to place a tick mark by sending a space (instead of ENTER!), you will find that it will work some
    of the time and it won't some other times. Any unexpected pop-up will derail your script. If you need robust code then you must avoid SendKeys.

  • How to include an image or pdf file in a message for this forum

    Can someone please tell me how to include in a message like this one an image or a pdf file?
    Thanks

    Read here _[Help and terms of Use|http://discussions.apple.com/help.jspa]_ which you can also can find in the right panel in the forum
    You can put your image on flickr.com or imageshack.us or similar sites.

  • How to include zoom option for images and video in adobe captivate5?

    I am developing an elearning software with captivate 5 which has images and video.
    I want to include an option to be able to zoom the images and video if clicked on the particular area.
    It should zoom any part of the image when clicked on it during run time and go back to original size when clicked again.
    How can I do this?

    1. I try with two images: The thumbnail y the Big Image Zoom image Detail.
    2. I Use Dinamic Images
    3. check this tip

  • Please help how to run System commands and batch files thru java program

    Sir,
    I want execute OS commands like dir,cls..etc and batch files,.exe filesthru java program.
    I have tried it sofar thru Runtime.getRuntime().exec("execute.bat");
    but it is not working.anybody knows about how to run the system commands thru java please give me the code.
    thank you,
    regards,
    j.mouli

    I've seen other posts with this questions, and answers. Unfortunately I didn't pay much attention. But the basic idea is to exec command.com and pass the specifc batch or command as an argument.

  • How to creating concurrent call in batch file

    Hallo,
    I want to write a batch file under windows to call 6 instances concurrently to test whether the program is thread-safe. Below is the shell script for linux to create parallel call, it works. But if I use the same syntax, i.e. "&" to connect "java" call in batch file under windows, it only creates serial call, not concurrent call.
    How can I write a windows script or a batch file under windows to build parallel call.
    Best Regards
    saarxfk
    parallelCall.sh
    # set the classpath
    export CLASSPATH=
    for i in jars/*jar; do export CLASSPATH=$CLASSPATH:$i; done
    java WinsServiceClient morganti.pdf morganti.pdf it &
    java WinsServiceClient alesi.pdf alesi.pdf it &
    java WinsServiceClient morganti2.pdf morganti2.pdf it &
    java WinsServiceClient alesi2.pdf alesi2.pdf it &
    java WinsServiceClient morganti3.pdf morganti3.pdf it &
    java WinsServiceClient alesi3.pdf alesi3.pdf it
    ------------------------------------------------------------------------------------------------

    Hallo,
    I want to write a batch file under windows to call 6
    instances concurrently to test whether the program is
    thread-safe. Below is the shell script for linux to
    create parallel call, it works. But if I use the same
    syntax, i.e. "&" to connect "java" call in batch
    file under windows, it only creates serial call, not
    concurrent call.
    How can I write a windows script or a batch file
    under windows to build parallel call.
    You can't do that in windows from one shell. Open 6 shells and do it manually

  • How to include the option for people to download adobe reader in an email campaign?

    We need to attach some terms & conditions as a PDF in our mails (sending to a few thousand people), but would like to include an option to download adobe reader to read the PDF if they haven't already got one.
    Is this a simple 'link to download page' or is there a widget/code or something that already exists for this? Just to make it quick & simple for email readers
    Many thanks in advance!
    Kathleen

    Icons and web logo guidelines | Adobe

  • 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

  • How to include externel library in JAR file?

    Hi all =)
    I have a program that uses an external library (in a JAR file) I would like to compile my program as a JAR and have it include the external library that it needs to run, so that the external library would not need to be on the computer running my program. How can I do this?
    Thanks =)
    Koneko349
    Message was edited by:
    Koneko349

    Ok I was able to make my JAR and launch my application correctly. However whenever I click a button that has a method using my external library I get the following error:
    C:\Documents and Settings\Koneko>java -jar D:\Mangment.jar
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/POIFSFileSystem at managment_system.ManagmentGUI.getNextStat(ManagmentGUI.java:569) at managment_system.ManagmentGUI$1.actionPerformed(ManagmentGUI.java:195)
    I do not get this error when I run and use my program from within the IDE.
    The JAR that has my external library (and has the class for POIFileSystem) is also on my D drive and i referenced it correctly (I think) In my classpath:
    <?xml version="1.0" encoding="UTF-8"?>
    <classpath>
         <classpathentry kind="src" path=""/>
         <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
         <classpathentry kind="lib" path="D:/poi.jar"/>
         <classpathentry kind="output" path=""/>
    </classpath>I would really like to get this working and I'm very confused XP

  • How to include custom css in js file

    Hi,
    We have a JS view and we want to include custom css in the same. How can we achieve the same.

    Hi Saket,
    You can use this in your view
    jQuery.sap.includeStyleSheet("custom.css","MyCustomCSS");
    or if it is in a package called css
    jQuery.sap.includeStyleSheet("css/custom.css","MyCustomCSS");
    MyCustomCSS is just an alias to call the css file
    Thanks,
    Roshini

  • How to include grouplayout in my .jar file.

    Hello,
    I have a program that works great on my comptuer and the one in my lab. I would like to deploy this .jar file to other systems, but these other systems are only running JRE 1.5.0_10-b03. The problem, as I understand it, is that swing.grouplayout first appeared in JRE1.6.XX so these older versions don't have the proper librairies to run this.
    How do I include the grouplayout class with my .jar file. I have searched all over my HDD and cannot find the grouplayout class file to include. Am I on the right track?
    Thanks!
    -- Snow

    Note: This thread was originally posted in the [New To Java|http://forums.sun.com/forum.jspa?forumID=54] forum, but moved to this forum for closer topic alignment.

  • How to include the RNDISFN.h header file in the WIN CE Build ?

    I need to include the header file RNDISFN.h in the build of the WIN CE OS. By default the file is not included.
    What do i need to include  in the OS design to have the Header file compiled ?
    Who can help ?  (thx in advance to all these brave people that help in this forum)

    Hello Mads, please check my answer to your previous question...
    [click]
    Regards,
    Mariusz

Maybe you are looking for