Problem during executing Command Prompt

Hi All
My current code is executing system commands through java programme,like �dir�,�date� itc.Whenever I run the code the desired output comes.But when I am running the code continuselly then lots of command prompt open regularlly.
Is there any way to stop the code from execution untill unless the command prompt get closed manually?Here is my code.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
interface IPerlService
     public String BZMCreateZone(String s);
     public int BZMRenew();
public class Sample
     public void BZMCreateZone()
          Runtime runtime;
          Process process;
          String s=null;
          String str=null;
          try
               runtime = Runtime.getRuntime();
               process =runtime.exec("cmd /c start dir");
               str=process.toString();
          try
               process.waitFor();
               catch (InterruptedException e)
               e.printStackTrace();
               BufferedReader reader = new BufferedReader(
               new InputStreamReader(process.getInputStream()));
          s = reader.readLine();
          catch (IOException ex)
               ex.printStackTrace();
     public static void main(String[] args)
          Sample obj_Sample= new Sample();
          obj_Sample.BZMCreateZone();
}

I want to execute below commands programmatically.
devenv D:\TestApp\TestApp.sln /rebuild release
devenv D:\TestApp\TestApp.sln /rebuild debug
But I am not able to set the current directory path as "D:\TestApp\" programatically.
Through which API I can execute multiple commands on command prompt programmatically same as  we do manually on cmd.
Why can you "not able to set the current directory path as "D:\TestApp\" programatically"? Are you forgetting to escape the backslashes?
Why to you need to set the current directory anyway?
What is the problem with executing multiple commands?
As to your basic goal, have you looked at
system()
ShellExecute()
ShelExecuteEx()
CreateProcess()
? Perhaps you should show us what you have tried.
David Wilkinson | Visual C++ MVP

