How to see if a program is running?

Hello,
I need to implement a program that checks if a program called "Thing.exe" is runing. If it is not running it launches "Thing.exe" and if it is kills "Thing.exe". This is the first time I have to program something like this in java and I'm lost with the syntax. The problem is basically I don't know how to check if "Thing.exe" is there running happily.
A little bit of code:
public class Main {
    public static void main() {
        Runtime application = Runtime.getRuntime();
        try {
            if (isRunning()) {
                application.exec("taskkill.exe /F /IM notepad.exe");
            } else {
                application.exec("cmd.exe /k start ThingLauncher.bat");
        } catch (Exception ex) {
            ex.printStackTrace();
    public static boolean isRunning(){
        boolean running=false;
        int[] pid;
        pid=Process.getProcess("Thing.exe"); // <-- obviously this is wrong
        if(pid.length!=0){
            running=true;
        return running;
}Hope someone can help me.
Thanks,
Onditz

A simple way is to launch a small vbscript and capture its output.
Example : [Check if a program or process is running (Windows)|http://www.rgagnon.com/javadetails/java-0610.html]
Bye.

Similar Messages

  • How to see if invisible program is running in background?

    Hello,
    I'm trying to help my friend who has an iMac running Snow Leopard (10.6.8). Her email and Facebook keep getting "hacked", and even though she changes the passwords to long and complex things that nobody could ever guess, someone is still able to figure out her passwords. The only way we think this could be happening is if someone broke into her home and put some type of "keystroke capture" program so that they could look at it while she's at work and get her passwords that way. We simply can not come up with any other way that her passwors are being discovered, and unfortunately we think it's a jealous ex-wife that is doing this.
    I seem to recall in Snow Leopard that there is a way to see what is running in order to see how much memory is being taken by each task or program on the computer, but I don't recall where to go on the computer to monitor that information. Can someone please point me to where that information is, and if you have any other advice on how to check to see if a program is running without her knowledge, I would sure appreciate any input.
    Thank you very much!

    Great---thank you very much. I actually do recognize everything there, so we are baffled as to what's going on.
    Thanks again!

  • I just got an IPAD2 on Saturday.  With the Mac, I could always tell when programs were open/running by going to the menu bar.  How can I tell what programs are running in the background.  I am struggling with not being able to go to a menu bar at the top

    I just got an IPAD2 on Saturday.  With the Mac, I could always tell when programs were open/running by going to the menu bar.  How can I tell what programs are running in the background.  I am struggling with not being able to go to a menu bar at the top

    You can see which apps are open and/or recently used by double-clicking the home button to bring up the taskbar at the bottom of the screen (not all apps that appear there are active) - you can then close apps on it by pressing and holding one of them for a couple of seconds or so until they start shaking, then press the '-' in the top left of the Mail app to close it, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar. If you have an app 'open' on-screen then it won't appear on the taskbar, you will need to go back to the homescreen first, and it should then show when you next open the taskbar.
    If you haven't already got a copy then you can download the iPad manual from here : http://support.apple.com/manuals/#ipad

  • How can I tell if programs are running in the background.

    iPod touch version 4.2.1, how can I tell if programs are running in the background.  Battery is dead quickly and time/date reverts to Dec 31, 1969.  can see thin silver frame around screen like something is running in background.

    You really can't tell unless you hear music or similar. Many are always listening for notifications and other things.
    To preserve battery life see the following:
    Apple - Batteries - iPod
    I leave mine in airplane mode when sleeping.

  • How to see the full program on the front panel when it is running?

    Hi, my program is really big, and when I run it and obverserve the program on the front panel, I cannot drag the window to see the other parts. Also, I tried the method like hold control, then press + to zoom in or press - to zoom out. However, labview seems doesnt have this function. Does anyone know how I can see the full program then it is running, maybe zoom out or drag the windows? thanks! 
    Attachments:
    not running.png ‏85 KB
    running.png ‏72 KB

    You should use a Tab control.  Group your front panel objects together and put the grouped items in tabs.  Then you can select the Tab you want to display while the program is running.
    It is never a good idea to make your screen too big to fit on one display.  This goes for the block diagram also.  If you have to scroll to see it all, use more subvi's.  Make it modular.  A state machine is a good way to put a lot of code on one display screen.
    - tbob
    Inventor of the WORM Global

  • How do I stop unnecessary programs from running in the background on a Macbook Pro 2010?

    Hi recently I bought a Macbook Pro OSX 10.8.3 2010 (2.4 GHz Intel Core / 2GB 1067 MHz DDR3). Im pretty content with it considering its my first Mac. Up until recently I had no problems with its speed.
    My brother directed me to the activity monitor and showed me how to quit a program. However there are still a several running programs I do not recognize and/or do not use (such as photo stream, Calendar Agent, UserEventAgent, Notification Center, AppleSpell service, cfprefsd, talagent, xpcd, imagent, com.apple.dock.extra, fontd, loginwindow, SystemUIServer, tccd, usernoted etc etc etc UGH!! The list just goes on and on. There is a circular graph at the bottom in pir form highlighted with the colors green, red, blue and yellow indicating what is taking up space or speed? If I quit Safari a huge portion of the green is highlghted. but I can not seem to get it to fill the majority of the pie graph. I see there are all these running programs (most of which I do not use or recognize) but I cannot get them to quit even if I highlight it. How can I stop this? Quite frankly its so frustrating. Again I am new to Mac.
    Thanks
    marcel11

    First, back up all data immediately, as your boot drive might be failing.
    There are a few other possible causes of generalized slow performance that you can rule out easily.
    Reset the System Management Controller.
    If you have many image or video files on the Desktop with preview icons, move them to another folder.
    If applicable, uncheck all boxes in the iCloud preference pane.
    Disconnect all non-essential wired peripherals and remove aftermarket expansion cards, if any.
    Check your keychains in Keychain Access for excessively duplicated items.
    Boot into Recovery mode, launch Disk Utility, and run Repair Disk.
    Otherwise, take the steps below when you notice the problem.
    Step 1
    Launch the Activity Monitor application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Activity Monitor in the icon grid.
    Select the CPU tab of the Activity Monitor window.
    Select All Processes from the menu in the toolbar, if not already selected.
    Click the heading of the % CPU column in the process table to sort the entries by CPU usage. You may have to click it twice to get the highest value at the top. What is it, and what is the process? Also post the values for % User, % System, and % Idle at the bottom of the window.
    Select the System Memory tab. What values are shown in the bottom part of the window for Page outs and Swap used?
    Next, select the Disk Activity tab. Post the approximate values shown for Reads in/sec and Writes out/sec (not Reads in and Writes out.)
    Step 2
    If you have more than one user account, you must be logged in as an administrator to carry out this step.
    Launch the Console application in the same way you launched Activity Monitor. Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
    View ▹ Show Log List
    from the menu bar.
    Select the 50 or so most recent entries in the log. Copy them to the Clipboard (command-C). Paste into a reply to this message (command-V). You're looking for entries at the end of the log, not at the beginning.
    When posting a log extract, be selective. Don't post more than is requested.
    Please do not indiscriminately dump thousands of lines from the log into this discussion.
    Important: Some personal information, such as your name, may appear in the log. Anonymize before posting. That should be easy to do if your extract is not too long.

  • How do you know what programs are running?

    Is there any way to tell from the Dock which programs are running? In Tiger there use to be a little black arrow underneath the app. What's changed in Leopard?

    The default Leopard Dock indicators are a bit difficult to see with the light background and 3D glass effect. If you would like to have a different look then go to http://www.leoparddocks.com/ I'm using the "Revamped" design.

  • How do I get a program to run inside flash

    How do I get a program on my harddrive to run inside flash on my computer? I would like to build a Flash front end for my boat pc, but I would need to be able able to open up a program inside a flash.exe?
    would a external .ini  File work? if so what code would I use internally to execute the .ini
    any help would be greatly appreciated Sincerely newwaveboats

    Thanks for the tip about Zink, but it is not what I'm after.
    On (Release)
    FS Command ("exec", "install.exe")
    End On
    google search just revealed this button code but it was for back in the day "Flash 8" as1 or 2.  as3 your not allowed code to be plaaced on buttons.
    So I know it is possible, I just need the know how.
    EDIT: I looked further into to this, and it is perfect for my needs. my first look was quick and I saw a close to 300 price tag and that it was a compiler, 2nd longer look showed it was free for personal use and has lots of great system features.
    Thanks again combustion007 for your help was greatly appreciated, Sorry I did not realize how perfect it was when you first told me about it.

  • How to check if ABAP program is running in another instance?

    Hey Guys,
    I need to ensure that a given ABAP program is only running in one instance.
    Here is what I tried so far:
    1) FM TH_WPINFO
    The problem with this is that the Z (custom) program calls lot of SAP function modules and when inside those, the WP_REPORT field of WPLIST table has something else and not the Z program name.
    2) FM ENQUEUE_ESINDX
    When I used the code below the following happened:
    -The First instance runs fine
    -The Second instance fails in the locking and exits the way it is supposed to but then
    -If I run the program the Third time, it runs with a succesful lock - probably because the after second instance the lock was cleared???
    CALL FUNCTION 'ENQUEUE_ESINDX'
        EXPORTING
         MODE_INDX            = 'E'
         MANDT                = SY-MANDT
         RELID                = 'ZZ'
         SRTFD                = PROGRAM
    *     SRTF2                =
    *     X_RELID              = ' '
    *     X_SRTFD              = ' '
    *     X_SRTF2              = ' '
    *     _SCOPE               = '2'
    *     _WAIT                = ' '
    *     _COLLECT             = ' '
        EXCEPTIONS
          FOREIGN_LOCK         = 1
          SYSTEM_FAILURE       = 2
          OTHERS               = 3.
    Any other idea, how I could accomplish this?
    Thanks a lot,
    Viktor

    -----> Include this perform in Initalization or in Start-of-Selection screen event.
    *&      Form  LOCK_CURRENT_INSTANCE
    * Perform to lock the current instance of the
    * program, so that only one
    * instance can be runned at a given time.
    FORM lock_current_instance .
    *---FM to lock the current instance of the program
        CALL FUNCTION 'ENQUEUE_E_TRDIR'
          EXPORTING
            mode_trdir     = abap_true
            name           = sy-repid
          EXCEPTIONS
            foreign_lock   = 1
            system_failure = 2
            OTHERS         = 3.
        IF sy-subrc <> 0.
          IF sy-batch = abap_true.
            MESSAGE e016 WITH 'Already one Instance of the Program is Running'.
          ELSE.
            MESSAGE s016 WITH 'Already one Instance of the Program is Running' DISPLAY LIKE 'E' .
            LEAVE LIST-PROCESSING.
          ENDIF.
        ENDIF.
    ENDFORM.                    " LOCK_CURRENT_INSTANCE
    ---->and include this perform as a last perform in End-of-Selection screen event.
    *&      Form  UNLOCK_CURRENT_INSTANCE
    * This perform is used to unlock the instance of the
    * running program
    FORM unlock_current_instance .
    *---FM to release the lock on the running program
      CALL FUNCTION 'DEQUEUE_E_TRDIR'
        EXPORTING
          mode_trdir = abap_true
          name       = sy-repid.
    ENDFORM.                    " UNLOCK_CURRENT_INSTANCE

  • How do I get my program to run at a faster frequency?

    I am using the PCI-DIO-32HS (6533) board. A portion of the program writes a pattern of various handshaking signals. The other clocks in a bit of data and formats the data into arrays. The spec. sheets say this board can do pattern I/O at 13Mbytes/s or handshake at 76Mbytes/s. I'm running a 733MHz processor with 128M of RAM. Even after changing the buffers any from 4-50 Million, the fastest I could get either part of the program to run individually was about 1MHz. Together, they top out at about 50KHz. What do I need to do to get this program to work at about 2MHz?

    William,
    Try running one of the examples that ship with LabVIEW that does pattern I/O or burst mode handshaking. One of the things to keep in mind is to eliminate as much programming in the DIO write loop as possible as this will slow down your program and your data transfer rate that is attainable.
    In LabVIEW the examples can be found under Search Examples -> I/O Interfaces -> Data Acquisition -> Digital I/O.

  • How to find whether a program is running in background

    Hi,
    I have a requirement to find out whether a program is being executed in background. If the same program is executed manually then it should not execute, the time when the same program is being executed in background.
    Please suggest.
    Thanks.
    Marked as a question
    Message was edited by: Rich Heilman

    You can put a lock on the program inside the program, so that when it is run it puts a lock entry in SM12, then anyone trying to run it will get a message saying that the program is locked.  USe the TRDIR lock object.
    report zrich_0001 .
    data: repid type sy-repid.
    repid = sy-repid
    call function 'ENQUEUE_E_TRDIR'
      EXPORTING
    *    MODE_TRDIR           = 'X'
        NAME                 = repid
    *   X_NAME               = ' '
    *   _SCOPE               = '2'
    *   _WAIT                = ' '
    *   _COLLECT             = ' '
    EXCEPTIONS
       FOREIGN_LOCK         = 1
       SYSTEM_FAILURE       = 2
       OTHERS               = 3
    if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    Welcome to SDN
    Regards,
    Rich Heilman

  • How to see the underlying program for Infoset  query in ECC?

    HI all ,
    we have generic datasource based on Infoset .
    now ii need to add 2 fields from batch characteristics .
    my question is how to go & edit the underlying abap program .
    i have added the fields to the extract structure , but not populated the 2 fiields .
    regards ,
    srinivas .

    Hello,
    Go to SQ02 T code -
    > Give your Info set Name -
    >Click on your Info set -
    >There top you will find Option GO TO click on Go To then you will get Global Properties -
    >if you click on Global Properties -
    >You will get another scree there if you click on External Program------->You will get  underlying program for Infoset  query in ECC.
    if you find the answer usefull kindly asign some points.
    Regards,

  • How to know if a program is running through a Web Service?

    Hello,
    I have some FM's published as WS, and they are working fine. These FM's may be called either through Web Services or through ABAP. I need a consistent way to know when the FM is called via the WS or via ABAP - I notice that sy-tcode is empty when the FM is called via WS, but:
    - Is it safe to test sy-tcode = INITIAL to conclude that the FM was called via WS?
    - Is there another way to distinguish the two situations? (Please do not suggest different users)
    - Can I force a "custom" sy-tcode content in the WS parameters that will allow me to detect the WS calls?
    Regards,
    Joã

    A colleague of mine had a similar problem a year or two ago, and I suggested to him the use of the SYSTEM_CALLSTACK function module... the results of that should tell you what caused your function to be invoked e.g. you'll probably see an entry for SAPLHTTP_RUNTIME / FUNC / HTTP_DISPATCH_REQUEST in the call stack (in ECC5 at least) when invoked from a web service.  There may be a more elegant way, but it seemed to work reliably.
    Jonathan

  • How to see my z programs in sap file system

    hello everyone
    my Z programs are deleted due t some server problem from  my  sap ecc 6.0 system  is there any way to  get   my programs from sap file system 
    if yes then  where  exactly in windows folder my zprogramms are stored.......

    >
    elinuk wrote:
    > my Z programs are deleted due t some server problem from  my  sap ecc 6.0 system  is there any way to  get   my programs from sap file system 
    If your Z Programs are present in other server viz., QAS / PROD, then you can import the programs to your DEV server.
    if yes then  where  exactly in windows folder my zprogramms are stored.......
    I am not sure about programs associated to unreleased transport requests (TRs). But when you release your TR, the data gets stored in COFILES & DATAFILES in the transport directory (DIR_TRANS) of the app server.
    Hope this helps.
    BR,
    Suhas

  • Trigger programs to run in background

    hello experts,
    In my program I have,
    do 2 times.
    SUBMIT <PROGNAME>  USING SELECTION-SET  'VARIANT'.
    enddo.
    its just running once. if i have 2 submits  to run 2 different programs its still running just the first one .how can I make my program to run both the programs one after another.plz advise!!!
    regards,

    Have u used the RETURN statement addition with SUBMIT
    SUBMIT REPORT AND RETURN.
    Have a look at this link.
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba50d35c111d1829f0000e829fbfe/frameset.htm
    Regards,
    Lakshman.

Maybe you are looking for