What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Input for .bat files

Input for .bat files
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Input for .bat files
some commands which can be usefull (type them in dos with /? behind them and you'll see the explainations):
    set /?
    shift /?
    if /?
    goto /?
    for /?

It is far too extensive to explain everything you can do with command lines and/or variables in DOS (it is almost a whole programming language on it's own now). Best is to google for a page which explains some stuff and work from there.

EDIT: but I'll make some quick examples anyways:

In all examples:
  • They all can take a number as command line. If a number is given, the prompt will not be executed. eg:

    C:\> example1.bat<enter>
    Choose a number: 1234<enter>
    net send abc1234 Hello

    C:\> example1.bat 5678<enter>
    net send abc5678 Hello

    C:\> _

  • No 'advanced' checking is done on the validity of the numbers; the user can enter letters as well for example.
  • Remove the 'echo' from the line "echo net send" if you actually want the net send command to be executed. 'echo' is added in these examples so you can clearly see what is suppose to be executed. (don't remove "@echo off" though)


First example:

@echo off
if "%1"=="" (
  set /p choice=Choose a number:
) else (
  set choice=%1
)
echo net send abc%choice% Hello
set choice=


Second example:
- shorter example of the first

@echo off
set choice=%1
if "%choice%"=="" set /p choice=Choose a number:
echo net send abc%choice% Hello
set choice=


Third example:
- variant of the second example:
- if user didn't type a number the question is asked again


@echo off
set choice=%1
:CheckNumber
if "%choice%"=="" set /p choice=Choose a number:
if "%choice%"=="" goto CheckNumber
echo net send abc%choice% Hello
set choice=


Fourth example:
- other version of the third example

@echo off
set choice=%1
:CheckNumber
if "%choice%"=="" (
  set /p choice=Choose a number:
  goto CheckNumber
)
echo net send abc%choice% Hello
set choice=


Fifth example:
- the program will quit when enter is pressed without typing a number

@echo off
set choice=%1
if "%choice%"=="" set /p choice=Choose a number:
if not "%choice%"=="" echo net send abc%choice% Hello
set choice=



This post was edited on 03-19-2005 at 12:49 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
03-19-2005 12:00 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Input for .bat files - by Vilkku on 03-18-2005 at 08:32 PM
RE: Input for .bat files - by segosa on 03-18-2005 at 11:04 PM
RE: Input for .bat files - by CookieRevised on 03-19-2005 at 12:00 AM
RE: Input for .bat files - by lopardo on 03-19-2005 at 03:09 AM
RE: Input for .bat files - by Vilkku on 04-07-2005 at 10:54 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On