Executing a batch file (.bat) on a different PC

Hi,
Is it possible to execute a batch file on a different pc.
Look at the following piece of code.
import java.io.*;
public class StartRemoteCmd {
     public static void main(String[] args) throws IOException
          System.out.println("Starting remote Command");
Process p = Runtime.getRuntime().exec("\\\\Itop001\\Tomcat\\commons-net-1.0.0\\setclasspath.bat");
          if (p==null){
          System.out.println("Process is null");
          System.exit(1);
          System.out.println("Started remote Command");
The machine ITOP001 has this setclasspath.bat...which sets classpath and has a java CustPgm.
I want to start this CustPgm program on ITOp001 from my machine.
Is it possible..? Am I doing some mistake in the code..pls suggest.
Thanks guys

Can't really add much to the online help:
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.
AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
    [ /EVERY:date[,...] | /NEXT:date[,...]] "command"
\\computername     Specifies a remote computer. Commands are scheduled on the
                   local computer if this parameter is omitted.
id                 Is an identification number assigned to a scheduled
                   command.
/delete            Cancels a scheduled command. If id is omitted, all the
                   scheduled commands on the computer are canceled.
/yes               Used with cancel all jobs command when no further
                   confirmation is desired.
time               Specifies the time when command is to run.
/interactive       Allows the job to interact with the desktop of the user
                   who is logged on at the time the job runs.
/every:date[,...]  Runs the command on each specified day(s) of the week or
                   month. If date is omitted, the current day of the month
                   is assumed.
/next:date[,...]   Runs the specified command on the next occurrence of the
                   day (for example, next Thursday).  If date is omitted, the
                   current day of the month is assumed.
"command"          Is the Windows NT command, or batch program to be run.

Similar Messages

  • Executing a batch file(.bat) from an AIR application

    Is there a way by which we can exceute a dos batch file from an AIR 1.5 application?

    I think your only option might Merapi, and that might only be for linking AIR and Java apps.
    http://merapiproject.net/
    If this post answers your question or helps, please mark it as such.
    Greg Lafrance
    www.ChikaraDev.com
    Flex Development and Support Services

  • How to execute a batch file on different remote server using TFS Build

    I have a build server and have 2 web servers. I am deploying using TFS Builds. Now, I have a requirement to execute a batch file which is kept on these 2 web servers. i.e. C:\MyBatch\CreateMe.bat
    After my build is successful, I need to execute this batch from the build server.
    Note, I cannot make any shared folder.

    Hi Sameer, 
    Thanks for your post.
    What’s the version of your TFS?
    How do you deploy solution using TFS Build, run MSBuild deploy command or using Release Management?
    That C:\MyBatch\CreateMe.bat file stay on your two web server machines separately? 
    If you want execute this bat file on your two web server machines separately using build process template, you need configure your web server machine as build agent, then add the InvokeProcess activity in build process template to run the bat file on build
    agent machine after build, please refer to Hari’s answer reply in this post:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/b8bcb19f-1296-441c-8356-e701b949445a/tfs-2010-how-to-execute-a-batch-file-after-build?forum=tfsbuild.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Execute a Batch file

    Hi,
    I need help in writing a method that execute a batch file which is in a different directory from my java application and show the result(after executing the batch file) in the java application. Can anyone tell me how to do that?
    Thanks,
    Khim

    Hi,
    Below are the codes in my application. Using these codes, the batch file can execute but I cannot get the output of the result from the batch file. (if I run the batch file from cmd, it shows: "Error: 0 : Cannot authenicate the information after all the attempts")
    String cmd = new String();
    Runtime rt = Runtime.getRuntime();
    System.out.println("Executing VocaliD check..");
    cmd="C:\\JNI\\Elva\\debug\\plug.bat";
    Runtime rn = Runtime.getRuntime();
    Process pc1 = rn.exec(cmd);
    String result=new String(pc1.getInputStream().toString ());
    System.out.println(result);
    The result I got is below:
    Executing VocaliD check..
    java.io.BufferedInputStream@3179c3
    Thanks,
    Khim

  • Urgent : Executing a batch file in a JSP file

    Hi;
    I need help in executing a batch file within a jsp page, ive the following codes but it doesnt seem to work...
    These are the codes :
    <%@ page import="java.util.*,java.io.*,java.net.*" %>
    <%@ page import="java.sql.*" %>
    <%
    Process p = Runtime.getRuntime().exec("Ratio.bat");
    p.waitFor();
    int i = p.exitValue();
    %>
    The following is the error :
    ype Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.io.IOException: CreateProcess: Ratio.bat error=2
    java.lang.Win32Process.create(Native Method)
    java.lang.Win32Process.<init>(Win32Process.java:63)
    java.lang.Runtime.execInternal(Native Method)
    java.lang.Runtime.exec(Runtime.java:550)
    java.lang.Runtime.exec(Runtime.java:416)
    java.lang.Runtime.exec(Runtime.java:358)
    java.lang.Runtime.exec(Runtime.java:322)
    org.apache.jsp.invRatio_jsp._jspService(invRatio_jsp.java:52)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    Anyone can tell me why it doesnt work ?... Thanks

    Aside from removing the "start" or adding the title ...
    Does your batfile really say "SET PATH=%PATH%;%JAVA_HMOE%\bin"? If so, I rather expect you meant to say "JAVA_HOME" and not "JAVA_HMOE".
    Also, I'd be cautious about those relative paths that you're passing in to the Java program. Of course I don't know what you're doing with those in the program, but if you try to just pass those paths to a File or InputStream constructor, they're going to be relative to the current directory. And if you execute a batfile using cmd from an exec that's within a JSP ... I'm not sure what your current directory would be when the bat runs. Maybe you've checked this out and it's the right place, but if not, perhaps you have a misconception there.

  • How to run a batch file (.bat) from forms? WEBUTIL_HOST.NonBlocking?

    I need to execute a batch file on the clients pc. Right now, I'm using:
    WEBUTIL_HOST.NonBlocking('cmd.exe /c "' || :Test.Batch_File_Name || '"');
    where the :Test.Batch_File_Name is something like C:\run.bat.
    This works to some extent. When it runs, I see a blank cmd.exe window and when I check my processes, I can see that run.bat is running. However, I need to be able to see run.bat as it executes because it outputs messages to the screen. Is there a way to call client_host or webutil_host that will display the batch file screen?
    Thanks

    Hello,
    With the Webutil Get_Standard_Output() , you can get the output strings and display them into your own Forms canvas ;o)
    Francois

