Run a .exe file with parameters from my java code

Hi, I want to run a .exe file from my java program. This .exe file will take some parameters in the command line. I need
to supply that to the program as well. Can someone help me in this please?
Thanks in advance.

I am trying like this:
public class lauch_ext {
     public static void main(String[] args) throws Exception{
          try {
            Runtime rt = Runtime.getRuntime();
            Process pr = rt.exec("C:\\Apps\\myapp.exe arg1 -arg2 return_arg");
            BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
            String line=null;
            while((line=input.readLine()) != null) {
                System.out.println(line);
            int exitVal = pr.waitFor();
            System.out.println("Exited with error code "+exitVal);
        } catch(Exception e) {
            System.out.println(e.toString());
            e.printStackTrace();
}

Similar Messages

  • PL/SQL to execute exe file with parameters from DB

    Hi all,
    I have a bit of a problem.
    I am in need to write all Logon, Logoff and Logon fail data onto the Windows Application Log. To do this I already tried various solutions but with my configuration (Oracle EE 10.2.0.4 and Windows Server 2003 R2 X64) the only possible solution (apparently) is the following.
    I create a Table with the info I need:
    CREATE TABLE logonaudittable
    event VARCHAR2(15),
    sid NUMBER,
    serial# NUMBER,
    orario DATE,
    username VARCHAR2(30),
    osuserid VARCHAR2(30),
    machinename VARCHAR2(64)
    I create a trigger for Logon Data, one for Logoff and one for Logon Fail:
    LOGON trigger.
    CREATE OR REPLACE TRIGGER logonauditing AFTER LOGON ON database
    DECLARE
    machinename VARCHAR2(64);
    osuserid VARCHAR2(30);
    v_sid NUMBER(10);
    v_serial NUMBER(10);
    CURSOR c1 IS
    SELECT sid, serial#, osuser, machine
    FROM v$session WHERE audsid = userenv('sessionid');
    BEGIN
    OPEN c1;
    FETCH c1 INTO v_sid, v_serial, osuserid, machinename;
    INSERT INTO logonaudittable VALUES ( 'LOGON', v_sid, v_serial, sysdate,
    user, osuserid, machinename );
    CLOSE c1;
    END;
    LOGOFF trigger
    CREATE OR REPLACE TRIGGER logoffauditing
    BEFORE LOGOFF ON database
    DECLARE
    machinename VARCHAR2(64);
    osuserid VARCHAR2(30);
    v_sid NUMBER(10);
    v_serial NUMBER(10);
    CURSOR c1 IS
    SELECT sid, serial#, osuser, machine
    FROM v$session WHERE audsid = userenv('sessionid');
    BEGIN
    OPEN c1;
    FETCH c1 INTO v_sid, v_serial, osuserid, machinename;
    INSERT INTO logonaudittable VALUES ( 'LOGOFF', v_sid, v_serial, sysdate,
    user, osuserid, machinename );
    CLOSE c1;
    END;
    LOGON FAIL trigger
    CREATE OR REPLACE TRIGGER logonfailauditing
    AFTER SERVERERROR ON database
    DECLARE
    machinename VARCHAR2(64);
    osuserid VARCHAR2(30);
    v_sid NUMBER(10);
    v_serial NUMBER(10);
    CURSOR c1 IS
    SELECT sid, serial#, osuser, machine
    FROM v$session WHERE audsid = userenv('sessionid');
    BEGIN
    IF (IS_SERVERERROR(1017)) THEN
    OPEN c1;
    FETCH c1 INTO v_sid, v_serial, osuserid, machinename;
    INSERT INTO logonaudittable VALUES ( 'FAILLOGON', v_sid, v_serial, sysdate,
    user, osuserid, machinename );
    CLOSE c1;
    END IF;
    END;
    The I create a trigger that starts every time something is written on the table.
    This trigger needs to start an EXE file that writes the latest data written on the table into the Windows Application Log.
    So I need a trigger that executes my WRITELOG.EXE file adding the parameters. For example:
    Execute WRITELOG.EXE event sid orario username
    So my program will write a Log in Windows with this data:
    Event: LOGON
    Sid: 2938473
    Orario: 12/12/2011 11:45:32
    Username: Scott
    And so on.
    I already have the program that does this, I need to execute the program with the right data directly from trigger or from a procedure executed by my trigger.
    Hope I've been clear and REALLY hope someone can help me!!!
    Thank you all!

    The java and PL/SQL you need to set up is in the very first response in the link. (I don't have a windows Oracle DB DBMS_JAVA to try it myself). Change the UNIX command '/usr/bin/ls' to your Windows command 'c:\yourdirectory\FILE.EXE'. Assuming you created everything and set permissions as Tom describes (later in the thread), your PL/SQL call in your trigger might look something like this:
    CREATE OR REPLACE TRIGGER logonauditing AFTER LOGON ON database
    DECLARE
    machinename VARCHAR2(64);
    osuserid VARCHAR2(30);
    v_sid NUMBER(10);
    v_serial NUMBER(10);
    CURSOR c1 IS
    SELECT sid, serial#, osuser, machine
    FROM v$session WHERE audsid = userenv('sessionid');
    BEGIN
    OPEN c1;
    FETCH c1 INTO v_sid, v_serial, osuserid, machinename;
    INSERT INTO logonaudittable VALUES ( 'LOGON', v_sid, v_serial, sysdate,
    user, osuserid, machinename );
    RUN_CMD('c:\yourdirectory\FILE.EXE LOGON '||v_sid||' '||v_serial||' '||to_char(sysdate,'MM/DD/YYYY')||' '||user||' '||osuserid||' '||machinename);
    CLOSE c1;
    END;
    Since you want to log what the trigger is writing to the table, you can call the executable with the same information you are writing, instead of writing then reading it back out again.

  • Execute .exe File With Arguments From CaptiveRuntime Air Application

    Hello,
    We have an AIR application compiled as a Captive Runtime app. We need to launch a Native Process (an exe file) on application startup and pass some arguments to that exe. Are there any examples on how to do this? Any resources we can look at for guidence?
    Thanks!

    Hi,
    You need to use Integration technology like BlazeDS or LCDS.

  • Facing problem with running exe from my java code

    Hello,
    I have to run the exe from java code for which I m using Runtime and Process classes. The exe runs in the following way on command line
    C:/ myexe -j [now press enter]
    input sentence followed by ! [now press enter]
    And after this exe gives the output.
    So is there any way to achieve this programmatically in Java?
    Thanks in advance.
    Regards,

    I m confused .. how can i pass input to the Process through InputStream? I think it will need OutputStream for that.
    Here is my code...
    import java.io.*;
    class CallToExe
    static BufferedReader br;
    public static void main(String[] args)
    File F = new File("C:/Chasen.exe");
    try
    if( F.exists())
         System.out.println("Exe exists");
         Runtime rt = Runtime.getRuntime();
         Process proc = rt.exec("C:/chasen.exe");
         br = new BufferedReader(new InputStreamReader(in));
         int a = in.read();
         System.out.println(a);
         String res = br.readLine();
         System.out.println(res);     
         while(!res.equals(null))
         System.out.println(res);     
         res = br.readLine();
    proc.waitFor();
         proc.destroy();
    catch(NullPointerException npe)
         npe.printStackTrace();
    catch (Exception IOEx)
    IOEx.printStackTrace();
    But it doesnt work as my chasen.exe needs arguments from stdin.
    The way exe works is as follows.
    on command prompt>>
    C:/chasen.exe -j [ Need to press ENTER here]
    input statement . [ Need to press ENTER here too]
    Then output is displayed on command prompt which can be taken from InputStream of the process. But I m not able to properly run this exe itself with all the arguments frm Stdin

  • I have a problem with running an EXE file on win2000, the Lab View is 5.1 and I do not know if it is 16 bit...

    I have a problem with running an EXE file on win2000, the Lab View is 5.1 and I do not know if it is 16 bit...what should I do?

    Hi Arika,
    The drivers that you need to install to make your executable work depends on what your executable is doing. To get started, you need to have the LabVIEW Run-Time Engine installed on your target machine (the Win2000 machine you are planning to use) in order to run your executable. Next, you need to determine what drivers your executable uses, if any. For example, if you are using GPIB instrument control, you will need to install the NI-488 drivers on your target machine. If you are performing data acquisition, you will need to install NI-DAQ drivers. If you are doing image acquistion, you will need to install NI-IMAQ drivers.
    All these drivers are available for downloading on ni.com. To get the drivers, go to ht
    tp://www.ni.com/support , click on the link that takes you to Drivers and Updates (under Option 3), and click on the links to get to the driver(s) you need. For example, if you need the LabVIEW 5.1.1 Run-Time engine, click on the All Drivers and Updates by Application link on the main page (http://www.ni.com/softlib.nsf/). Then click on the LabVIEW link, Windows 2000, Run Time Engine, and then you will see the link to get to the page to download the LabVIEW 5.1.1 Run-Time Engine.
    I hope this information helps.
    Best Regards,
    Wilbur Shen
    National Instruments

  • How To Run An External .exe File With Command Line Arguments

    Hiya, could anyone tell me how I can run an external .exe file with command line arguments in Java, and if possible catch any printouts the external .exe file prints to the command line.
    Thanks.

    Using the Runtime.exec() command. And read this:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • How to run .exe files with DAQ on a target PC?

    Hi,
    I want to run LabVIEW executable files on a target PC, where there is no LabVIEW installed. These files are used to do measurement using DAQ devices.
    In order to run these .exe file, I guess that I should install both LabVIEW Runtime Engine and NI-DAQmx on the target PC. Is it right?
    I'm wondering if it is mantatory to install NI-DAQmx on the target PC. I tried running .exe files without NI-DAQmx installed, but there was an error: nilvaiu.dll couldn't be found. Shouldn't this file be included automatically when building the executable files?
    Thanks,
    Qifu

    No, none of the hardware drivers are included in the LabVIEW exe that you build. You have to install DAQmx. With LabVIEW 8.x, you can include the DAQmx driver with the installer that you create. You also have the option to install different versions of DAQmx. These different versions are smaller than the full DAQmx install (i.e. you may choose to install documentation, MAX. etc.). When you create the installer, you also inclue the LabVIEW run-time and you should also choose to install the hardware configureation that is in MAX.

  • Running an exe file from java

    Hi , can anyone tell me how to run an exe file from my java program. the exe is in the same directory as my java files . When i click on a button i want to put something in the actionPerformed() method which will launch the exe file - prog.exe
    Hope someone can help me.
    Thanks Jim

    Hi !
    Look at the RunTime class...

  • What is the best way to run a powershell script with parameters in the Task Scheduler?

    Hello, 
    Want to run the following from a scheduled task in the Task Scheduler on a server.  What is the best approach?
    .\pscript.ps1 -csvfile "\\Srv1\Share\File.txt"
    Thanks for your help! SdeDot

    Hi,
    To run a powershell script with parameters in the Task Scheduler:
    Program: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Add argument (optional): -Command "& c:\scripts\test.ps1 -par1 2 -par2 3"
    Hope the below two articles be helpful for you:
    Schedule PowerShell Scripts that Require Input Values
    https://blogs.technet.com/b/heyscriptingguy/archive/2011/01/12/schedule-powershell-scripts-that-require-input-values.aspx
    How to Schedule a PowerShell Script
    http://dmitrysotnikov.wordpress.com/2011/02/03/how-to-schedule-a-powershell-script/
    Regards,
    Yan Li
    Regards, Yan Li

  • Run/Start .Exe file in ColdFusion

    Hi guys,
    am trying to open up a .exe file like notepad or whatever windows program with using <cfexecute> but seems it doesn't work at all. I'm able to write the command in cmd and run the exe file but when i put the command in cfexecute so i get nothing.
    here is the command i would like to run:
    "C:\Program Files (x86)\Vc\vc.exe" -e "\Crystal\BF_Faktura_D.rpt"
    altso, run/start a simple .exe windows program. I think there is something about security access from CF server or something like that.
    ANY HELP?

    this is what i have in my .bat/.cmd file:
    "C:\Program Files (x86)\Vc\vc.exe" -e "\Crystal\BF_Faktura_D.rpt"
    And i would like to remove that batch file totaly and run the command directly from CF to be able to make a HTML form and put some inputs through that form.
    here you can see what i really do in bat file:
    echo parameters:
    echo      fakturagruppe  : %1
    echo      fakturanr(fom) : %2
    echo      fakturanr(tom) : %3
    "C:\Program Files (x86)\Visual CUT 11\Visual CUT.exe" -e "\BF_Faktura_D.rpt" "Parm1:%2>>>%3>>>3" "Parm2:false" "Parm3:%1" "Parm4:false"
    "Export_File:\\bf-visma02\vismadata\vbdoc\F0001\Fakturakopi\IC{BF_Faktura_S.InvoNo}.pdf" "Export_Format:Adobe Acrobat (pdf)"
    I would like to open Visual cut.exe through CF to be able to make thos parameters in an HTML form instead of inputs from .bat file as you see!

  • How to execute one .exe file with as3 in air ?

    Hi
    How to execute one .exe file with as3 in air?
    I want do this work without fscommand .
    plize 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.

  • Can I run a .exe file on a Mac?

    I need to know know if it's possible to run a '.exe' file on an Intel-based Mac running Mac OS X. There's a CD with an application I need to run. In the Finder it has the icon of the black computer screen with green letters and it's titled 'startCD.exe. It'll run on Windows but due to circumstances I need to run it on my computer. Any direction you can point me in will be greatly appreciated. Thank You!
    MacBook   Mac OS X (10.4.8)  

    Maybe:
    http://www.codeweavers.com/
    "CrossOver Mac allows you to install many popular Windows applications and games on your Intel OS X Mac. CrossOver includes an easy to use, single click interface, which makes installing Windows software simple and fast. Once installed, your application integrates seamlessly in OS X. Just click and run your application directly from the OS X Finder. Clicking a Windows file or document — including email attachments — will launch the appropriate Windows program, allowing you to work on the files. Best of all, you do it all easily and affordably, without needing a Microsoft operating system license.
    Adding new Windows software is easy. Just place your install CD in your Intel Mac, and CrossOver will recognize it and offer to begin the installation process. CrossOver then completes the installation and configures your application to run on your Mac. That's all there is to it."

  • Is it possible to convert Java to EXE and run this EXE file without any JRE

    hello friends
    I have GCC/GCJ for windows but dont know how to work with it... it creates file with .o extension but i m not able to create .exe from that... i installed mingw for that also .. unsuccessful ...
    tell me the solution for it... i want to generate machine dependent exe from java file...on the web i ve seen that GCC/GCJ is used on linux platform..not cleared properly..
    Again i m writing my question
    Is it possible to convert Java to EXE and run this EXE file without any JRE if yes then how... tell me the procedure to do that...

    Vipul wrote:
    Its software now hardware .... some times u need these things ...anyway do u ve solution for my questionSo what? By creating a native executable you are restricting the program to the OS for which that native executable was made, just like removing the engine from a car restricts driving to downhill only. So like the I said, the principle remains the same, "Why would you want to?"
    I am asking you, truthfully, why do you feel the need to negate the largest advantage of using Java by creating a native executable from it?
    What is your rationale?
    I can pretty much guarantee there is a much better way of achieving your wish without "removing the engine".

  • EXE file with STMP mail

    Hi guys,
    I ran into a problem that I don't understand and I would really appreciate someone's expertises getting in.
    I've developed a VI (let's call it a 'Main.VI') that has more than 100 subVIs. Among the subVIs, there are numerous 'STMP Email Send Message.VI's.  What this whole program does is that it first reads raw data from a data logger, goes through a data processing/reduction program, saves reduced data into a folder, and then sends only reduced data files to the users on timely basis (e.g. every hour, once a day, once a week...) - this is where 'STMP email send message.VI' comes in play.
    I plan on running this 'Main.VI' as a service (in background). So I made an exe file out of this 'Main.VI'.  Now, here comes an odd part. Before I made a exe file, everything works fine (it saves data and send reduced files to users). However, when I make and run the exe file, the email thing does NOT work. The strange thing is that everything else works fine but I can not get the email stuff to work.
    Does anyone have any idea why it's happening? Any suggestions?
    Does Labview limit the usage of STMP email.VI when a normal VI is turned into an exe file?

    Thanks for your help. To anwer your question first, No I'm not using 'current vi's path'. The location of my 'Main.VI' and the file folders are different (e.g, 'C:\....\desktop\Main.VI.' and 'C:\temp\data file folder'). I will once again try to explain how the program works.
    1. 'Main.VI' collects/reduces/processes raw data and save the reduced data hourly into 'data file folder'.
    2. When it reaches a certain time limit (e.g. 1day, 1week, 1 month,..etc), it will send a notification to a subVI and this subVI will do some processing/saving and send a reduced file to users via email.
    Again, before I make an exe file, everything works the way I programmed. After building an exe, however, everything else works fine except the email.
    I included a screen shot of a portion of block diagram for this subVI. 
    Attachments:
    block diagram.doc ‏156 KB

  • Labview- .EXE file with excel template

    How to create a .exe file from the .vi file with excel template. Since I am giving only .exe file, the client wont be having the excel templates. So please tell me how to build a .exe file with templates which will be invoked by mainfile.vi. Please let me know if U guys know. (Now in my mainfile.vi I am using local file location path to invoke)

    Hi saamy,
    I have tested it out at my PC and it is working.
    I have tested with MS office report and put the template "Excel Template.xlt" under VI's folder (C:\temp) and make the exe file.
    After the exe file has been moved to other place(C:\build) and has been executed, the exe file try to locate  "Excel Template.xlt" under both C:\temp and C:\build. As long as the template is the same folder with exe file, it is working.
    Pls refer to attached file.
    Hopefully it will help. Please let me know the result.
    Thanks & Regards,
    Steve
    Attachments:
    My Application.zip ‏4415 KB

Maybe you are looking for

  • Windows Home Server and iTunes

    Hi, I have the following setup (all machines on GBit LAN): - a Windows Home Server machine with all my music on it (currently stored raw on the filesystem) - 3 Windows XP machines - 2 iPods I would like an authoritative answer on how to setup iTunes

  • How do I get the Adobe Presenter trial .exe file to run? I'm getting an error requiring placement into a designated folder,

    Getting an error trying to run the Adobe Presenter trial .exe file because it is requiring that the file be placed in a designated folder with the other downloaded file. How do I solve this problem?

  • Cache server settings...

    Some of my Crystal reports need caching and some are run so frequently that they need caching set to zero. Is there a way to have certain reports use a different cache server? Thanks, Todd Edited by: Todd Stalie on Oct 2, 2008 11:01 PM Edited by: Tod

  • How to integrate SCM with SM7.0

    Gurus: Is there any relationship between SM7.0 and SCM except using SM7.0 to monitor SCM? Thanks a lot!

  • Prob with drop down lists jiggling

    Hi all This is a little different than the last posted problem. When I click on a drop down list..for example a list of states, I can only scroll so far down. The list jiggles up and down, when you get only about 1/2 way down it suddenly shifts back