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> ")

Similar Messages

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

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

  • 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

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

  • 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

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

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

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

  • Run batch file on a remote computer

    I am looking for syntax so that I can run a batch file that is on my computer and I want to run it on a remote computer. I am thinking I can do this with psexec but have not been able to figure out the correct syntax.

    psexec.exe -s \\namepc -u yourusername -p yourpassword cmd /k c:\blabla\Install.bat
    Install.bat must be on some folder on remote pc and I think that is only posible way.
    U can change \\namepc with @blabla.txt file with computers list if you want to run that bat file on more computers.
    Your account in this example must have admin rights on remote computer.

  • How to execute  a batch file using javascript

    Hi,
    I dont know java. i have a batch file to do my task. Im designing the front end with HTML.Can anyone tell the command to execute batchfile using javascript
    Message was edited by:
    viswanath_java

    Java and not JavaScript are not the same thing or even close to the same thing. You appear to be in way over your head. It might be a good time to fess up to your employer that you are underqualified.
    Apart from the JavaScript faux pas your question is also lacking because
    - you don't identify what this batch file is or does or needs to execute in
    - it is very difficult to understand how the front end for this will be HTML
    It seems you may one day want something like a Servlet. But you are long way from implementing this solution.

  • Psexec shows Access denied when i execute a .exe file on a remote machine

    Hi All,
    I am using Psexec application to run exe on multiple remote machines in the domain. When i run the the .EXE i get the error message saying access is denied.
    I am running this script against agents in a list.
    Below is the script i am running in the batch:
    "C:\Windows\system32\PsExec.exe" @C:\Test.txt cmd
    1. I am first connecting to the cmd of the remote computer and it connects successfully.
    2. When i enter the .exe file location on the command prompt (which is also in a shared drive but in the same domain).
    3. I ran the batch file as Run as administrator
    4. I am itself a member of the Domain admins and Administrators group of the domain.
    5. Turned off firewall on both sides.
    6. Turned off UAC fully as per the below MS article - http://technet.microsoft.com/en-us/library/cc709691(v=ws.10).aspx
    7. Pressed shift and right click so i will get the Run as option and mentioned different domain admins user account and password.
    Below is the screenshot for your reference: 
    Restated both the machines after doing these changes. But still the same issue.
    But still i get access is denied. Can anyone please help.
    Gautam.75801

    Few days back when i used to run the same task in this Access is denied mode its self. My destination server used to give a Audit failure event log as below.
    Now a days this event log does not come.
    Can this help for analysis.
    Subject:
    Security ID:
     Domain name\My username
    Account Name:
     Gautamr
    Account Domain:
    My Domain
    Logon ID:
     0x234992
    Object:
    Object Server:
    Security
    Object Type:
     File
    Object Name:
     C:\Windows\System32\eventvwr.msc
    Handle ID:
     0x0
    Process Information:
    Process ID:
     0x17e0
    Process Name:
     C:\Windows\System32\mmc.exe
    Access Request Information:
    Transaction ID:
    {00000000-0000-0000-0000-000000000000}
    Accesses:
     READ_CONTROL
    SYNCHRONIZE
    WriteData (or AddFile)
    AppendData (or AddSubdirectory or CreatePipeInstance)
    WriteEA
    ReadAttributes
    WriteAttributes
    Access Reasons:
    READ_CONTROL:
    Granted by
    D:(A;;0x1200a9;;;BA)
    SYNCHRONIZE:
     Granted by
    D:(A;;0x1200a9;;;BA)
    WriteData (or AddFile):
    Not granted
    AppendData (or AddSubdirectory or CreatePipeInstance):
    Not granted
    WriteEA:
     Not granted
    ReadAttributes:
    Granted by ACE on parent folder
    D:(A;;0x1301bf;;;BA)
    WriteAttributes:
    Not granted
    Access Mask:
     0x120196
    Privileges Used for Access Check:
    Restricted SID Count:
    0
    Gautam.75801

Maybe you are looking for

  • Deleting a row from a table using jsp

    Given a table in a jsp, can an user click on a row of that table and retrieve the information so that the program can delete a record from a database table? most of the tables that I have seen are static, the user cannot interact with them(specially

  • Unable to select ERP6EHP6 to download files

    Hello All, I have a ERP6EHP5 system and a solution manager 7.01 SPS28. I plan to download ERP6 EHP6 installation files  via solution manager. But i cann't select EHP6 in Maintenance Optimizer Transaction. Following is the detail. 1. tcode: dswp.    

  • TV@nywhere -- no sound when timeshifting

    I just installed my card, and most of it works, although some of the channels are have really bad reception, and tuning is no help. Anyway, the big problem I can't seem to solve is with pausing and timeshifting.  Both work, but I get no sound on play

  • IPad 4 with camera connection kit doesn't work with 64GB SDXC card on iOS 7.1.1

    I have an iPad 4 and official Apple camera connection kit. Even though ios 7 was supposed to provide compatibility with SDXC cards there is obviously an issue. I'm using 64GB SDXC and 32GB SD cards - both Sandisck Extreme Pro with RAW Canon 5D Mark I

  • User exit - change header status of quotation - VA22

    Hi, I want to limit the user who can change the header status of quotation by using VA22. Can anyone help me to identify the user exit to do this. Thanks in advanced, Thang