  • Java.io.filepermission error while executing a batch file from java prog

    Hi,
    i want run a java program which executes a batch file, both are in a jar file. while am trying this using webstart it shows error:access denied java.io.filepermission <<ALL FILES>>execute. why this happens how to rectify this.
    By
    Vinod

    Clearly, it would be a security vulnerability to be able to do such a thing from the web w/o user granting trust to the application.
    Java Web Start applications run in the Java SE secure sandbox unless they have been granted all-permissions by the user:
    1.) sign all jar files.
    2.) add <security><all-permissions/></security> to the jnlp file.
    The user would then be prompted to grant trust to the applications.
    /Andy

  • How to execute java batch file in JSP

    Kindly give a solution. I want execute a batch file which gives a preview window ,. I want call that batch file in my jsp, .I am using Tomcat 5.5, I have tried that using a Process object and Runtime.getRuntime().exec(path) , where path is location of my batch file. As a java class i could execute the batch file, but when i import the method in JSP nothing is happening (even no jsp error).
    Is it possible to execute the batch file in JSP?
    Can any one help me?

    itsdhanasaraa wrote:
    But as this a web application ... By using Runtime i'm getting some probs ..
    Let me guess, you want your web application to run a program on the client and to your surprise that's not working?
    Ain't gonna happen.
    its taking more time to execute .... that's y is there any other option to execute .exe file other than Runtime.getRuntime().exec("filename");Write proper English and you may be taken more seriously.
    1) it's not "taking more time to execute", whatever that's supposed to mean.
    2) there's no other way to execute something. Not that you should every use even that way anyway
    3) whenever you start thinking of executing external programs from Java, start thinking of not using Java in the first place.

  • Executing the batch file from SQL Server Agent job

    Hi - I have a simple batch file (.bat) which connects the SFTP server and drop the files to location machine.  When I run the .bat file manually its working fine but when I schedule it in SQL Agent its keep on running and never shows success message. 
    Could you please tell me how can i resolve it.  Its very urgent for me.
    thanks

    If you trust this host, enter "y" to add the key to
    PuTTY's cache and carry on connecting.
    If you want to carry on connecting just once, without
    adding the key to the cache, enter "n".
    If you do not trust this host, press Return to abandon the
    connection.
    Store key in cache? (y/n) Remote working directory is /
    When you connect via putty you get prompted to accept a key in interactive mode. At this point your batch file is waiting for someone to type in y or n.  
    Try running putty in batch mode to get around this.
    http://the.earth.li/~sgtatham/putty/0.52/htmldoc/Chapter6.html#6.1.8
    6.1.8 -batch: avoid interactive prompts
    If you use the -batch option, PSFTP will never give an interactive prompt while establishing the connection. If the server's host key
    is invalid, for example (see section 2.2), then the connection will simply be abandoned instead of asking you what to do next.
    This may help PSFTP's behaviour when it is used in automated scripts: using -batch, if something goes wrong at connection time, the batch
    job will fail rather than hang.

  • Executing a batch file from a jsp

    hi,
    i have a jsp running on tomcat 3.1
    now upon submit, i want a batch file to execute .
    how do i do that..( i mean what will be the correct syntax for this ) say the batch file exists in /tomcat/batch/ do i have to give the abosolute path for this or a relative path will do.. ( if the relative path works then, do i have to mention a context for the batch directory in server.xml..
    pls help.. this is urgent
    thanx

    Hi truptip,
    This is the code to execute a batch file or any system command,
    Process p = Runtime.getRuntime().exec("shell command you want to exit");
    p.waitFor();
    In regards to whether you should access it using a relative location, the answer is no. Execution of a batch file is not part of the the webserver, so the webserver's concept of the current directory for the client does not apply.
    On a side note I wanted to say that I would highly recommend that you don't put the batch files anywhere on the webserver that is accessible to the user, not that the webserver would execute the code, but it may let out some information that you don't want available.
    Hope this is of some help,
    James

  • Running executable in batch file as administrator when UAC is high

    Hi Team,
    I have a requirement of running executable in batch file by passing the current windows login username as parameters. Below is the content of my batch file:
    cmd /c start setup.exe http://testsite:7001/mobile  %username%  %username%
    But, when the UAC is set high in windows 7 machine, this executable is not running properly, and giving me warnings. And, if I am running the same start command after opening command prompt as administrator, then executable is running smoothly.
    So, is there any way I can run the executable as administrator by giving some options in batch file, when UAC is high?
    I tried runas option, but its prompting for admin password, which we can't provide as users will not know.
    Do we have some option in batch file as 'Run As Administrator' right click option, where it doesn't prompt for password but run the file with admin privilege?
    Thanks,
    Tina Soni

    Hi,
    When using Runas command, you can add a switch option /savecred
    /savecred will make it ask for admin password on the first run only, after that it should be saved
    Yolanda Zhu
    TechNet Community Support

  • Executing an Executable or Batch file in DOS/Unix Env. - Urgent Urgent.

    Hi there
    We are currently using Oracle 8i with 9ias as the Application Server. I have a requirement where I should be executing a batch file or a executable on the local client system (from where the browser runs).
    I have downloaded a script from Oracle Metalink which creates a class file. This class file enables me to create a executable or a batch file on to the local client machine. But does not allow me to execute it.
    Can anyone kindly send me a script which enables me to execute a .exe file on the client machine.
    Many thanks in advance.
    Regards
    Pavan Chelvaraj

    I have the below program. I need to embedd, the script for executing a file. Please help.
    Regards
    Pavan Chelvaraj
    import oracle.forms.ui.*;
    import oracle.forms.properties.ID;
    import oracle.ewt.lwAWT.lwText.*;
    import java.awt.*;
    import java.io.*;
    public class TextPJC extends VTextArea {
    private static final ID READFILE = ID.registerProperty("readfile");
    private static final ID WRITEFILE = ID.registerProperty("writefile");
    private String filename=null;
    public TextPJC() {
    super();
    public boolean setProperty(ID pid, Object value)
    if(pid ==READFILE) {
    try {
    File inputFile = new File((String)value);
    FileReader in = new FileReader(inputFile);
    char c[] = new char[(int)inputFile.length()];
    char c1[]= new char[(int)inputFile.length()];
    in.read(c);
    int j=0;
    for (int i=0;i<inputFile.length();i++)
    if((int)c==13);
    else
    c1[j++]=c[i];
    String str = String.copyValueOf(c1,0,j);
    this.setContent(new LWTextArea(str));
    in.close();
    catch(Exception e) {System.out.println("Error in PJC " );e.printStackTrace();}
    return true;
    else if(pid==WRITEFILE) {
    try {
    File inputFile = new File((String)value);
    FileWriter in = new FileWriter(inputFile);
    LWTextArea lw = (LWTextArea)(this.getContent());
    String text1 = lw.getText();
    int length1 = text1.length();
    char c[] = new char[(int)length1];
    char c1[]= new char[(int)length1*2];
    text1.getChars(0,length1,c,0);
    int j=0;
    String s1= System.getProperty("line.separator");
    for(int i=0;i<length1;i++)
    if ((int)c[i]==10)
    s1.getChars(0,s1.length(),c1,j);
    j=j+s1.length();
    else
    c1[j++]=c[i];
    in.write(c1,0,j);
    in.flush();
    in.close();
    catch(Exception e) {System.out.println("Error " );e.printStackTrace();}
    return true;
    else
    return super.setProperty(pid,value);

  • Batch file (.bat)

    hello Guyz....
    I just want to know , how can i execute multiple lines in a .bat file... i.e a batch file...
    the batch file is for a parser which is developed in java...
    Please reply....
    Thank you
    Nikhil

    If you're trying to launch a java program from a batch file, just Google it
    http://forum.java.sun.com/thread.jspa?threadID=622449&messageID=3524317
    if you're trying to run a batch file from withing java
    http://www.artima.com/legacy/answers/Jan2001/messages/1.html

  • How can I execute a batch file from my java program

    Hi,
    Can someone help me or direct me to a link,
    How can I execute a DOS batch file from my java program?
    Thanks

    You will need to grab a handle to the process's
    outputstream so u can see its output.The OP didn't mention any output from any batch file;
    nor any input for that
    matter,so lets not complicate matters here for now
    ok?Actually I think this is essential to see whether it works or not. It's either that or do some manual check to see whether it ran, which is not exactly elegant, and in some cases this may not be easier than simply writing the output stream code, or in fact it may be impossible to check manually.
    I'm sure it wasn't intentional that your post appeared to be bristling with attitude.

  • Execute a batch file on a remote PC

    Hello,
    I have a powershell script that I would like to exceute several batch commands on a remote computer.  I first need the script to change to the network drive on that remote computer then execute a batch command that I write into the script is that
    possible?
    G

    I did try it and no results were giving and the jvm services on the remote machine was not stopped.  Here is what im trying to do based on your suggestions.
    $process
    =
    [WMICLASS]"\\severgoeshere\ROOT\CIMV2:win32_process"
    $result
    =
    $process.Create("e:\stopserver.bat
    JVMdfs -user <myusername> -password <mypassword> ")

Maybe you are looking for

  • Local area connection doesn't have valid ip

    I have a Touchsmart 320-1030 that belongs to a friend. Everything was working fine then for no apparent reason connection to the internet was lost.  They have contacted their isp and gone through all troubleshooting with them. All other equipment (ie

  • I have problems with the language when i install i put another language how can i repair that

    I need help because i was instaling first time my apple tv and whm i was going to select my language y press another one that i dont undestand , please can some one help me with this ?

  • Decode a parameter to be all values

    Hi- I would like to know if there is a way to decode a value of a parameter to all values for a particular column: ie can i DECODE(column_name, 'ALL', [something that represents all], 'Option1', 1, 'Option2', 2, 3) I have tried to use *- discoverer g

  • Gallery withn a gallery?

    short version: I have a gallery page with 3 different collections of photos. I want to add a new one that will open up a new page with two new collections. Is this possible? detailed version: I have a photography website. One of the pages is a galler

  • Photoshop CS3 printing problem

    Hello all, One of my client is having problems printing Contact sheets on his color printer. Here is the scenario; User opens CS3 File - Automated - Contact Sheet II Browse to folder where pictures are and selects folder Contact sheets get created At