Similar Messages

  • Problem in executing command prompt commands through application

    Hi,
    I am facing issue in executing commands through VC++ application.
    My application is a dialog based MFC application in VS2008.
    I want to execute below commands programmatically.
    devenv D:\TestApp\TestApp.sln /rebuild release
    devenv D:\TestApp\TestApp.sln /rebuild debug
    But I am not able to set the current directory path as "D:\TestApp\" programatically.
    Through which API I can execute multiple commands on command prompt programmatically same as  we do manually on cmd.
    Please Help.
    Thanks in Advance. 
    Thanks & Regards, Mayank Agarwal

    I want to execute below commands programmatically.
    devenv D:\TestApp\TestApp.sln /rebuild release
    devenv D:\TestApp\TestApp.sln /rebuild debug
    But I am not able to set the current directory path as "D:\TestApp\" programatically.
    Through which API I can execute multiple commands on command prompt programmatically same as  we do manually on cmd.
    Why can you "not able to set the current directory path as "D:\TestApp\" programatically"? Are you forgetting to escape the backslashes?
    Why to you need to set the current directory anyway?
    What is the problem with executing multiple commands?
    As to your basic goal, have you looked at
    system()
    ShellExecute()
    ShelExecuteEx()
    CreateProcess()
    ? Perhaps you should show us what you have tried.
    David Wilkinson | Visual C++ MVP

  • Problem in Executing Command Line

    Hello all,
       I am trying to execute the Perforce command lines through LabVIEW System Exec. These commands are working propery when directly entered in the command prompt, but through LabVIEW it is not working properly.
    "P4 client -i  <E:\template.txt"
    This command will read the file and create a client. Whenever we are doing this kind of  file operation (reading or writing), the command through LabVIEW is not working and the System Exec VI is giving the Standartd error output as  " Usage: client -i [ -f ] Unexpected arguments", but working perfectly in the comand prompt,

    hi cranen,
      use "cmd/c P4 client -i  <E:\template.txt" as command line input to the system exec.vi.
    Thanks and regards,
    srikrishnaNF

  • Problem during executing MC8G transaction

    Hi,
    I have created inactive plans in MC88 and transferring it to demand (in active) , for this I am using background scheduling MC8G transaction. But system is unable to transfer any plan and status of batch is always coming as canceled. 
    Please let me know how do I rectify this problem.
    Regards,
    Pavan

    Hi,
    Try these two options.
    1. Planning job is created via MC8D >Job is changed via MC8E > deletion of job is done via MC8F.
    2. Planning job is created via MC8D > Job is changed via MC8E (Reset the job before re-execute the Job)
    Regards,
    Lok

  • Error when executing scenario use command prompt - startscen

    Hi All,
    Anyone know how to solve this error? I get this error message when I execute command prompt: startscen scenarioName version001 contextDevelopment "-v=2"
    The error message is:
    java.lang.NullPointerException
    at com.sunopsis.g.a.f.b(f.java)
    at com.sunopsis.tools.core.SnpsStringTools.a(SnpsStringTools.java)
    at com.sunopsis.dwg.DwgObject.snpsDecypher(DwgObject.java)
    at com.sunopsis.dwg.DwgJv.treatCmd(DwgJv.java)
    at com.sunopsis.dwg.DwgJv.main(DwgJv.java)
    at oracle.odi.Agent.main(Agent.java)
    I use JDK version 1.4.
    Thanks in advance.
    Regards,
    Sumardi

    Hi Sumardi,
    Trying to help you,
    Please cross check the repository configuration information in ODIPARAM.BAT file.
    Thanks,
    G

  • Command prompt from pl/sql

    hi,
    is there any way to execute command prompt statements (like IMP for example) from within pl/sql procedures.

    I didn't particularly want to have to start writing java utilities etc, just wanted to execute commands from within pl/sql. In sqlserver you can do this in transact-sql by running xp_cmdshell. I am trying to find ways of exporting table data and being able to reimport it on another machine or even different databases - so want a comma delimited file (preferably with a format file to go with it to identify what columns there are etc.
    Is this not possible then ?

  • How to get no. of rows of Windows Command Prompt in java

    hi all,
    can anybody tell me that is there any java utility avalilable throght I can find the how many rows avalilbe on currently executing command prompt, and also how can i clear the content of command prompt (result of 'cls' command).
    Currently execting command prompt means from where I have run my java program.
    any reference is also welcome.
    thanks in advance.

    Clearing the screen is trivial, as long as you're OK with making your program specific to Windows only (i.e. you never hope to run it on any other OS ever):
    Runtime.getRuntime().exec("cmd /c cls");As to figuring out how many lines your command window's screen buffer has - good luck with that. I'm not familiar enough with the Win32 API to get this info, but you'll have to figure out what that is, and call it via JNI.

  • Problem with executing java on command prompt

    Hi my program uses java mySQL connector to connect to a local host. The program works fine when i run through netbeans. But when i run through command prompt it gives in this error message
    java.lang.ClassNotFoundException:com.mysql.jdbc.Driver Can anyone help me to solve this problem

    add mysql.jar file to ur classpath, it will work fine.

  • Error during executing the tp command 'tp Connect DEV...

    Dear All,
       There is error when I SPAM support package SAPKB70010.(SAP ECC6.0)
       Info:
       Import phase 'CHECK_REQUIREMENTSS'
       \HOSTNAME\SAPMNT\trans\bin\TPPARAM
       Error during executing the tp command 'tp connect DEV...'
       TP return cod:'0208', tp message:'error in transportprofil (param missing,unknow..'tp output
       sapmnt\trans\bin\TPPARAM could not be opened.
      EXIT
      ERROR:
    System: Parameter SAPEVTPATH not set. Batch jobs cannot be started.
      Error in
    hostname\sapmnt\trans\bin\TPPARAM: transdir not set.
      tp return code Summary:
      TOOLS:Hightest return code of single steps was:0
      ERRORS: Highest tp internal error was:0208
    My environment:
    Win2003 X64
    Oracle 10.2
    SAP ECC 6.0  Basis 700  09
    Kernel patch num:254
    How to solve the issue?
    Thank you very much!

    Hi
    2 possible problems.
    1) tp is using the wrong profile
    2) the profile is not complete
    For 1, specify the profile when using the tp command e.g. tp connect dr1
    pf='/usr/sap/trans/DR1/bin/TPPARAM'
    For 2 you need to edit the TPPARAM file and insert the correct values e.g.
    DR1/sapevtpath = /usr/sap/$(system)/SYS/exe/run/sapevt or you can add
    it into the command line with the -D option
    At the command prompt enter 'tp connect' and the help file will be
    displayed for that command with the available options
    Cheers
    Nirav Kundaria

  • Test Execution hangs while executing a test from Command prompt option

    I have done the following
    1) Created a script Test driver
    2) Added different scripts as Script->Properties->Assets to the driver script
    3) Call each of this asset script from TestDriver using command getScript("<<ScrptName>>".run(1, true, true, true);
    4) Now calling this TestDriver script from command prompt with command
    e:\\OracleATS\\agent
    runScript.bat E:\\INTEGRATION_SERVICES\\Identity_management\\Automation\\Scripts\\MasterScripts\\TestDriver
    TestDriver.jwg
    The script execution hangs at "Initializing VU 1 for Script TestDriver. After few mintues of seeing this message i get error "Execution Timed Out".
    Do I need to keep openscript UI open for script execution from command line ?
    Is there any way to increase this Execution Time out ? May be it is taking time to load the internal script assets. AS other scripts are running fine on the same machine from command prompt itself.
    Complete error is as follows
    C:\Documents and Settings\oracle>e:\\OracleATS\\agent\\runScript.bat E:\\INTEGRATION_SERVICES\\Identity_management\\Automation\\Scripts\\MasterScripts\\TestDriv
    er\\TestDriver.jwg
    Running "TestDriver" ...
    Agent started. Available commands:
    stop - Stop the virtual user after it finishes the current iteration.
    abort - Abort the virtual user cleanly, before it finishes the current itera
    tion.
    exit - Terminate the process immediately
    You may type the above commands at any time.
    12:17:53,418 INFO [1] Initialized script service "oracle.oats.scripting.modules.utilities.api.UtilitiesService"
    12:17:53,418 INFO [1] Initialized script service "oracle.oats.scripting.modules.browser.api.BrowserService"
    12:17:53,418 INFO [1] Initialized script service "oracle.oats.scripting.modules.functionalTest.api.FunctionalTestService"
    12:17:53,465 INFO [1] Initialized script service "oracle.oats.scripting.modules.webdom.api.WebDomService"
    12:17:53,856 INFO [1] Initialized script service "oracle.oats.scripting.modules.datatable.api.DataTableService"
    12:17:53,856 INFO [1] Initializing VU 1 for script TestDriver
    Execution Timed Out.

    Hi e_raja_sekar,
    You wrote:
    public static void main(String args){should be
    public static void main(String args[]){Granted, the below code was tested on Windows XP using J2SE SDK 1.4.1_02 (and not 1.2.2 like Sridhar is using), but when I compiled and executed this code:
    public class BadMain {
      public static void main(String args) {
        System.out.println("Hello World");
    }The output I got was:
    Exception in thread "main" java.lang.NoSuchMethodError: mainSo I don't think this is Sridhar's problem (but I could be wrong) since he says that he gets no error message.
    Cheers,
    Avi.

  • Executing multiple command lines in command prompt (windows)

    Hi,
    I am currrently using the command prompt in the windows to try to send a command to the microcontroller that is connected through TCP connection.
    I am able to use the normal cmd.exe to send the command but am unable to send all the command successfully using labview. 
    The Vi. that I am using the the system exec.vi found in labview connectivity section. 
    Basically what I want to send is "telnet A1" in the cmd.exe to establish connection to the microcontroller, followed by "FOR A1 100 GO" which will be intepreted by the microcontroller to make the necessary motion. But currently, the problem is that I can only establish connection using the system exec.vi but am unable to send the second part of the message "FOR A1 100 GO". 
    My command line i tried typing is cme.exe /K telnet A1 & FOR A1 100 GO. it seems that labview is only able to execute the first command part. Is there any other alternatives? 
    Thanks everyone for your help. 
    Solved!
    Go to Solution.

    Hi,
    Thanks for the help, the picture shows 1 of the error which state Error 56, the error occurs occasionally whenever I have used the command prompt to send a message to the microcontroller.
    Alternatively, there are times when no errors occur but my microcontroller does not move as well. It does move if I were to send the command through the cmd prompt.
    And I have attached a picture of my program as well. I am currently using Labview 2010 32bit. Thanks.
    Jh
    Attachments:
    TCP Connection.jpg ‏170 KB
    Error56.png ‏222 KB
    Picomotor_App New v3.0.vi ‏38 KB

  • Hiding the command prompt when executing bat file

    Hi,
    I hava a bat file which contains following
    java -jar MyJar.jar
    When I execute the bat file, the jar file is executed. But a command prompt also opens along with it. I dont want to display the command prompt to the user. Is there any way to hide that command prompt ?
    regards,
    Jatin.

    Is your problem solved?
    If not then
    insted of creating a batch file create a form file in visual basic and write following code in it
    shell "java -jar MyJar.jar"
    Endand then create its exe file.
    It will just launch your jar file and then exit.

  • Invoking command prompt & executing a java class from one more java class

    Hi,
    I have a problem with my application. I need to develop an editor which compiles and interpretes java programmes. I am develoopping it in Java (Swing and pure Java). I have no problem in compiling a java programme from my editor. But while execuing if any body writes a programme which has console input the system hangs. I am using Runtime.exec() method to call command prompt of Win'2000. My editor is working fine for the programmes written without console input in my editor. I want the same type of input acceptance as JCreator / Vim editors accept.
    How can i achieve this? Please give me some source code help for my requirement.

    When you create a Process object from executing a command you can grab it's input and output streams. Using these, and a text area, you can create a "virtual terminal" for your user to work with their console programs. The rest is just details :)

  • How to execute a scenario from Windows command prompt

    Hi,
    I have a package which is executing fine from Designer. But the same scenario if I am trying to execute from windows command prompt, then it is giving error.
    The package is getting a refresh variable, passing to interface which is creating a file from table, this file is then getting FTP'ed to another server.
    I am executing following command -
    startscen OB_TAB_TO_FILE_PKG 001 ODICTX "-v=2"
    The error is -
    A JDK is required to execute Web Services with OracleDI. You are currently using
    a JRE.
    OracleDI: Starting scenario OB_TAB_TO_FILE_PKG 001 in context ODICTX ...
    java.sql.SQLException: socket creation error
    at org.hsqldb.jdbc.jdbcUtil.sqlException(jdbcUtil.java:67)
    at org.hsqldb.jdbc.jdbcConnection.<init>(jdbcConnection.java:2451)
    at org.hsqldb.jdbcDriver.getConnection(jdbcDriver.java:188)
    at org.hsqldb.jdbcDriver.connect(jdbcDriver.java:166)
    at com.sunopsis.sql.SnpsConnection.u(SnpsConnection.java)
    at com.sunopsis.sql.SnpsConnection.c(SnpsConnection.java)
    at com.sunopsis.sql.i.run(i.java)
    DwgJv.main: Exit. Return code:-1
    Please let me know where I am going anything wrong.
    Thanks,
    Himanshu

    Hi,
    you need to make the necessary changes to the %odi%\bin\odiparams.bat config file, under the "Repository Connection Information" section so that startscen knows how to extract metadata from your repository.
    You apparently have left the default settings to the Hypersonic demo repository. Is that the technology your repository is hosted on?

  • Error while executing ODI scenario from command prompt

    Hi all,
    I am trying to execute a scenario of a package( that I have created in designer) in OS command prompt in Windows in the following way-
    C:\ODIHOME\oracledi\bin>Startscen DIM_TECHNOLOGY_PACKAGE 001 Global LEVEL5
    However I am getting the following message:-
    OracleDI: Starting scenario DIM_TECHNOLOGY_PACKAGE 001 in context Global ...
    com.sunopsis.core.SnpsInexistantObjectException: SnpScen.getScenarioByCodeAndVer
    sion ; SnpScen does not exist
    at com.sunopsis.dwg.dbobj.SnpScen.getScenarionByCodeAndVersion(SnpScen.j
    ava)
    at com.sunopsis.dwg.cmd.DwgCommandScenario.b(DwgCommandScenario.java)
    at com.sunopsis.dwg.cmd.DwgCommandScenario.treatCommand(DwgCommandScenar
    io.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.prepare(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.t(e.java)
    at com.sunopsis.dwg.cmd.e.y(e.java)
    at com.sunopsis.dwg.DwgJv.treatCmd(DwgJv.java)
    at com.sunopsis.dwg.DwgJv.main(DwgJv.java)
    at oracle.odi.Agent.main(Agent.java)
    com.sunopsis.core.SnpsInexistantObjectException: SnpScen.getScenarioByCodeAndVer
    sion ; SnpScen does not exist
    at com.sunopsis.dwg.dbobj.SnpScen.getScenarionByCodeAndVersion(SnpScen.j
    ava)
    at com.sunopsis.dwg.cmd.DwgCommandScenario.b(DwgCommandScenario.java)
    at com.sunopsis.dwg.cmd.DwgCommandScenario.treatCommand(DwgCommandScenar
    io.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.prepare(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.t(e.java)
    at com.sunopsis.dwg.cmd.e.y(e.java)
    at com.sunopsis.dwg.DwgJv.treatCmd(DwgJv.java)
    at com.sunopsis.dwg.DwgJv.main(DwgJv.java)
    at oracle.odi.Agent.main(Agent.java)
    Please tell me what can be the possible reason?
    Thanks in advance
    PB

    Hi PB ,
    Use the following syntax
    C:\ODIHOME\oracledi\bin>startscen DIM_TECHNOLOGY_PACKAGE 001 <CONTEXT_CODE> "-v=5"
    Also make sure that the repository connection details are all correct before running scenario via startscen script
    Thanks,
    Sutirtha
    Edited by: Sutirtha Roy on May 14, 2010 12:18 PM

Maybe you are looking for

  • Is this possible - I have 10hrs of video but each DVD only needs about 10min

    I did a 10 hour dance event and I need to make custom DVD's for each customer that usually only include 3 or 4 songs. Each DVD is different. I don't need the whole 10 hours. Will Encore lay down just the video I need or will I have to cut away all of

  • Premiere Pro CC Cutting off frames and shifting audio from .MOV

    Hi everyone! I recently converted from Premiere Pro CS6 to CC. I've noticed an incredibly frustrating problem that I can't diagnose. In CS6 my Quicktime files would come in just fine, with correct audio lining up. However in Premiere Pro CC, the firs

  • Problem downgrading nvidia

    Hi, I want to use nvidia-177 drivers but somehow the installer can't find the prebuild kernel PKGBUILD pkgname=nvidia-test pkgver=177.82 pkgrel=1 pkgdesc="NVIDIA beta drivers for kernel26." arch=('i686' 'x86_64') _kernver=`uname -r` [ "$CARCH" = "i68

  • No xServe system activity lights in 10.8 Server

    Hi there, i have installed Mountain Lion Server on my xserve and everything is fine but the "System activity lights" do not come to live at boottime as the did in Lion server. I know they need a kext because by the time i was installing 10.7 server t

  • Udf for CollapseContext

    Hi all, I need to write a UDF for CollapseContext. Has anybody coding for that. Thanx in advance, Thomas