|
Answer» 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, KhasIt 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. 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 senseMay 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?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.
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. Quote from: Geek-9pm on May 18, 2011, 10:07:17 AMThat is the best I can do. And very good it was too. Quote from: Geek-9pm on May 18, 2011, 10:07:17 AMOff 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. 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!
|