Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

batch file parameter choosing

  • 24-04-2007 9:16pm
    #1
    Registered Users, Registered Users 2 Posts: 1,766 ✭✭✭


    Hi Folks,
    Anyone still have the knack of DOS batch scripting? I would like to create a .bat file which would allow me to choose 1 or 2 for say starting or stopping services. I'd like to find some specific examples or someone would know offhand? It's been awhile! I believe I need to use % for parameters.

    eg.

    REM ** do this **
    %1 run this
    REM ** do that **
    %2 run that


Comments

  • Registered Users, Registered Users 2 Posts: 1,766 ✭✭✭hamster


    Think I found an example I can work with:

    @ECHO OFF
    ECHO 1 - Stars
    ECHO 2 - Dollar Signs
    ECHO 3 - Crosses


    CHOICE /C:123

    IF errorlevel 3 goto CRS
    IF errorlevel 2 goto DLR
    IF errorlevel 1 goto STR

    :STR
    ECHO *******************
    ECHO.
    PAUSE
    CLS
    EXIT

    :DLR
    ECHO $$$$$$$$$$$$$$$$$$$$
    ECHO.
    PAUSE
    CLS
    EXIT

    :CRS
    ECHO +++++++++++++++++++++
    ECHO.
    PAUSE
    CLS
    EXIT


  • Registered Users, Registered Users 2 Posts: 1,766 ✭✭✭hamster


    Found a nice scripting site:

    http://www.robvanderwoude.com/index.html


  • Closed Accounts Posts: 1,974 ✭✭✭mick.fr


    hamster wrote:
    Hi Folks,
    Anyone still have the knack of DOS batch scripting? I would like to create a .bat file which would allow me to choose 1 or 2 for say starting or stopping services. I'd like to find some specific examples or someone would know offhand? It's been awhile! I believe I need to use % for parameters.

    eg.

    REM ** do this **
    %1 run this
    REM ** do that **
    %2 run that

    net start dns
    ...
    net stop dns

    Easiest way rather than creating a menu, or if you insist :

    :: Script start
    :: Kick ass batch file from Mick.fr, the batch killer.
    SET Choice=
    SET /P Choice=Hey budy, please make your choice
    echo.
    echo Press 1 to start the DNS service
    echo Press 2 to stop the DNS service
    echo Press 3 to to get a new boss
    echo Press 4 to get a night out with the gorgeous HR manager
    IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1%
    echo.
    :: /I makes the IF comparison case-insensitive
    IF /I '%Choice%'=='1' GOTO option1
    IF /I '%Choice%'=='2' GOTO option2
    IF /I '%Choice%'=='3' GOTO option3
    IF /I '%Choice%'=='4' GOTO option4

    :option1
    net start dns

    :option2
    net stop dns

    :option3
    getanewboss.exe
    echo That might work if you publish his CV on Monster.ie

    :option4
    getlaidtonit.exe
    echo That might work if you get a nice bimmer


    But I would rather go with some WSH/VB scripting, or KIXTART which is an excellent and really handy scripting engine, plus it is really easy and powerful.


  • Closed Accounts Posts: 1,974 ✭✭✭mick.fr


    hamster wrote:
    Think I found an example I can work with:
    CHOICE /C:123

    CHOICE is a small app you can get from Windows resource kit, but out of the box it is not on XP+
    Plus this is legacy, SET needs to be used on instead.


  • Registered Users, Registered Users 2 Posts: 1,766 ✭✭✭hamster


    Nice one mick.fr - Choice errored out for me since I didnt have the resource kit (have XP). I found a ref to set /p. Nice example btw - Thanks!


  • Advertisement
  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 92,404 Mod ✭✭✭✭Capt'n Midnight


    mick.fr wrote:
    CHOICE is a small app you can get from Windows resource kit, but out of the box it is not on XP+
    Plus this is legacy, SET needs to be used on instead.
    you can use the choice from dos 6 /window 95 / 98 too.
    use with errorlevel , and you don't have to press enter either

    to see if the DNS service has started
    net start | find /i "DNS"
    if errorlevel 1 echo "dns NOT started"

    a bit of imagination and you get a batch file that will toggle the DNS service.

    might as well add a
    ipconfig /flushdns
    too


Advertisement