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

Author Topic: keep batch file on top of other windows  (Read 25937 times)

0 Members and 1 Guest are viewing this topic.

Khasiar

    Topic Starter


    Intermediate

    keep batch file on top of other windows
    « on: May 04, 2011, 10:57:08 PM »
    Hey all,

    Trying to figure out how to keep a batch file on top of other windows.

    Pretty much my program runs a series of tests and outputs results on the cmd window but all the programs it opens go on top of CMD window, is there a way to refresh this screen?

    I was thinking maybe have a 2nd batch file that continuously calls the previous one but that would probably require a PID or something along those lines and seems unfeasible.

    Thanks,
    Khas

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: keep batch file on top of other windows
    « Reply #1 on: May 04, 2011, 11:47:52 PM »
    It is not clear what you want.
    Batch files are normally used for tasks that come to an end and do not need to leave a window open on the desktop. You may wish to consider a programming language for Windows other than command line batch scripts.

    Yes, there is a way to do this, but you need to explain in a clear and logical way what you want to do. So you want a report to be seen on the desktop at all times? How will the report be refreshed? It is possible to write text from a batch  to an object that is present on the desktop, but how the object is refreshed has to be determined.

    Khasiar

      Topic Starter


      Intermediate

      Re: keep batch file on top of other windows
      « Reply #2 on: May 15, 2011, 08:59:52 PM »
      Hi Geek-9PM

      When i run my batch file it opens multiple windows which appear on top of the batch window ie open 5 instances of cmd and they will cascade but you will not be able to read any text from the initial cmd window as it is covered by the other 4.

      The batch i created echos results when opening these programs but you cannot read them unless you change window to the batch file and which stage the program has already started opening more windows and hides the batch screen again.

      so the aim is to somehow keep a batch window above all current and new windows until the batch has completed

      hope this makes more sense

      Geek-9pm


        Mastermind
      • Geek After Dark
      • Thanked: 1026
        • Gekk9pm bnlog
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Re: keep batch file on top of other windows
      « Reply #3 on: May 15, 2011, 09:20:21 PM »
      May be helpful if you could either show what you have, or write a simplified version that shows the same behavior.
      It is not clear if you are debugging the batch or if you need to show the user various outputs. Batch does not of itself control where a window opens.
      Not knowing what you want to show the user, it is hard to guess how a batch could do it. If you just want the user to see some reports properly aligned on the desktop, it is easier to do it in a regular presentation program like power point or even Excel. It is even possible to use HTML frames to put  stuff where you wan t it on the desktop. It is not clear why you want a batch to place things in well-positioned windows.  If you want batch to open another windows, there is not easy way to force a batch where to put the next window. But there are scripts that can do that. Are you familiar with Vb Script?

      Khasiar

        Topic Starter


        Intermediate

        Re: keep batch file on top of other windows
        « Reply #4 on: May 17, 2011, 09:47:50 PM »
        Familiar but not too good at it, learning API at the moment.

        My batch is a very low level stress tester so please dont get the wrong idea by it. the purpose of it is to test that a computer can run on full capacity without crashing or bluescreening.

        you must understand my shyness when revealing code, its similiar to stripping *censored* in public hahaha anyway here it is

        @echo off
        echo      _ _     _ _     _ _
        echo     _   _   _   _   _   _
        echo    _  _  _ _  _  _ _  _  _
        echo     _   _   _   _   _   _
        echo      _ _     _ _     _ _
        echo.
        echo.
        echo 1. Start stress test 1
        echo 2. Kill all processes opened by stress test 1
        echo 3. Quit
        echo.

        set /p userinp=choose a number(1-3):
        set userinp=%userinp:~0,1%

        if "%userinp%"=="2" goto kill
        if "%userinp%"=="3" goto end

        echo.

        set /p test=How many tests do you want to run?
        set test=%test:~0,2%

        set instance = 1

        if "%userinp%"=="1" goto start


        :start

        set /a instance+=1

        echo Starting Test %instance%

        start program

        echo Passed Test %instance%

        if %instance%==%test% goto kill
        goto start


        :kill

        taskkill -f -im "program" >> a.txt

        del a.txt

        goto end

        :end
        pause
        exit


        The parts that of interest to this post is that i want to be able to view the echos so that i can see what test they are up to and or fail on to compare with other computers etc.
        im sure you know how this program operates and as you can imagine with constant calls to new programs clicking on the CMD window specially when your CPU is maxing out and RAM is filling is very difficult so keeping the window on top will be ideal.


        Geek-9pm


          Mastermind
        • Geek After Dark
        • Thanked: 1026
          • Gekk9pm bnlog
        • Certifications: List
        • Computer: Specs
        • Experience: Expert
        • OS: Windows 10
        Re: keep batch file on top of other windows
        « Reply #5 on: May 18, 2011, 10:07:17 AM »
        Now I get the picture. You want the original windows, or a specific windows, to always be visible. One method is to have dual displays, but I think you would have tried that it you had two monitors.

        Off the top of my head I don't know how you tell windows to keep on DOS box on top. But you can tell the CMD to start a program with a limited windows, or no window. Look at this:
        Quote
        START
        Start a specified program or command in a separate window.

        Syntax
              START "title" [/Dpath] [options] "command" [parameters]
        Key:
           title      : Text for the CMD window title bar (required)
           path       : Starting directory
           command    : The command, batch file or executable program to run
           parameters : The parameters passed to the command
        Options:
           /MIN       : Minimized
           /MAX       : Maximized
           /WAIT      : Start application and wait for it to terminate
           /LOW       : Use IDLE priority class
           /NORMAL    : Use NORMAL priority class
           /HIGH      : Use HIGH priority class
           /REALTIME  : Use REALTIME priority class

           /B         : Start application without creating a new window. In this case
                        ^C will be ignored - leaving ^Break as the only way to
                        interrupt the application
           /I         : Ignore any changes to the current environment.

           Options for 16-bit WINDOWS programs only

           /SEPARATE   Start in separate memory space (more robust)
           /SHARED     Start in shared memory space (default)

        http://ss64.com/nt/start.html
        Example"
        start "Peek-A-Boo" /MIN "new-batch.bat "

        Would tell CMD  stat new-batch with a window in the task  bar  that says "Peek-A-Boo" but not on the screen.

        That is the best I can do. For more info, see the link above.

        Salmon Trout

        • Guest
        Re: keep batch file on top of other windows
        « Reply #6 on: May 18, 2011, 11:06:14 AM »
        That is the best I can do.

        And very good it was too.

        Salmon Trout

        • Guest
        Re: keep batch file on top of other windows
        « Reply #7 on: May 18, 2011, 11:11:02 AM »
        Off the top of my head I don't know how you tell windows to keep on DOS box on top.

        You can't easily with anything built-in but there is a downloadable program called CMDOW which can do this among other things (move, resize, send to back, bring to front, keep on top, tile horizontally or vertically, [and untile again] cascade, [and uncascade], activate, deactivate, minimize, maximize, restore. and more!) Beware though because some antivirus programs (stupidly IMHO) flag it as suspicious apparently because it can be used to completely hide a window.

        Khasiar

          Topic Starter


          Intermediate

          Re: keep batch file on top of other windows
          « Reply #8 on: May 18, 2011, 07:45:13 PM »
          Salmon: Would like to keep it native to most OS's but it seems like an awesome program :)

          Geek: If i open all programs as /min it works although winword and powerpnt 2010 is an exception as it minimizes the first instance and the rest open non minimized.

          This should be good enough though thanks for all your help!