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:
Vilkku
Veteran Member
*****

Avatar

Posts: 1411
Reputation: 27
36 / Male / Flag
Joined: Mar 2003
O.P. Input for .bat files
Quick queston, I doubt this is possible.
Is it possible to add input and variables for .bat files? Or we can counter it: how can I use command line commands with java?

Example:
code:
Choose a number: x
net send abc1230x Hello
[Image: signature.php]
03-18-2005 08:32 PM
Profile E-Mail PM Web Find Quote Report
segosa
Community's Choice
*****


Posts: 1407
Reputation: 92
Joined: Feb 2003
RE: Input for .bat files
I believe %1, %2, etc refers to each word in the commandline parameters of the .bat file.
The previous sentence is false. The following sentence is true.
03-18-2005 11:04 PM
Profile PM Find Quote Report
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
lopardo
Veteran Member
*****


Posts: 1395
Reputation: 33
38 / Male / Flag
Joined: Nov 2002
Status: Away
RE: Input for .bat files
Really good page about batch files: http://www.robvanderwoude.com/
[Image: userbar452797dd.gif]
03-19-2005 03:09 AM
Profile PM Find Quote Report
Vilkku
Veteran Member
*****

Avatar

Posts: 1411
Reputation: 27
36 / Male / Flag
Joined: Mar 2003
O.P. RE: Input for .bat files
Thank you all <3

*I deleted the old post and reposted it with the following message to get you to read this*

Is there any similar thing to Javas x++, so that I could set how many times I could send the message?
[Image: signature.php]
04-07-2005 10:54 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


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