Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Test to see if Batch File is running  (Read 6928 times)

0 Members and 1 Guest are viewing this topic.

BatchFileCommand

    Topic Starter


    Hopeful
  • Thanked: 1
    Re: Test to see if Batch File is running
    « Reply #15 on: March 01, 2009, 03:45:58 PM »
    Oh, I was thinking to see if there are to sessions of cmd.exe running.
    οτη άβγαλτος μεταφ βαθμολογία

    oldun

    • Guest
    Re: Test to see if Batch File is running
    « Reply #16 on: March 01, 2009, 08:56:21 PM »
    Maybe the batch file could create a file when it starts, and delete it when it completes.

    The batch file could then check for the existence of that file when it starts, and if it finds the file, it would exit, or else it would carry on.

    BatchFileCommand

      Topic Starter


      Hopeful
    • Thanked: 1
      Re: Test to see if Batch File is running
      « Reply #17 on: March 02, 2009, 07:25:47 PM »
      That would be a lot of work. Because the only way that you could really quit would to click the exit button in the corner of the screen. Or doing quit. But the person will probably press the X button.
      οτη άβγαλτος μεταφ βαθμολογία

      Dias de verano

      • Guest
      Re: Test to see if Batch File is running
      « Reply #18 on: March 03, 2009, 12:16:29 AM »
      the only way that you could really quit would to click the exit button in the corner of the screen. Or doing quit.

      A batch file will quit when it encounters the EXIT command.  ::)

      oldun

      • Guest
      Re: Test to see if Batch File is running
      « Reply #19 on: March 03, 2009, 12:29:45 AM »
      I may have misunderstood your requirements, but what I was thinking of was something like this:


      @Echo Off
      :: Check if temporary file exists
      If Exist %temp%\AlreadyRunning.tmp (
         Echo This batch file is already running & Goto :EOF)
      :: Else create it
      Echo . > %temp%\AlreadyRunning.tmp
      :: Carry on with remainder of batch file
      Echo.
      Echo Do whatever here, then
      Echo.
      :: Delete temporary file
      Del %temp%\AlreadyRunning.tmp


      BatchFileCommand

        Topic Starter


        Hopeful
      • Thanked: 1
        Re: Test to see if Batch File is running
        « Reply #20 on: March 03, 2009, 07:57:08 PM »
        My program. Doesn't really have a beginning and an end. It has a old GUI with options.
        οτη άβγαλτος μεταφ βαθμολογία

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: Test to see if Batch File is running
        « Reply #21 on: March 03, 2009, 09:08:31 PM »
        My program. Doesn't really have a beginning and an end. It has a old GUI with options.

        all programs have a beginning and an end.  instead of exiting the batch file using EXIT, you can redirect to a label that performs the necessary cleanup.
        I was trying to dereference Null Pointers before it was cool.

        BatchFileCommand

          Topic Starter


          Hopeful
        • Thanked: 1
          Re: Test to see if Batch File is running
          « Reply #22 on: March 04, 2009, 06:03:31 AM »
          Even if it does have a beginning and an end. What if someone doesn't know about the file and clicks the X button in the corner of the screen. Then they would never be able to use it again.
          οτη άβγαλτος μεταφ βαθμολογία

          BC_Programmer


            Mastermind
          • Typing is no substitute for thinking.
          • Thanked: 1140
            • Yes
            • Yes
            • BC-Programming.com
          • Certifications: List
          • Computer: Specs
          • Experience: Beginner
          • OS: Windows 11
          Re: Test to see if Batch File is running
          « Reply #23 on: March 04, 2009, 06:07:05 AM »
          This is why I stopped using this method in my batch files/programs early on.
          I was trying to dereference Null Pointers before it was cool.