Store the batch console on the screen as an active window

what I want to achieve is to run some directories (folders), but in the background and save the batch console on the front of the screen as active windows. For example, I have a package with a selection list, when I click 1) the assigned directory opens on the screen, and the batch console remains on top, like an active window, so I can choose another action to start and continue ... the batch console should stay on top, so that I can first open several actions, close the batch file and start working on open windows.

Hope that is clear :)

The selection list is very long, so the part below.

@echo off  
:List  
cls  
echo select from list  
echo.  
echo 1) Postage  
echo 2) Documents  
echo 3) EXIT  
echo.  
set /p option=select:  
if %option%==1 goto option1  
if %option%==2 goto documents  
:option1  
Start d:\Postage  
goto List  
pause  
:option2  
Start d:\documents  
goto List  
pause

, 1), , , , , 2) - 1) , Alt + Tab.

!

+2
1

, Windows XP SP3 x86, Windows 10 x64:

@if (@X)==(@Y) @end /* JScript comment
    @echo off

    rem A window title is needed so the appActivate function is
    rem able to recognize the console window of this batch file.
    title Open Folders

    setlocal EnableExtensions EnableDelayedExpansion

    :List
    cls
    echo Select from list.
    echo.
    echo 1) Postage
    echo 2) Documents
    echo 3) EXIT
    echo.
    set "Option="
    set /p "Option=Enter the number: "

    rem Prompt user once more if nothing entered.
    if "!Option!" == "" goto List

    rem Prompt user once more if entered string is not a positive
    rem integer because it contains characters not being a digit.
    for /F "delims=0123456789" %%N in ("!Option!") do goto List

    rem Trim all leading zeros from number.
    set "Number="
    for /f "tokens=* delims=0" %%N in ("!Option!") do set "Number=%%N"

    rem Prompt user once more if entered string is zero.
    if "%Number%" == "" goto List

    rem Prompt user once more if entered number is too large.
    if %Number% GTR 3 goto List

    rem Jump to appropriate option if not being the exit option.
    if %Number% LSS 3 goto Opt%Number%
    endlocal
    exit /B

    :Opt1
    call :OpenDirectory "D:\Postage"
    goto List

    :Opt2
    call :OpenDirectory "D:\documents"
    goto List


    rem This is a batch subroutine used for opening a folder with
    rem Windows Explorer and getting the command prompt window
    rem again back to top of all windows for next user input.

    :OpenDirectory
    if "%~1" == "" (
        %SystemRoot%\explorer.exe
    ) else (
        rem start "" "%~1"
        %SystemRoot%\explorer.exe /e,"%~1"
    )

    rem The jscript part with the appActivate is called now
    rem to make the command window again the top most window.
    %SystemRoot%\System32\cscript.exe //E:JScript //nologo "%~f0"

    rem This GOTO command ends the subroutine and results in continuing
    rem batch processing on the line below the line called this routine.
    goto :EOF

@if (@X)==(@Y) @end JScript comment */

var sh=new ActiveXObject("WScript.Shell");
WScript.Echo(sh.AppActivate("Open Folders"));

- - Bat , npocmaka.

Windows 10 x64. Windows, , , . , .

, ,

  • - ,
  • , ,
  • , ,
  • , EXIT.

, , , EXIT.

, , , .

, , , script GOTO List.

. KB314853 Windows Windows Windows 95.

, start "" "%~1" , , . "" , , . start "%~1" . "" .

, , , , .

  • call /?
  • cls /?
  • echo /?
  • endlocal /?
  • exit /?
  • for /?
  • goto /?
  • if /?
  • rem /?
  • set /?
  • setlocal /?
  • title /?

:

@echo off

rem A window title for better identifying what this cmd window is for.
title Open Folders

setlocal EnableExtensions EnableDelayedExpansion

:List
cls
echo Select from list.
echo.
echo 1) Postage
echo 2) Documents
echo 3) EXIT
echo.
set "Option="
set /p "Option=Enter the number: "

rem Prompt user once more if nothing entered.
if "!Option!" == "" goto List

rem Prompt user once more if entered string is not a positive
rem integer because it contains characters not being a digit.
for /F "delims=0123456789" %%N in ("!Option!") do goto List

rem Trim all leading zeros from number.
set "Number="
for /f "tokens=* delims=0" %%N in ("!Option!") do set "Number=%%N"

rem Prompt user once more if entered string is zero.
if "%Number%" == "" goto List

rem Prompt user once more if entered number is too large.
if %Number% GTR 3 goto List

rem Jump to appropriate option if not being the exit option.
if %Number% LSS 3 goto Opt%Number%
endlocal
exit /B

:Opt1
start "" /min "D:\Postage"
goto List

:Opt2
start "" /min "D:\documents"
goto List

, , . , , .

GUI . , , Windows,

start "" /min %SystemRoot%\explorer.exe /e,"%~1"

, , , , , , .

+1

All Articles