How to launch a DOS command with process

When I tried to create a process which launch a DOS command, I have a big exception with CreateProcess error=2.
I just would like to make a "cd directory"
Please help!!!

Go back to the API documentation and look for the version of Runtime.exec() that allows you to specify the working directory. Even if you could run a task that executed "cd something" that would be pointless, since it would only change the current directory of that task.

Similar Messages

  • How to execute a system command with call executable in teststand 4.2.1?

    Hi All,
          how to execute a system command with "call executable" step in teststand 4.2.1?
          example as i want to quit a application.using "taskkill /f /im xxx.exe".And execute other system command(DOS).
    BR
    Johnny

    Hi, 
    I want to run netstat -an | find "8080" command from command prompt using call executable in test stand. after that i would like take the std output to local variable. 
    Attachments:
    callsettings.jpg ‏404 KB

  • How to execute dir dos command in Runtime Execution

    Hi All,
    Does anybody know how to execute the dir command in DOS in the runtime execution
    for example,
    when we open the command prompt,
    c:\Documents and Settings\java> e:
    e:\cd java
    e:\dir *.*
    how we can list the directory in runtime execution?

    Process childProcess = Runtime.getRuntime().exec("cmd /C dir *.*");or try with
    ProcessBuilder pb = new ProcessBuilder("cmd /C dir *.*");
    Process childProcess = pb.start();
    NOTE: We can use the ProcessBuilder class from J2SE 5.0+.
    for further reference check the below link
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=3
    and don't forget to go through API documentation for java.lang package
    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/package-summary.html
    and if you want to implement it through Java which provides you a list of Files & directories in the present directory here is an example of such code snippet REF:as insisted by my fellow poster.
    File file = new File("<present_directory_path>");
    if(file.isDirectory()){
       String fileNames[] = file.list();
            for(String fileName:fileNames)
               System.out.println(fileName);
      fileNames = null;
            or for detailed info use
             File files[] = file.listFiles();
             for(File fileEntity:files)
                System.out.println("FILENAME:"+fileEntity.getName+",IS FOLDER:"+fileEntity.isFolder()+",ABSOLUTE PATH:"+fileEntity.toString()+"FILE SIZE:"+fileEntity.length());
             files = null;
    }and please do not forget to go through File API Documentation provided as recommended by my fellow poster.
    hope this might help :)
    REGARDS,
    RaHuL

  • How to run a DOS command from an Oracle form.

    How can I run a DOS command from an Oracle form (i.e. open the calculator located at c:\windows\system32\calc.exe)?

    first of all get the environment variable for the c:\windows\system32 direcotry for any of the windows
    you can use get variable from the ora env package
    now cancat the system32 variable with the calc.exe string
    now pass the string with host command as parameters
    this process will work for all type of windows.

  • How to run multiple DOS commands from a single Webutil Client_Host session?

    Hello all,
    I have a requirement where I need to create an interface with SVN from Forms for basic checkin-checkout of files.
    So, I've been trying to use webutil client_host to open a command line session and issue svn commands.
    For svn, sometimes I need to give multiple commands like change to a particular directory and then run an svn command.
    But client_host takes in only one command at a time and I'm unable to issue a series of DOS commands to perform
    a particular task.
    Is there a way to do this?
    Pls suggest.
    Regards,
    Sam

    First your original question... You can put more than one DOS command on a single line, simply separate each command with an ampersand (&). For example:
    mkdir c:\abc & cd abc & dir*
    Regarding your concerns about performance, well that would depend on exactly what you mean. Using CLIENT_HOST (or HOST on the server) simply opens a shell (DOS in this case) then passes your command to it. The performance of performing this action really isn't measurable. Basically you are just pressing a button and you should get a near immediate action. As for the performance of executing each command, that has nothing to do with Forms. Once the command is passed to the shell, the rest is a function of the shell and whatever command you passed.
    Having said that, if you were to write something sloppy like a loop (in pl/sql) which called CLIENT_HOST lots of times repeatedly, then yes there would be a performance problem because the pushing of the button will cause an exchange to and from the server and each cycle in the loop will do the same.
    So the answer to how performance is impacted will depend on what exactly you need to accomplish. If it is a single call to CLIENT_HOST, this should be fine.

  • How to execute MS DOS command through Java program???

    Dear Sir,
    I want to run a MS-DOS command through my Java program. I have tried "Dir" command but no other command which takes command line args doesn't work at all. Please help.
    import java.io.*;
    class CommandPrompt
         public static void main(String[] args)
              try
                   File file = new File("C:/Temp/Java");
                   String[] cmd = {"command.com","/c","md folder"};
                   String[] envp = {""};
                   Process m;
                   String s = "";
                   m = Runtime.getRuntime().exec(cmd,null,file);
                   BufferedReader buf = new BufferedReader(new InputStreamReader(m.getInputStream()));
                   while ((s = buf.readLine())!=null)
                        System.out.println(s);
              catch (Exception ex)
                   System.out.println("Exception is "+ex);
                   ex.printStackTrace();

    1. This forum is for Swing-related issues only. This question should be posted to the "Java Programming" forum.
    2. Please enclose your sample code in code blocks; it's much easier to read that way. See here for how it's done: http://forum.java.sun.com/faq.jsp#messageformat
    3. Please provide more information, like what error messages you got and what OS you're running. For instance, if you're running WinXP, Win2k or NT4, your command processor should be "cmd.exe", not "command.com". When I made that change, your program worked for me.

  • EXECUTE DOS COMMANDS WITH JAVA

    I'm new to java and I want to execute dos commands by java
    can someone help me by by anyway?
    like tell me the packages or methods I need
    or give me links to sites?
    thanks

    No Arguments:
    try {
            // Execute a command without arguments
            String command = "ls";
            Process child = Runtime.getRuntime().exec(command);
            // Execute a command with an argument
            command = "ls /tmp";
            child = Runtime.getRuntime().exec(command);
        } catch (IOException e) {
        }With Arguments:
    try {
            // Execute a command with an argument that contains a space
            String[] commands = new String[]{"grep", "hello world", "/tmp/f.txt"};
            commands = new String[]{"grep", "hello world", "c:\\Documents and Settings\\f.txt"};
            Process child = Runtime.getRuntime().exec(commands);
        } catch (IOException e) {
        }

  • How can you run a command with elevated rights on a remote server with invoke-command ?

    I am trying to run a script on a remote server with invoke-command.  The script is starting and is running fine, but the problem is that it should be running with elevated rights on the remote server.  On the server where I start the invoke-command, my account has the necessary rights.
    The server were I launch the invoke-command is a W2K8 R2.  The remote box is a W2K3 with powershell v2.0 installed.
    When I launch the script on the remote-box from the command line, I don't get the access denied's.
    Is there a way to do this ?
    Thanks in advance

    The script that I want to run is to install the windows updates.  I get an access denied on the download of the updates.
    When I execute the script on an W2K8 box, (not remotely) and I run it with non-elevated rights, I get the same error.
    The script is running fine when it is launched on W2K3 box locally with a domain account that has local admin rights, or on a W2K8 R2 server with a domain account that has local admin rights, but with elevated rights.
    Thanks in advance for your help.
    #=== start script ====
    param($installOption="TESTINSTALL",$rebootOption="NOREBOOT")
    Function Show-Help
    Write-Host ""
    Write-Host "SCRIPT: $scriptName <installOption> <RebootOption>"
    Write-Host ""
    Write-Host "DESCRIPTION: Installatie van WSUS updates op de lokale server"
    Write-Host ""
    Write-Host "PARAMETERS"
    Write-Host " -installOption <[INSTALL|TESTINSTALL]>"
    Write-Host " -rebootOption <[REBOOT|NOREBOOT|REBOOT_IF_UPDATED]>"
    Write-Host ""
    Write-Host "EXAMPLE:"
    Write-Host "$ScriptName -installOption INSTALL -rebootOption REBOOT_IF_UPDATED"
    Write-Host "$ScriptNAme INSTALL NOREBOOT"
    Write-Host ""
    Write-Host "Indien beide parameter weggelaten worden zijn de defaultwaarden :"
    Write-Host " installOption=TESTINSTALL "
    Write-Host " RebootOption=NOREBOOT"
    Write-Host ""
    Exit
    #Include alle globale variablen
    $CEIF_WIN_PATH = (get-content env:CEIF_WIN_PATH)
    $includeFile=$CEIF_WIN_PATH + "\Scripts\include_win.ps1"
    . $includeFile
    #initialiseer error count
    $errcnt=0
    $scriptName=$MyInvocation.MyCommand.Name
    #argumenten controleren
    $arrInstallOption= "TESTINSTALL", "INSTALL" # Mandatory variable with predefined values
    If (!($arrInstallOption –contains $installOption)){ Show-Help }
    $arrRebootOption = "REBOOT", "NOREBOOT","REBOOT_IF_UPDATED" # Mandatory variable with predefined values
    If (!($arrRebootOption –contains $rebootOption)){ Show-Help }
    #Logfile opbouwen
    $logfile = get-logfileName($MyInvocation.MyCommand.Name)
    Log-scriptStart $MyInvocation.MyCommand.Name $logfile
    function Get-WIAStatusValue($value)
    switch -exact ($value)
    0 {"NotStarted"}
    1 {"InProgress"}
    2 {"Succeeded"}
    3 {"SucceededWithErrors"}
    4 {"Failed"}
    5 {"Aborted"}
    function boot-server()
    if ($installOption -eq "TESTINSTALL")
    logger "TESTINSTALL : - Reboot local Server" $logfile
    else
    logger " - Reboot local Server" $logfile
    $thisServer = gwmi win32_operatingsystem
    $thisServer.psbase.Scope.Options.EnablePrivileges = $true
    $thisServer.Reboot()
    $logmsg="Install option = " + $installOption + ", RebootOption = $rebootOption"
    logger "$logmsg" $logfile
    logger "" $logfile
    logger " - Creating WU COM object" $logfile
    $UpdateSession = New-Object -ComObject Microsoft.Update.Session
    $UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
    logger " - Searching for Updates" $logfile
    $SearchResult = $UpdateSearcher.Search("IsAssigned=1 and IsHidden=0 and IsInstalled=0")
    logger " - Found [$($SearchResult.Updates.count)] Updates to Download and install" $logfile
    $Updates=$($SearchResult.Updates.count)
    logger "" $logfile
    foreach($Update in $SearchResult.Updates)
    if ($Update.EulaAccepted -eq 0)
    $Update.AcceptEula()
    # Add Update to Collection
    $UpdatesCollection = New-Object -ComObject Microsoft.Update.UpdateColl
    $UpdatesCollection.Add($Update) | out-null
    if ($installOption -eq "TESTINSTALL")
    else
    # Download
    logger " + Downloading Update $($Update.Title)" $logfile
    $UpdatesDownloader = $UpdateSession.CreateUpdateDownloader()
    $UpdatesDownloader.Updates = $UpdatesCollection
    $DownloadResult = $UpdatesDownloader.Download()
    $Message = " - Download {0}" -f (Get-WIAStatusValue $DownloadResult.ResultCode)
    if ($DownloadResult.ResultCode -eq 4 )
    { $errcnt = 1 }
    logger $message $logfile
    # Install
    logger " - Installing Update" $logfile
    $UpdatesInstaller = $UpdateSession.CreateUpdateInstaller()
    $UpdatesInstaller.Updates = $UpdatesCollection
    $InstallResult = $UpdatesInstaller.Install()
    $Message = " - Install {0}" -f (Get-WIAStatusValue $InstallResult.ResultCode)
    if ($InstallResult.ResultCode -eq 4 )
    { $errcnt = 1 }
    logger $message $logfile
    logger "" $logfile
    #Indien er een fout gebeurde tijdens download/installatie -> stuur mail naar windowsteam
    if ( $errcnt -gt 0 )
    logger " - Fout tijdens de uitvoering van script -> send mail" $logfile
    $mailSubject=$MyInvocation.MyCommand.Name
    $msg = new-object Net.Mail.MailMessage
    $att = new-object Net.Mail.Attachment($logfile)
    $smtp = new-object Net.Mail.SmtpClient($smtpServer)
    $msg.From = $mailFrom
    $msg.To.Add($mailTo)
    $msg.Subject = $mailSubject
    $msg.Body = “Meer details in attachement”
    $msg.Attachments.Add($att)
    $smtp.Send($msg)
    #Moet de server herstart worden ?
    if ($rebootOption -eq "REBOOT_IF_UPDATED" )
    if ($Updates -gt 0)
    #Reboot the server when updates are installed
    boot-server
    elseif ($rebootOption -eq "REBOOT")
    #reboot the server always
    boot-server
    else
    #Do not reboot the server
    logger "Do not reboot the server" $logfile
    Log-scriptEnd $MyInvocation.MyCommand.Name $logfile
    exit 0

  • HOW DO I RUN DOS COMMANDS ON JAVA

    I SWEAR, I'LL PAY YA IF YOU HELP ME!!!
    Hi, this is the thing:
    have you ever run the "time" command on a DOS console?? if you have, you know that it shows the current time, and lets you set a new time.
    well, i need to make a java program to open a DOS console and execute the command, and making it able to write in information on the console so it sets a new time.
    MY PURPOSE IS NOT JUST WATCHING THE CURRENT TIME!! so please don't tell me to use System.getCurrentTimeMillis() or something like that; i explicitly need to run that DOS command. what's the Java code to do it??
    thank you!! and please attach your account # so you get a $50 deposit by the end of the week
    thank you!!

    Thanks a lot, you all guys, but i don't know what's with this thing.... it always throws an IOException, with the following exception stack trace:
    java.io.IOException: CreateProcess: temp.bat error=0
            at java.lang.Win32Process.create(Native Method)
            at java.lang.Win32Process.<init>(Win32Process.java:63)
            at java.lang.Runtime.execInternal(Native Method)
            at java.lang.Runtime.exec(Runtime.java:550)
            at java.lang.Runtime.exec(Runtime.java:416)
            at java.lang.Runtime.exec(Runtime.java:358)
            at java.lang.Runtime.exec(Runtime.java:322)
            at Tarea.main(Tarea.java:15)and it will come out the same shit over and over. The above case was thrown by the line Runtime.getRuntime().exec("temp.bat") where temp.bat is a file where the only thing written in it is the word "time". and you can change the string parameter of the method exec, and thats what will change in the stack trace above.
    I also tried "cmd", "command", and "command.com". With the last one, it opens the command.com application but it freezes and does nothing. With the other two, appears the same old shit from above.
    Please help me!!
    Thank you...

  • Problem in Execution of DOS Commands with JAVA.

    I am trying to execute DOS Commands and FTP commands using Java Programming Language and Trying to get the output for further processing.Actually I want the exact output what DOS and FTP give after execution of a their corresponding commands.

    Process p = new Process("dir");
    InputStream is = p.getInputStream();

  • At CRS-1,how can i use show command with pipe | ?

    HI,ALL
    when I use show command with pipe on the CRS-1,the command invalid
    RP/0/RP0/CPU0:JA-DL-CR-1.MAN.CRS-1#show interfaces | include line |errors 
                                                                       ^
    % Invalid input detected at '^' marker.
    ========================================================
    But Previously on the cisco 7609,I can use the show command
    GZ-DM-SR-1.MAN.7609#show int | include line |err
    Vlan1 is down, line protocol is down
         0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
         0 packets output, 0 bytes, 0 underruns
         0 output errors, 0 interface resets
    Vlan11 is administratively down, line protocol is down
         0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
         0 packets output, 0 bytes, 0 underruns
         0 output errors, 0 interface resets
    Vlan99 is down, line protocol is down
         0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
         0 packets output, 0 bytes, 0 underruns
         0 output errors, 0 interface resets

    RP/0/RP0/CPU0:JA-DL-CR-1.MAN.CRS-1#show interfaces | include line |errors 
                                                                       ^
    % Invalid input detected at '^' marker.
    RP/0/RP0/CPU0:JA-DL-CR-1.MAN.CRS-1#show interfaces | include line |?    

    RP/0/RP0/CPU0:JA-DL-CR-1.MAN.CRS-1#show interfaces | include line | |?
                                                                        ^
    % Invalid input detected at '^' marker.
    RP/0/RP0/CPU0:JA-DL-CR-1.MAN.CRS-1#show interfaces | include line | ?
      begin    Begin with the line that matches
      exclude  Exclude lines that match
      file     Save the configuration
      include  Include lines that match
      utility  A set of common unix utilities
      <cr>    
    RP/0/RP0/CPU0:JA-DL-CR-1.MAN.CRS-1#show interfaces | include line |
    % Incomplete command.
    RP/0/RP0/CPU0:JA-DL-CR-1.MAN.CRS-1#show interfaces | include line |errors
                                                                       ^
    % Invalid input detected at '^' marker.
    RP/0/RP0/CPU0:JA-DL-CR-1.MAN.CRS-1#                                     
    RP/0/RP0/CPU0:JA-DL-CR-1.MAN.CRS-1#show interfaces | include line | ?   
      begin    Begin with the line that matches
      exclude  Exclude lines that match
      file     Save the configuration
      include  Include lines that match
      utility  A set of common unix utilities
      <cr>    
    RP/0/RP0/CPU0:JA-DL-CR-1.MAN.CRS-1#show interfaces | include line |?

    RP/0/RP0/CPU0:JA-DL-CR-1.MAN.CRS-1#show interfaces | include line | include er$
    Thu Jan 15 22:36:24.120 GMT
    RP/0/RP0/CPU0:JA-DL-CR-1.MAN.CRS-1#
    RP/0/RP0/CPU0:JA-DL-CR-1.MAN.CRS-1#show interfaces | include line           
    Thu Jan 15 22:37:05.013 GMT
    Loopback0 is up, line protocol is up
    Loopback1 is up, line protocol is up
    Loopback6 is up, line protocol is up
    Null0 is up, line protocol is up
    POS0/0/0/0 is up, line protocol is up  (APS not Configured )
    POS0/0/1/0 is up, line protocol is up  (APS not Configured )
    TenGigE0/0/4/0 is up, line protocol is up

  • How to sync TCP/IP command with data

    Hello. I am trying to catch a TCP/PI data and write it to the file. I am using the TCP Communicator example as the base. My goal is to send a command and write to the file the response from the host. Few challenges. I can send multiple commands, but I only want to write to file after specific one and only once. It is the reason I have some logic in the send loop to enable write block. My problem is, by the time data comes, my enable changes value, so I only write the data that was on the bus from previous command. Or, I keep witing to file ove r and over.
    What is the best way to sync send a command and wait for the result for this command? Should I just use case structure since I do not need to listen host all the time, only after I sent  commands.
    Labview 8.2
    Win7
    Thank you
    Attachments:
    TCPIP.PNG ‏71 KB

    Do you have control over the data on both ends of the connection? If so, create a simple messaging protocol that will help you keep things in sync and give you the ability to recognize the commands. The simplest protocol would be to define your data packets to contain a message header and data. The message header would contain a message identifier identifier and the message data length. The header should be fixed length. This allows you to easily read the header and the data. The data will be whatever you need for each message type. The header message length will let you know how much data to read. Using this simple protocol the message reading would be very simple. Since each message will contain an identifier you can easily chose how to process the message and what actions you take. If you need to match responses with specific commands you could put a command sequence number in the message header. This would allow you to match the response with the specific command. You would need to include the command sequence number in the response.
    If you don't have control over the other side of the connection you will need to get the message format the device uses. That will dictate how to process the messages.
    Also, if your system is always a command/response system you do not have to have the read and write in separate tasks. You can send the command and wait for the response immediately afterward. You would not send the next command until you get a reposes. If you know you won't get a response for a specific command you would skip the read.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • How to Launch a "setup.exe" with LabVIEW app? No luck with System Exec.vi

    I've got an application that I'm trying to update with a separate LabVIEW application (the "Updater"). It's the "Check for Updates" capability you see on other major apps.
    Here's the glitch: When the Updater tries to launch "setup.exe" using "System Exec.vi", The installer seems to catch the attempt and pops a dialog titled "Windws XP Setup" saying "Please go to the Control Panel to install and configure system components".  The install does not begin and the installer closes (if it was ever open!).
    Running the same installer by double-clicking the "setup.exe" file from windows runs just fine.
    Here's the question: "How can a LabView app launch an installer?" 

    Could you show the code.
    Look at the path where you want to run the code.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • How do I use voice commands with CC on my Mac?

    Howdy all! Just made the switch to Adobe from Final Cut 7. Overall, I'm digging it a bunch.
    However, there's one aspect of CC on my Mac that's vexing me.
    As you may know, there is speech recognition / voice command software built in to Mountain Lion (it's been around for years, and many iterations of OSX). With this software, you can make any number of custom voice commands for another piece of software. For instance, in FCP 7, I can program the keystroke "l" (play track) to respond to the voice command, "Forward." (It can be any word or phrase you type in.) This works with other programs as well.
    All well and good, and pretty dang cool. However, I can't make any voice commands work with any of the CC software (I've tried Premiere and Media Encoder so far). I'm curious if anyone else has had any luck, or, perhaps, that the ported interface from Windows to Mac has some layer of code that (probably inadvertantly) blocks voice commands from working with CC on a Mac.
    Anyone got any tips? Tricks? Confirmation that this simply won't work on a Mac? (If the last, I'd love to know the "why" as well.)
    Thanks!
    Best,
    Ian
    2009 Macbook Pro, 2.8Ghz Intel Core 2 Duo, 8GB 1067 MHz DDR3 Ram, 1TB 5400 RPM hard drive, OSX 10.8.4.

    There are none.
    iPad has dictation only-no commands.

  • Calling a DOS command with LabVIEW

    Is it possible to run commands that you might execute on the DOS prompt from
    labview?
    -- Stephen

    Well at least you did a search- the thread you replied to is 7yrs old! please start a new thread
    Jeff

