Computing.Net > Forums > Disk Operating System > Advanced msdos batch file, need hel

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Advanced msdos batch file, need hel

Reply to Message Icon

Name: GodSyn
Date: November 19, 2002 at 23:55:55 Pacific
OS: dos 6.X
CPU/Ram: dosent matter
Comment:

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)



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: November 20, 2002 at 09:55:00 Pacific
Reply:

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 loop

That 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


0

Response Number 2
Name: godsyn
Date: November 21, 2002 at 01:09:45 Pacific
Reply:

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


0

Response Number 3
Name: godsyn
Date: November 21, 2002 at 01:11:55 Pacific
Reply:

nevermind, just needed a space in set MSG=%MSG%%2 like set MSG=%MSG% %2
thanx again


0

Response Number 4
Name: Secret_Doom
Date: November 21, 2002 at 18:53:31 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Advanced msdos batch file, need hel

Printing HTML file through a batch file www.computing.net/answers/dos/printing-html-file-through-a-batch-file/10731.html

MSDOS batch file program www.computing.net/answers/dos/msdos-batch-file-program/2471.html

Batch File Needed for SCR www.computing.net/answers/dos/batch-file-needed-for-scr/10359.html