script menu

Discussion in 'Scripting' started by Thomas Dubreuil, Jan 11, 2019 at 18:08.

  1. Thomas Dubreuil

    Thomas Dubreuil MDL Member

    Aug 29, 2017
    134
    218
    10
    maybe a dumb question...I'm making a menu for a .bat script to run separate parts, like for ex:
    1 full script
    2 only reg part
    3 only task part

    I wonder if is there a way to run only part of the full script? for now I just copy parts and "goto :" from main menu but that makes a lot of redundant code...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. Imp Eached

    Imp Eached MDL Novice

    May 30, 2013
    6
    4
    0
    You mean something like this:

    Code:
    @echo off
    
    
    :top
    cls
    echo   ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
    echo   º  Sample Menu  º
    echo   ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
    echo   º 1 Full Script º
    echo   º 2 Registry    º
    echo   º 3 Tasks       º
    echo   ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
    echo   º X Exit        º
    echo   ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
    echo.
    set /p select="Choose one: "
    if /i %select% ==x goto exit
    if %select% ==3 goto task
    if %select% ==2 goto reg
    if %select% ==1 goto full
    goto top
    
    :full
     setlocal
     set full=on
     goto reg
    
    :reg
    Your registry commands go here
     if exist %full% ==on (goto task) else (goto cleanup)
    
    :task
    Your task commands go here
     if exist %full% ==on (goto comp) else (goto cleanup)
    
    :comp
     endlocal
     goto cleanup
    
    :cleanup
    Any nessecary cleanup should be done here
     echo.
     echo DONE!
     echo.
     pause
     goto top
    
    :exit
    
     
  3. Thomas Dubreuil

    Thomas Dubreuil MDL Member

    Aug 29, 2017
    134
    218
    10
    yes, exactly! thanks a lot
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...