Maybe you are looking for

  • Alarm clock not working in iOS 7 with multiple alarms set.

    I usually have two alarms set on my phone, both using the stock clock app.  One about an hour before I need to get up (so I can turn the heater on and crawl back under the covers), the other for the time I am supposed to get up.  The second alarm wor

  • My consoleone is no longer working with groupwise

    Hello Somehow I screwed up my consoleone. It is GroupWise 7.0.3 and running on SUSE Linux 10.1 . Now when I select domain, the domain databases come up but none of the GroupWise options are available and it is just showing the standard consoleone inf

  • Migrating from RAS9 to Crystal Reports Server XI R2

    We are currently in the process of migrating to CRS XI R2 from RAS9 and have come across an error thrown by some reports that we have been unable to find an answer to. We receive this error... <blockquote>ErrorLog 2008 10  8  8:53:31.284 3092 5816 (\

  • How to escape XML in BPEL?

    I have a part of a outputmessage in an element HTML of xsd:any. This element contains HTML which i have to transform to escaped XML. Therefore i created the following embedded java code. String htmlContent = ((oracle.xml.parser.v2.XMLElement)getVaria

  • What Happened? Imovie used to play .mpg with audio.

    I have a new Imac 27in. The firsst few days after opening it. I hooked up my panasonic video camera, and uploaded and edited several videos, in .mpg. Now i cannot even get Imoive to recognize a .mpg. I can get quicktime to play the video but without