Write directx diagnostics from a cmd command in java

how can I make my java programm run the directX diagnostics tool and write the results into a file?
I guess its the command Runtime.exec(....) but what do I have to fill in?

next code gives me no output, but it does show the
DirectX diag, is there a way to make press the button
save diags to file?
try{
Process process =
s = Runtime.getRuntime().exec("dxdiag");
InputStream pIn = process.getInputStream();//reads
ads data piped from the std out of
                                           //your process
             //read the data here
InputStreamReader isr = new
= new InputStreamReader(pIn);
             BufferedReader br = new BufferedReader(isr);
             String theLine;
             while ((theLine = br.readLine()) != null) {
                  System.out.println(theLine);
          catch(IOException ioe){
If you do this you will only have one line of data saved in your String you would have lost all previous data from this stream seperated by a new line char
try something like
   BufferedReader reader = new BufferedReader(new InputStreamReader(pIn));
   String data = new String();
   for(String temp = reader.readLine();temp!=null;temp=reader.ReadLine()){
       data +=temp;
   }

Similar Messages

  • Running cmd commands through java

    Hi,
    I am trying to run few dos commands through java using Runtime.exec("command") but I am getting following error
    commmand is cd D:\CodeMerge\A\
    java.io.IOException: CreateProcess: cd.. error=2
    at java.lang.Win32Process.create(Native Method)
    at java.lang.Win32Process.<init>(Unknown Source)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at createDirectory.main(createDirectory.java:24)
    Basically what I am looking for is this:
    1) My program is in D:\Amit\RM
    2) I want to get out to D:\ go to CodeMerge\A\.
    3) Create folder with curretn date as name of the folder
    Hence I am doing
    rTime.exec("cd../..");
    rTime.exec("cd D:\CodeMerge\A\");
    rTime.exec("mkdir "+date);
    Can anybody tell me why I am getting this error
    Jounty

    U can run either DOS Commands or UNIX Commands thru the following Java Program
    Written By BalaNagaraju Malisetti
    contact: [email protected]
    import java.io.*;
    public class RunBdiff
    public static String rununixcmd(String v_prev_path,String v_curr_path,String v_delta_path,String v_beg,String v_len)
    String s = null;
    FileOutputStream fos;
    DataOutputStream dos;
    try
    int v_int_beg = Integer.parseInt(v_beg);
    int v_int_len=Integer.parseInt(v_len);
    int v_int_end=(v_int_beg+v_int_len)-1;
    String v_pos1=String.valueOf((v_int_beg+2));
    String v_pos2=String.valueOf((v_int_end+2));
    String cmd1 = "bdiff ";
    String cmd2=v_prev_path;
    String cmd3=" ";
    String cmd4=v_curr_path;
    String cmd5="| grep '^>'";
    String cmd6="| cut -c";
    String cmd7=v_pos1+"-"+v_pos2;
    String cmd8="| sort ";
    String cmd9="| uniq ";
    String cmd=cmd1+cmd2+cmd3+cmd4+cmd5+cmd6+cmd7+cmd8+cmd9;
    String[] commands = {"/bin/csh","-c",cmd}; //in Unix
    //String[] commands = {"cmd.exe","-c",cmd}; //in Windows
    Process p = Runtime.getRuntime().exec(commands);
    BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
    BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
    // read the output from the command
    File file = new File(v_delta_path);
    fos = new FileOutputStream(file);
    dos=new DataOutputStream(fos);
    //Writing the output of bdiff command to Delta File
    while ((s = stdInput.readLine()) != null)
    dos.writeChars(s);
    //Return Error Message to Calling Procedure
    while ((s = stdError.readLine()) != null)
    return s;
    return s;
    catch (IOException e)
    return String.valueOf(e);
    public static void main(String args[])
    String msg=rununixcmd("/home/g_anil/MS_ADDRESS1.dat","/home/g_anil/MS_ADDRESS2.dat","/home/g_anil/MS_ADDRESS_DELTA.dat","1","9");
    **************************************************************************************************************************************

  • CMD commands in Java?

    Ok, Im creating a java program to run in command prompt. I was woundering if there is a way to run command prompt's cmd command (or if java has a simmular command) to clear the screen. I know c++ is able to run the cls command by stateing System("cls");
    Thanks,
    Campsoup1988

    I think you mostly get the same answers as above, but search the forum for "cls dos" (not in quotes, though). You get lots of answers.
    http://onesearch.sun.com/search/onesearch/index.jsp?qt=cls+dos&col=developer-forums&subCat=&rt=true&site=dev&cs=false&dftab=&chooseCat=javaall

  • Getting result from a telnet command through Java

    Hi,
    I've been using a set of classes found here: http://javatelnet.org/
    to do telnet through Java in a non-interactive mode.
    However I've got a problem when retrieving the result of a command sent to the remote host: the classes read the stream until the prompt is encountered; my problem is I must execute commands on several remote hosts, and the prompt is not necessarily the same on all hosts.
    Is there a simple means to establish a telnet connection through Java and retrieve the result of the commands?
    Any help would be appreciated.

    Thanks again, this is a very good article
    I see it is still the same strategy to get the result of a command : wait 'til the prompt is sent. Maybe there is just no other way to get it .
    But as I don't know the prompt on the different hosts I have to query, this won't do it.
    The article gave me an idea though : I only need to count the files in a directory on the remote host; until now I was trying to send the 'ls | wc -l' command by Telnet.
    Maybe I can simply do it by FTP (retrieve the list of files, and then count the lines with JAVA).

  • Running CMD command from process.exec

    I've been chopping this code up so forgive me if this is a mess, however I cannot figure out why this command simply will not work. It never seems to attempt to sign the jar files. I've also tried to sign the jar file by using an output stream. I can run the System.out of the payload from the CMD and it works fine.
    When this method is executed it seems to loop over like nothing is happening.
    private void signJar(String jarPath)
                   String payload = "\"c:\\program files\\java\\jdk1.6.0_17\\bin\\jarsigner.exe\" -keystore \"" + ksPath + "\" -storepass " + ksPW + " \"" + jarPath + "\" " + ksAlias;
                   try {
                        Process proc = Runtime.getRuntime ().exec("cmd /c " + payload);
                        InputStream inputstream = proc.getInputStream();
                        InputStream errorstream = proc.getErrorStream();
                        InputStreamReader inputstreamreader = new InputStreamReader(inputstream);
                        InputStreamReader errorstreamreader = new InputStreamReader(errorstream);
                        BufferedReader inputreader = new BufferedReader(inputstreamreader);
                        BufferedReader errorreader = new BufferedReader(errorstreamreader);
                        while ((line = inputreader.readLine()) != null) {
                             d.asyncExec(new Runnable() {
                                  public void run(){
                        l.setText(line + "\n" + l.getText());
                        while ((line = errorreader.readLine()) != null) {
                             d.asyncExec(new Runnable() {
                                  public void run(){
                             l.setText(line + "\n" + l.getText());
                        errorreader.close();
                        inputreader.close();
                        return;
                        catch(IOException e)
                             e.printStackTrace();
                             return;
              }

    sabre150 wrote:
    You probably have a deadlock since your code falls for at least 2 of the traps described in the 4 sections of [http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html|http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html].
    Thanks, I checked this out and decided to implement one of the methods he had, however, now I am getting an illegal argument exception. I think it is because of my payload, but I am not sure how to fix it. I know everything is formatted properly to input it in the console manually.
    private void signJar(String jarPath)
                   String payload = "\"c:\\program files\\java\\jdk1.6.0_17\\bin\\jarsigner.exe\" -keystore \"" + ksPath + "\" -storepass " + ksPW + " \"" + jarPath + "\" " + ksAlias;
                   String cmds[] = {"cmd","/c",payload};
                   if (cmds.length < 1)
                     System.out.println("USAGE: java GoodWindowsExec <cmd>");
                     System.exit(1);
                 try
                     String[] cmd = new String[3];
                         cmd[0] = "cmd.exe" ;
                         cmd[1] = "/C" ;
                         cmd[2] = cmds[2];
                     Runtime rt = Runtime.getRuntime();
                     System.out.println("Execing " + cmd[0] + " " + cmd[1]
                                        + " " + cmd[2]);
                     Process proc = rt.exec(cmd);
                     // any error message?
                     StreamGobbler errorGobbler = new
                         StreamGobbler(proc.getErrorStream(), "ERROR");           
                     // any output?
                     StreamGobbler outputGobbler = new
                         StreamGobbler(proc.getInputStream(), "OUTPUT");
                     // kick them off
                     errorGobbler.start();
                     outputGobbler.start();
                     // any error???
                     int exitVal = proc.waitFor();
                     System.out.println("ExitValue: " + exitVal);       
                 } catch (Throwable t)
                     t.printStackTrace();
              }Updated with different code still same error
    EDIT: I should pay closer attention and stop trying to copy and paste code. I see where he says you can't use it like the command line...

  • How to write the CMD command for restarting all obi services?

    Hi Experts,
    BIEE:11.1.1.6
    How to write the CMD command for restarting all obi services automatically by windows task scheduler?
    I am try to write the code as below, but it does not work. Please help me to review it and check what I am missing.Thanks.
    Or is there any better method for solving my requirement ? Please share me.Thanks very much.
    cd C:\InstallPath\OBIEE\instances\instance1\bin
    opmnctl stopall
    opmnctl startall
    I am facing the problem that it does not excute the 'opmnctl startall' code, which will be stopped after 'opmnctl stopall',
    So how to modify the command ?Thanks

    See if any of the these are useful or solves your query -
    4.5.2 Using a Windows Service to Start and Stop System Components
    http://docs.oracle.com/cd/E23943_01/bi.1111/e10541/components.htm#BABEEAAI
    4.5.3 Using the Oracle BI Systems Management API to Programmatically Start and Stop Oracle Business Intelligence
    http://docs.oracle.com/cd/E23943_01/bi.1111/e10541/components.htm#BABFGICA
    Edited by: Abhi on May 8, 2013 4:44 AM

  • How to run a CMD command directly from run ?

    How to run a CMD command directly from run ?
    Like "cmd md D:\abcd". I did this before. But now I totally forgot how to do that ?
    Please help..........

    Hi,
    To add, here is the command CMD reference:
    Cmd
    Best regards
    Michael Shao
    TechNet Community Support

  • How can we write the code for opening the command prompt and closing the

    how can we write the code in java for opening the command prompt and closing the cmd prompt from eclipse (cmd prompt should close when click on the turminate button in eclipse)

    rakeshsikha wrote:
    how can we write the code for opening the command prompt and closing theBy typing in Eclipse (which you seemingly have)?

  • Windows 7 x64: Execute a 64bit exe/script from a 32bit command prompt?

    Anyone have any tricks up their sleeve to do as the title says?  For example:
    I'm working within a 32bit app that calls a command using cmd.exe.  In taskmanager we see cmd.exe*32
    From that cmd.exe, say we want to launch notepad.exe.  Obviously taskmanager will show notepad.exe*32.  We want plain old "notepad.exe" running in 64bit mode.
    Thoughts:
    I've been unable to do this using vbscript and may try a .NET console application next.
    Another thought is to set up a schtask, run it, then delete it....but that sounds messy.
    Am I missing something that would make this extremely easy?

    Well, I'm working within WiseScript Editor and SMS Installer. They are 32bit compiled scripting languages so, if I launch notepad.exe from within the compiled Wise or SMS Installer scripts, using either their built-in Execute Program command the OS
    always launches the process as a 32bit process as the parent process is 32bit even when trying to specify notepad.exe in %WINDIR%\system32.
    I did, however, find a solution using vb.net.  I compiled the following code as a console app named cmdx64.exe
    Module Module1
        Sub Main()
            Dim arrArgs As Array
            Dim Args As String = ""
            Dim intCount As Integer = 0
            arrArgs = System.Environment.GetCommandLineArgs()
            For Each Arg In arrArgs
                If intCount <> 0 Then Args = Args & " " & Arg
                intCount = intCount + 1
            Next
            Shell("cmd.exe /C" & Args, AppWinStyle.NormalFocus, True)
        End Sub
    End Module
    Now when I run "cmdx64.exe notepad.exe" from within WiseScript Editor and SMS Installer instead of getting notepad.exe*32 I now get the 64bit flavor. So...I guess I answered my own question but it required a custom console command.  I was hoping
    for a native solution.

  • Host and cmd command

    Hi,
    i want to use some cmd commands in my form to copy and del some pictures.
    I found out that 'host' or 'client_host' are the build ins i need
    My Problem:
    How can i use more than one command...
    A .bat file works with this cmd commands:
    md C:\Versuch\Archivierung %date%
    copy N:\ftpRoot\Scanner\Einzeln\*.jpg C:\Versuch\Archivierung\%date%
    erase N:\ftpRoot\Scanner\Einzeln *.JPG /q
    But i dont know the syntax for the host() build in
    host('cmd /c md C:\Versuch\Archivierung %date% copy
    N:\ftpRoot\Scanner\Einzeln\*.jpg C:\Versuch\Archivierung\%date% erase N:\ftpRoot\Scanner\Einzeln\*.JPG /q', no_screen);
    ...in one line doesnt work. i can run the .bat file but i want to do the destinations dynamically, so i need to use my commands in pl/sql for my form.

    You have write seperate HOST commands for each command you need to issue.
    like:
    HOST('cmd /c md test');
    HOST('cmd /c copy abc efg');
    etc..

  • How to call cmd commands in OS COMMAND

    Hi
    I need the syntax for calling a cmd commands using OS Command tool.
    Thanks
    sri

    I was trying to say you incase you are using the xcopy using the server agent when you mention the path please specifiy the complete directory path , since ODI run the scripts from oracledi/bin path .
    Now when you are running cezar command , you dont need to have the file . it copy the directoy liste into that txt file.

  • Execute cmd command with spaces

    Hi dears,
    I am trying to execute a cmd command (shell comnmand), but I got no response from the console i,e it is not executed even no errors returned.
    here is my code to be executed
    import java.io.*;
    import java.util.*;
    public class TestCommand
         public static void main(String[] args)throws IOException
              String[] cmd={"Nvdkit notify.tcl ALL hameed1 hameed2"};//command with arguments
              String[] envo={"path=;","path=C:\\Program Files\\Novadigm"};//path of the file
              //String[] cmd2={"cmd.exe","\\C","dir"};
              Runtime rt = Runtime.getRuntime();
              Process pp = rt.exec(cmd);
              //pp.waitFor();
              writeProcessOutput(pp);
         static void writeProcessOutput(Process p)throws IOException
              InputStreamReader tempReader = new InputStreamReader(new BufferedInputStream(p.getInputStream()));
              BufferedReader br = new BufferedReader(tempReader);
              while(true)
                   String line = br.readLine();
                   if(line==null)
                        break;
                   System.out.println(line);
    }     Could you please assist?
    thanx in advance
    Edited by: hameedo on Sep 21, 2008 11:51 AM

    import java.io.*;
    import java.util.*;
    public class TestCommand
         public static void main(String[] args)throws IOException
              String[] cmd={"java","-version"};
              String[] envo={"path=;","path=C:\\Program Files\\Java\\jdk1.6.0_02\\bin"};
              String[] cmd2={"cmd.exe","\\C","dir"};
              Runtime rt = Runtime.getRuntime();
              Process pp = rt.exec(cmd,envo);
              //pp.waitFor();
              writeProcessOutput(pp);
         static void writeProcessOutput(Process p)throws IOException
              InputStreamReader tempReader = new InputStreamReader(new BufferedInputStream(p.getInputStream()));
              BufferedReader br = new BufferedReader(tempReader);
              while(true)
                   String line = br.readLine();
                   if(line==null)
                        break;
                   System.out.println(line);
    }     The above code won't executed correctely.
    I am trying to get java version, but no errors no iformation were returned!
    Coudl you please assist in this issue?
    thanx all

  • How to set JRE 1.5.0_07 as default Java from the cmd line in Windows

    Hi All,
    We are currently in the process of upgrading our company to IE8. As MS JVM is incompatible we need to remove it.
    However, once we have done this JRE 1.5.0_07 is not the default version of Java any more for IE8.
    My question is - Is there a command line switch to set set JRE 1.5.0_07 as default Java from the cmd line in Windows. ie the setting in Java Control panel where you would tick Internet Explorer?
    Thanks in advance!

    This is to confirm a similar issue. Here is the scenario:
    We are currently using IE 6 and looking forward to upgrade to IE 8. Our current Java version is: J2RE 1.5.0_16.
    When updating from IE 6 to IE 8 with J2RE 1.5.0_16 on a test workstation, we get the following error from the Java testing website (http://www.java.com/en/download/help/testvm.xml): "load: class testvm2/Main.class not found."
    Workaround :
    -> Change Java JRE Network Settings in Control Panel to "User proxy server : xxx.xxx.xxx.xxx:xx"
    We are using an autoconfig.pac file and it seems IE8 can't parse the settings to JRE to go through the proxy.
    Please advise if you have a fix for the autoconfig.pac file.

  • ODI - Error when Executing a Scenario from an OS Command

    I am developing a project with ODI on Oracle 10g, but I have had some troubles with it.
    Problem:
    I have a scenario that I run from the Designer and it works correctly.
    But, the problem is when I want to run it from a terminal command from an Operating System (OS).
    For this, I did the following steps:
    1.-Configure file odiparams.bat file from the path C: \ OraHome_1 \ oracledi \bin as follows:
    set ODI_SECU_DRIVER=oracle.jdbc.driver.OracleDriver
    set ODI_SECU_URL=jdbc:oracle:thin:@192.168.1.114:1521:orcle
    set ODI_SECU_USER=ODI_REPMSTR
    set ODI_SECU_ENCODED_PASS=eyfpRSdWr9N5rARKkCmCNMVrEp
    set ODI_SECU_WORK_REP=ODI_REPWORK
    set ODI_USER=SUPERVISOR
    set ODI_ENCODED_PASS=LELKIELGLJMDLKMGHEHJDBGBGFDGGH
    2.- Launching a Listener Agent
    Start\All programs\Oracle\Oracle Data Integrator\Agent
    3.- Run the next command:
    startscen ACT_ETL_CGA 001 GLOBAL -NAME=AGENT_1 "-v=5"
    But, at the end of the execution, it shows one list like that
    FirstDate:2010-03-01 17:10:24.0
    FirstUser:SUNOPSIS_INSTALL
    IndChange:I
    IntJavaName:com.sunopsis.dwg.dbobj.SnpState
    IObjects:4700
    LastDate:2010-03-01 17:10:24.0
    LastUser:SUNOPSIS_INSTALL
    ObjName:OBJ_SNPSTATE_4700
    SecuPos:570, ExtVersion:null
    And last:
    java.lang.NullPointerException
    DwgJv.main: Salida. Código de retorno:-1
    Can you please help.
    Thanks.
    Arturo Rubio

    Hello,
    Try to remove and recreate your package and scenario, I had the same issue and solved doing it.
    It seems for me that the package cannot update its contents, for example, if you change something in your interface, you must recreate your package and scenario to update the changes.
    What ODI version do you use? If you use an old version, try to update to ODI 10.1.3.5
    Regards,
    Wallace Galvão
    São Paulo - Brazil

  • Could not complete the new 3D extrusion from selected layer command because the path is too complex.

    I was trying to do a photo of mine like in this video but its not working help needed. thanks.
    http://www.youtube.com/watch?v=egyLY78H7nE
    When I tried the 3D I got an error message that said (could not complete the new 3D extrusion from selected layer command because the path is too complex.) what does this mean and how can i fix it?

    There was a bug at one time where really simple paths (like a triangle, for example) could cause that error.
    Is your path really simple (I don't plan to go watch the video)?  If so, have you installed the latest update for Photoshop?  That bug may have been fixed already.
    If it's not that, it's possible that if your path is really complex and simply exceeding Photoshop's capability.
    -Noel

Maybe you are looking for

  • Starting a workflow from an XML file

    Does anyone know if there is anyway to have a workflow poll a folder for the existence of an XML file and start a workflow with it? When looking in the documentation, there is a mention of a scheduler. I need to integrate with a fairly old system tha

  • Subclassing a Java Class in JRuby

    Hello, everyone. I'm studying JRuby by writing a minimal Swing app in Ruby. It seems to be an effective way of finding Ruby <-> Java integration issues. ;) I am trying to create a subclass of AbstractAction for a button whose name will be "Quit" and

  • Macbook air graphics flicker

    Hi I have a brand new Macbook Air 13" i7.  OSX 10.8.4 Graphics in finder windows sometimes flickers.  Someimes this occurs in Safari also.  Particularly when discplaying a PDF. Anyone have a soluion? Thanks, Stee

  • Adding pc to i match fails

    When i try to add my newer windows 7 pc to i match, itunes always malfunctions and has to close when it is scanning the library.  I have the latest version of itunes installed also.  I was able to do it on my pc which has xp service pack 2 after i in

  • Error While Importing the Attribute Groups using Import Config

    Hi All, I have succesfully exported attribute groups using export config but facing an issue while importing them after resetting the data store.Can any one help me out??? I am facing the follwing weird error and unable to debug it: ERROR [WatchDog]