Launch Pad

I have been thinking about a great real-world example of a script to do a simple launcher..

You can go as simple as a batch file or a full-featured AutoIT Script that is compiled into an executable..

We’ll keep this simple and just use Windows notepad.exe and calc.exe for now..

In Batch, we have (Note: in ASE, you will need to change the behavior to “Execute via shell”) :

@echo off
Color e0
Cls
:menu
@Ping 127.0.0.1 -n 3 -w 1000 > nul
echo.
echo Menu options:
echo.
echo 1 Notepad
echo 2 Calculator
echo.
echo x Exit
echo.
Set /p userc= What would you like to DO?
If "%userc%"=="1" Goto notepadrun
If "%userc%"=="2" Goto calcrun
If /i "%userc%"=="x" Goto exitnow
echo %userc% is an invalid choice
Goto menu
:notepadrun
notepad.exe
echo.
echo Returning to Main Menu..
@Ping 127.0.0.1 -n 1 -w 1000 > nul
Cls
Goto menu

:calcrun
calc.exe
echo.
echo Returning to Main Menu..
@Ping 127.0.0.1 -n 1 -w 1000 > nul
Cls
Goto menu
:exitnow
echo Exiting menu..
@Ping 127.0.0.1 -n 1 -w 1000 > nul
Cls
Exit

Even though that is a simplistic example, there is a lot of code there..

3 Responses

  1. Excellent Kent! Can you elaborate on your use of ping here?

  2. The use of PING is to simulate SLEEP.. Older OS installations did not include SLEEP.EXE as part of them.

    So.. With:
    @Ping 127.0.0.1 -n 1 -w 1000 > nul

    It is telling PING to PING 127.0.0.1 (localhost)
    For one (1) time (-n 1)
    And wait 1000 milliseconds (1 second) (-w 1000). Note: If you wanted to wait say 5 seconds, change the -n 1 to be -n 5 and it will wait 5 iterations of 1000 milliseconds and is 5 seconds.. Sorry about being windy here.
    > nul and this redirects the screen output to nul (suppress the output)

    HTH,

    Kent

  3. Excellent, a nice trick; thanks for sharing!

Comments are closed.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: