Run .bat file with arguments?

Hi,
   I need to run the .bat file with parameters/arguments in Adode Indesign JavaScript. "File.execute()" executes the file using the appropriate application.It executes the .bat file suceessfully.But I am unable to pass the arguments.I need to execute the command like
Eg : test.bat parameter1 parameter2
var myFile=new File("c:\\test.bat");
myFile.execute();
The above statements works fine. Is it possible to execute the with parameters. Please suggest the solution to above problem.

Hi,
let VB start the *.bat. this works for me:
#target InDesign
doTheBat('START "" "C:\\Program Files\\Adobe\\Adobe Photoshop CS5.1 (64 Bit)\\Photoshop.exe"')//Start Photoshop, just a example
function doTheBat ( _data ) {  
        try 
            var _file = new File('~/myTmpBat.bat'); 
        _file.open( 'w' );  
        _file.encoding = 'UTF-8';  
    _file.writeln ( _data );  
    _file.close();  
    //_file.execute(); 
    myVBScript = "Set WshShell = CreateObject(\"WScript.Shell\")\r"; 
myVBScript += "WshShell.Run chr(34) & \"C:\\Users\\%USERNAME%\\myTmpBat.bat\" & Chr(34), 0\r"; 
myVBScript += "Set WshShell = Nothing\r";
myVBScript += "\r"; 
app.doScript(myVBScript, ScriptLanguage.VISUAL_BASIC);
    }catch (e){  alert(e);
Good luck
Hans-Gerd Claßen

Similar Messages

  • How to run jar files with arguments?

    Hi everybody,
    Is it possible to run a jar file with arguments passed to its MAIN class?
    If yes can you help me on how to do it?
    Thanx

    I am in complete agreement with FahleE. I'll refine it a bit.
    On my machine (running RedHatLinux8.0) you can run the demos like this.
    1. open a console window
    2. go to the directory where the demo you wish to run, say, demo.jar, is located
    for instance for the SwingSet2-demo
    cd /usr/lib/java/demo/jfc/SwingSet2
    3. run the jar file
    java -jar demo.jar
    In order to run it windows style, ie, launching by double clicking, save these lines in a file called
    LaunchJar.sh
    cd /usr/lib/java/demo/jfc/SwingSet2
    java -jar demo.jar
    where demo.jar is the jar file you want to run.
    Right click on the LaunchJar.sh and go to the 'Properties' tab. Check the 'Execute' permissions for Owner/groups/others. You can also do the same thing by chmod command.
    Now double-click on the LaunchJar.sh file: your application should be launched.
    Palash.
    Please Note: It is important to set the path variable to your JAVA_HOME directory....
    Otherwise, instead of
    java -jar demo.jar, you will need to use the full path to your JAVA_HOME/bin directory like:
    JAVA_HOME/bin /java -jar demo.jar.
    Where JAVA_HOME is the directory where you have installed java. Typically it is usr/java or usr/local/java

  • Problems running bat file with calls to java programs (.jar)

    I created a bat file with calls to jar programs. In each line,
    I put a call to the programs with parameters, but bat only
    executes the first line and ends execution.
    All lines of my bat file must be executed.
    What should I do?
    Best Regards,
    Pedro Felipe
    [http://pedrofao.blogspot.com|http://pedrofao.blogspot.com]
    [http://viajantesmundo.blogspot.com/|http://viajantesmundo.blogspot.com/]

    user8730639 wrote:
    I realized that the problem isn`t my bat file. I made tests calling another jar files and then all the lines of the batch file were executed. So, the jar file called on my previous bat is finnishing the execution. I verified and the jar apps worked without error.
    I would like to know if exists any command in Java that can cause this effect (close a batch), to modify the open source code of the application.Not that I know of.
    Is prism a bat file?
    If you are invoking bat files from your bat file without using call that would explain it
    :: mymain.bat file
    :: call the first bat file
    call prism.bat arg1 arg2 arg3
    :: call the other bat file
    call prism.bat arg4 arg5 arg6
    ::

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

  • 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();
    }

  • Running Bat file in Minimized Mode

    Hai All,
    I need to run bat file using Runtime, Bat file should run in minimized
    mode ...
    any one help me
    Regards
    Yuva

    Assuming it's windows...
    start /min mybatchfile.batOpen a command prompt and type "start /?" to see the params available.
    regards,
    Owen

  • How to write run.bat files

    Can anyone tell me how to write run.bat files to run java classes. Currently my run.bat file has the following two lines,
    c:\j2sdk1.4.1_02\bin\javac.exe *.java
    c:\j2sdk1.4.1_02\bin\java.exe questionnair
    But the class is not executed. Thanks in advance.

    you'll have to provide more details.
    Firstly, which package is the class a part of? and secondly, where on the filesystem is the root of the package?
    You might also benifit from placing the c:\j2sdk1.4.1_02\bin\ into the classpath.
    On a rainy day, check out the ANT tool, it will take care of all that crapola for you.
    newio

  • Help! problem running .bat files in browser

    HI! Hope you can help me!
    I have a simple applet that runs .bat files and retrieves the resulting information into a text box.
    To run those files I use:
    Runtime rt = Runtime.getRuntime();
    Process processo=rt.exec("C:/po2PrtMonitor.bat 04600105 ope >C:/infoPrt.txt");
    in wich "04600105","ope" and ">C:/infoPrt.txt" are parameters that the .bat file is expecting. When the file is ran it saves the resulting information on a simple .txt file, that I later read by using:
    fichResposta = new FileInputStream(fichRespostaPath[0]);
    When I run my applet on JDeveolper 9.0.2.822 is works perfectly, the problem is when run it on the browser.
    On the browser the applet executes the file by opening a MS-DOS prompt and when it finishes executing the file, the prompt closes automatically and doesn't send the information into the .txt file.
    My .bat file is something like:
    jre -cp PrtSrv20.jar sibs.deswin.prt.PrtMonGateway 10.46.1.22 5003 %1 %2 %3
    where %1,2%,3% are the above parameters given by the applet when the file is ran.
    If I run it on JDeveloper I get:
    C:\>jre -cp PrtSrv20.jar sibs.deswin.prt.PrtMonGateway 10.46.1.22 5003 04600105 ope
    PRTSES=04600105 HDR=0460010000000005 STA=OPENED TRF=ACTIVE TRP=CONN ILTS=15 Long postings are being truncated to ~1 kB at this time.

    Here is what is missing:
    ILT=0 MSQ=388 HDR=04.60.01.00.00.00.00.05.41.00.01.84. CMD=STRT-TRF
    When the applet is run on the IE broser what I get is simply:
    jre -cp PrtSrv20.jar sibs.deswin.prt.PrtMonGateway 10.46.1.22 5003 04601005 ope
    I have no idea as to what the problem might be! Do native methods work differently on the browser?! Could it be a problem on the deployment? A library not included on the deployment profile? Suggestions are very welcome.
    Hugo Rosas

  • How to run two files with same url-  urgent

    hi,
    i created two servlet page and both are working very fine.but at same time i only able to run one file with same url. Is possible to run two or more file at same time with same url name..
    if you r not understanding what i want to ask then, i have two file names under helloWeb directory
    1) helloWorld.java(servletname s1, url /man)
    2) helloWeb.java (servletname s2,url /man)
    to run - http://localhost:7001/helloWeb/man - it runs very first file which is added to deployment module.
    so i want to know how i can run both file with same url, for this what i have to pass on my address bar.
    plz help me i m wating
    <b></b>

    Hi,
    We can give same url mapping to both Servlets but we can access the servlet which is entered first in web.xml because whenever we send a request to the webserver then webserver look at the elements in web.xml file one by one.
    When it finds the corresponding url mapping then immediately sends the response to the client.The same url mapping for the next element will be ignored.
    I think there is no possibility to access both servlets with same url.
    Regards
    Anilkumar kari

  • Can't run .jar file with JavaSE

    Hello.
    I'm trying to run a .jar file with JavaSE Binary, just like I did with Windows. I Ctrl+Rclick and pick "Open with..." and there is no such option. I've been searching the whole day for a solution, I kept getting "Open Java Preferences... put on top of the list" and things like that. There is no "Java Preferences" in the Utilities folder, and nothing related to my problem in "Java Control Panel" in System Preferences. Yes, I have Java 7. I just need to run this file with Java. How?
    Thanks in advance.

    Max. allowed size of .jar file is 1MB.

  • Running bat files from JDeveloper

    hi
    Sometimes it could be convenient to run a bat file directly from JDeveloper.
    For example, the application in SQLAuthenticatorApp-v0.02.zip (see also forum thread "how to disable (or lock) users") has an Ant file BuildStuff/build-wlst.xml which has targets like "wlst.create-domain" and "create.wls-start-stop-bat-files", the last one resulting in some bat files which I have been able to configure to run from JDeveloper,
    see http://www.consideringred.com/files/oracle/img/2011/run-using-cmd-20110529.png
    The External Tool cmd configuration I use is shown in the screenshot
    at http://www.consideringred.com/files/oracle/img/2011/external-tool-cmd-20110529.png
    See also the blog post by John 'JB' Brock
    at http://blogs.oracle.com/jdevextensions/entry/how_to_extend_jdeveloper_without_writing_code
    - (q1) How can I configure the External Tool cmd to run in its own cmd (command) window outside JDeveloper?
    many thanks
    Jan Vervecken

    Hi Jan,
    It looks like this is going to be a bug from what I can see. After looking at it a little more this morning, not only does it not display the cmd window, but if you use the /k argument, it leaves the script running in memory. Look at your Task Manager after running a few times with /k
    I'll file a bug, and see if anyone has a work around or something that I missed.
    For now, it would appear this is not possible, and you will just have to see the result in the log window. I would not use /k as well. Stick with /c for now.
    Sorry for the inconvenience.
    --jb                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Running bat-files from Java

    Hello,
    I have been trying to launch a bat-file from my Java code, running under windows, but with no success.
    Here is my simple code:
    Runtime.getRuntime().exec(new String[] {
             "C:\\temp\\test.bat"
          });This does nothing at all and generates no exception. Any suggestions?

    It seems java has a real problem with this... if you
    want to run another java program, for instance, you
    cannot do that either with String cmd="cmd.exe /C
    java myProgram"
    I need to pass parameters from one program into the
    program I'm going to open using java, that is why I
    need to call it from my first program. It can open
    executables and shortcuts, but has a real big problem
    doing things with the command line.No it doesn't have a problem with it. You just must be doing something wrong. By the way, since "java(.exe)" is already an executable, there's little value in wrapping that by the "cmd.exe" shell (unless you want to use the command shell for some reason such as passing the redirector (>) symbols to it to let it redirect stdout / stderr to a file)

  • Problems running jsp files with tags on tomcat 4.0

    hi,
    i had some jsp1.1 stuff running on tomcat3.3.
    last week i moved to tomcat 4.0 , changed the tags to fit jsp1.2 and... everything is wrong now. while trying to run jsp with tags i get an error message (same for all files):
    ---->
    description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: (class: org/apache/jsp/djsp$jsp, method: _jspService signature: (Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse; )V) Incompatible object argument for function call
    <-------
    the jsp files with no tags and servlets are running ok.
    I NEED YOUR HELP!!!

    cyclid,
    i have the same environment setup and the same troubles. after searching the forums, it seems that there are others with the same, if not similar issues, yet no solutions. if you find the solution to this one, could you please post it. i would really appreciate it since i have been on this one for several days with no success. i even tried the helloworld jsp/custom tag examples from a jsp profession book that i have and that won't work.
    Anyone out there,
    if you have any idea why this problem exists, any solutions, ideas would be appreciated.
    thank you,
    navesink

  • Scheduled task won't run .bat file

    Hi. On Windows Server 2008 I have a scheduled task that calls a .bat file. The fist step in the .bat file is write to a log file to the same directory in which the .bat file exists. This allows me to find out if it is ever run. When the .bat file is run from a command prompt it runs as expected writing to the log file and completing its actions. My problem is that when I run the scheduled task manually or allow it to run when scheduled it appears to run but the .bat file is never run. No log file is ever created. The History tab in the properties of the scheduled tasks shows the task being started and running then completing with an operation code of 2. I've disabled the UAC for the user account. I've set the task to run as the Administrator user and verified the permissions for that user. I know the password is correct for the task because I can make changes to the properties and save those changes with the username/password. I'm at a loss for further troubleshooting steps. Can anyone point me in the right direction to figure out why these .bat files are not being run? 

    So I had this problem, I double clicked on the .bat and notepad opened the .bat.  I ran through this whole long and very absorbing thread of this forum.   I wanted to save the entries that were most helpful, so I copied and pasted into
    a notepad document (.txt)  I could not find a way to attach it here, so I copied and pasted that below. I called it a synopsis....  Did I spell that right?
    As you can see, I added my experience at the top (A and B).  The stuff I copied is noted with the original author. This is the first time I posted anything to these here microsoft forums, although I have been telling computers what to do for 40+ years. 
    So hope I did not break any social protocols here.
    ==================================== Begin ====================================
         Running A Dot Bat File in Windows Server 2008 Vista 7 etc and beyond V01
    ============================================================================
    This was created as a synopsis of the entries at the following forum location:
    http://social.technet.microsoft.com/Forums/en/winservermanager/thread/d47d116e-10b9-44f0-9a30-7406c86c2fbe
    A) manually
         This is an opinion added by Thomas Rock
        1) Open a command window (that would be cmd.exe)
        2) In the command window navigate to the directory containing the .bat file and it's dependents
               ex...  C:\Program Files (x86)\Bobs\Your\Uncle
        3) Run the .bat file by typing the name including the .bat extension (in the command window of course)
                 TheBatFile.bat
           Note: Using this method, the .bat file will run in the current command window directory (the directory where the .bat file is located)
                             (this is the key for getting it to run in the task scheduler... Start in folder option)
    B) The double click
                This is an opinion added by Thomas Rock
         1) Using Windows exlporer, find the .bat file
         2) use the mouse or other device to double click on the .bat file
         3) if it does not run (in my case the wordpad application opened the .bat file)
              a) make sure that the .bat file extension is associated with the program c:\windows\system32\cmd.exe
              b) make sure the profile you are using has rights to run the cmd.exe
              c) make sure the profile has the rights to the directories, the .bat and any other objects used or affected by the .bat file processing.
    C) As a task using task scheduler
         Proposed As Answer by Brian Vandemark Wednesday, September 02, 2009 9:36 PM
    1) Make sure that the task is set to "configure for Windows Vista or Windows 2008" on the first page of the task properties (under the "general" tab)
    2) Make sure that the task is set to "start in" the folder that contains the batch file:
          a) open the task properties
          b) click on the "actions" tab
          c) click on the action and then the "edit" button at the bottom. 
          d) In the "Edit Action" Window there is a field for "start in (optional)" that you set to the path to the batch file.
          e) be sure to include an end backslash for the start in path "C:\dir1\dir2\"    (the last backslash is not optional)
    3) Make sure that the task is running as an account that has explicit "Full access" permissions to all these things:
          a) the .bat file itself
          b) the folder containing the .bat file
          c) the target files/folders that are affected by the .bat script. 
               Note:  Inherited permissions did not seem to work.
    4) Make sure that the account running the task is a member of the local "administrators" group for this machine
    5) Make sure that the task is set to "run whether logged on or not"
    6) Tick the box "Run with highest privileges".    
           Note: Point 6 here was from Edson F. Lima Wednesday June 30 2010 1:35 PM
                      The original point 6 was moved to point 7.
    7) The Task should run successfully with expected output when you right-click on the task and select "run" 
            If it does that then it will run successfully when you are logged off.
    D) Still another way as a task using task scheduler
          Proposed As Answer byDarren Wallace Thursday, July 15, 2010 1:41 AM
    This has been bugging me for 6 or 7 months.
    I don't have admin rights to the box and the guy who does is very busy...
    so I've felt the range of emotions mentioned above.
    I tried most everything above as well. But what seemed to get my processes processing, was ...
       • on the General tab, I clicked the Change User or Group button
       • in Select User or Group (first smaller dialog box)  I clicked the Advanced... button
       • in the next Select User or Group (second bigger dialog box) I clicked the Find Now button
       • in the Search results I selected the Administrators (a group) and it returned SERVERname\Administrators into the "Enter the object name to select" entry in the previous dialog box
       • then I clicked OK and returned to the General tab above
       • the options to Run only when user is logged on and Run whether user is logged on or not are no longer available
       • then I made sure that the Run with highest privileges was checked
       • then I clicked OK and during the next scheduled time to run ... it ran
       Note: See note in A) Manually above.
    E) Task scheduler recommendation
         Proposed As Answer byTamusJRoyceThursday, December 01, 2011 3:42 PM
    I have found .bat and .cmd files do not run correctly either.
        My solution:  Don't run the batch file directly. 
           Have TaskScheduler run:  cmd.exe
              with parameter:  /C YourBatchFile.bat
             and start in: C:\SomePath\ (without quotes!) where C:\SomePath\YourBatchFile.bat exists. 
            And then select the radio button for it to run regardless if you are logged in or not.
    Exit errors may not be logged to the Event Log (they weren't when the .bat ran directly from Task Scheduler when I was logged in), so I find it best to manually log your own Event in case a error occurs and you want to send an email.
     REM Logs an event which causes eventlog to send an email when it fails.  Also, "/l application" needs to be lowercase.
    eventcreate /t error /id 203 /l application /d "your logged description."
    And then make a completely separate task with a trigger:  On an event.  Basic Selected.  Log: Application.  Source: EventCreate. Event ID: 203.  And have the action on this task send an email (attaching any generated log files, if needed).
    Hopefully helpful (took me 3 days to figure all this out...gar)
    ===================================== End ===================================
         Running A Dot Bat File in Windows Server 2008 Vista 7 etc and beyond V01
    ============================================================================
     

  • 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

  • Final Cut Pro 7 Crashing on startup for only one project

    Hi there, Been using FCP for years now and have never had this issue.  For some reason FCP keeps crashing when I launch a particular project; just this one project!  Others don't seem to have this issue.  Sometimes it does get as far as loading all t

  • Itunes wont Install, could not find key, please help.

    Every time I try to install the new itunes I get an eroor, I have a screen capture of it here: http://i10.photobucket.com/albums/a141/lilyphotos/error.gif I just bought a new ipod and it only works with 7.0. I'm pretty much ready to throw my computer

  • How To display Project Information In Infopath Form Field On Form Load Base on Project Id.

    Hello, I have a Requirment that I want to Display Project Name and their Client Name in Info Path Form Field as I Open the Form. I do have uploaded InfoPath form in Forms Library in Project  of Project server 2010.  is there any simple way to do this

  • [solved]patch 2.6.29-3-ARCH confilict with aufs2

    After checked the aufs2 standalone code and 2.6.29-3-ARCH patch, I found 2.6.29-3-ARCH confilict with aufs2... 2.6.29-3-ARCH changed the do_splice_from of fs/splice.c to vfs_splice_from...   while aufs2 standalone need do_splice_from ... And there is

  • Asian characters in iPhone?

    Hello. I have a client who does asian inputs and outputs on his old Palm Treo 650 and Pilots (don't remember the models) with CJKOS (http://www.dyts.com/en/cjkos.html ). He would like to get an Apple iPhone. Does iPhone have the abilities to do asian