Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
i'm writing a batch file for messageing my local network, because typing "net send gets old...
heres and example...
%%%%%%%%%%%%%%%%%%%%%%%%%start$$$$$$$$$$$$$$$$$$$
@echo off
:1
if "%1" == "Hobbit" goto 10
(other ifs go here)
:else
goto 100
:10
net send lorax * %2 >nul
goto exit:100
echo.
echo NS version .5
echo,
echo Usage:
echo ns (name) (message)
echo ns names
echo.
Goto end
:exit
if errorlevel=1 goto fail
if errorlevel=0 echo Message Sent
goto end
:fail
cls
echo Sending of message failed, user may not be on network.
echo For computer name changes, please notify GodSyn.
goto end
:end
@echo on
%%%%%%%%%%%%%%%%%%%%%%%%%STOP%%%%%%%%%%%%%
how can i make it that %1 isnt case sensitive, and that %2 is every charcter, including spaces, after %1? for as it stands now... "ns.bat Hobbit hi, how are you?" sends "hi," to him.any help would be greatly appreciated... please send reply to godsyn@hotmail.com (subject = batch)

NOTE: this message was also e-mailed to the original poster.
You reported your OS to be Dos 6.X. Are you certain about this? I'm asking because many people using NT systems such as Windows NT or 2000 think they're on DOS just because they're using the command prompt. That's NOT true.
So, if you're on DOS or on Win9x, there's no direct way to make the IF comparison case unsensitive (though there are probably work arounds). If you're on a NT system, add the /I switch to the IF cmd:
if /I "string"=="STRING" echo True!
About sending all characters after %1, like
ns.bat Hobbit hi, how are you?
Sending
hi, how are you?
Not only
hi,This should do it:
set MSG=
:loop
set MSG=%MSG%%2
shift
if not "%2"=="" goto loopThat would go on the begin of the script (right after "@echo off"). Then, when sending the message, instead of %2, use %MSG%.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

well, thank you very much.. now i have a new problem.. there are no longer spaces in the words that i type :P

Oh, sorry about that.
BTW, I forgot mentioning... On DOS, there are some characters which separate one argument from another. Those are: [space] [;] [,] [=] (those are the ones I can remeber). Such characters aren't part of any batch variable, so you can't know if a space or a comma or what was used to separate arguments.
What I'm trying to say is that
ns.bat Hobbit hi, how are you?
Won't send
hi, how are you?
But this, instead:
hi how are you?-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |