There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Old school request....DOS batch program!


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
DarkCrystal's Avatar
Member with 51 posts.
 
Join Date: Jan 2005
Location: Wales, MA
Experience: spec=security.hardware;adv=soft;int=network
01-Apr-2005, 08:47 AM #1
Old school request....DOS batch program!
To s/he who reads this:

Its been a while since I last wrote me a DOS batch (*.BAT) program. So, here's my request. I would like it very much if someone could write me a BAT program that will do the following:
1. User enters the the number of the computer (alphanumeric, up to 4 characters) s/he would like to send a message
2. User enters message to send.
3. the 2 entered values should be put into the following DOS command: NET SEND th-2156-number message
4. Option to send or cancel.

So pretty much, it looks like this:

Send to: mm12
Message: Testing...123...Testing
NET SEND th-2156-mm12 Testing...123...Testing
Press [ENTER] to send this message, [ESC] to cancel.

Many thanks to s/he who helps me.
(Don't be afraid to put you name and what not in the coding, after all, it is your work.)
__________________
Templin, Bryan M.
PVT, U.S. Army, ADA
14J10(Q3), 01-06 D.H.G.
Fort Bliss, TX

Laptop Specs:
Brand: ACER Ferrari WLMi 4005
CPU: AMD Turion64 ML-37 2.0GHz 1MB Cache
RAM: 1GB DDR PC2700 333MHz
HD: 100GB
Video: ATI Radeon Mobility X700 128MB LCD/TFT/WSXGA 15.4" 1680x1050
Devices: Dual Layer DVD+-RW, Sound Blaster Audigy 2 ZS, 5-in-1 Media Card Slot
LAN: 10/100/1000 Integrated (RJ45) & Wireless, 2.4GHz Bluetooth, 4MBps Infrared, 56KBps Modem
OS: WIN XP Pro SP2

Custom Built PC
MacFromOK's Avatar
Senior Member with 1,947 posts.
 
Join Date: Mar 2001
Location: Oklahoma
Experience: idiota de la aldea
02-Apr-2005, 05:56 PM #2
Hey DarkCrystal,

Unless the MS DOS utility "choice.com" (or some other similiar util) is available, there's no way to accept user input in a batch file.

You can however make a simple command line batch file that can be called by the batch file name, the computer number, and the message. Here's a simple example you can save as "NS.bat" (or whatever):
Code:
@ECHO OFF
rem -- %1 is the first (computer number) parameter, %2 is the second (message)
rem -- parameter. The message should be quoted so each word won't be counted as
rem -- separate parameters. %0 displays the name user typed to run the batch file.
if "%1"=="" goto ERROR
if "%2"=="" goto ERROR
NET SEND th-2156-%1 %2
goto END

:ERROR
  cls
  echo.
  echo.
  echo     Usage: [this batch file name] [computer number] [message (in quotes)]
  echo.
  echo     Example: %0 100a "this is a test"
  echo.
  echo.

:END
If "choice.com" is available, let me know and we can do a batch file more like you asked for.

Cheers, Mac
__________________
MacFromOK : PC User
Do I have all the answers?
I don't even have all the questions!

____________________________________________________________

Last edited by MacFromOK : 02-Apr-2005 06:36 PM.
DarkCrystal's Avatar
Member with 51 posts.
 
Join Date: Jan 2005
Location: Wales, MA
Experience: spec=security.hardware;adv=soft;int=network
06-Apr-2005, 01:04 PM #3
Mac:

Thanks for the reply. Sorry for my delayed reply. Your help was fantastic, but I have already created a batch file (a few hours of reading involved). It is rather efficient as well. For your use, if you so desire, the code is below:

@ECHO OFF
set name=%1
set msg=%2
net send th-2156-mm%name% %msg%

All one would do is set the PATH to the folder MSG.BAT is located in, and then one can just type "msg 4 Testing msg.bat program." where "msg" is the .BAT file, "4" is the %name% value, and "Testing..." is the %msg% value.

However, if you can provide assistance in making it so that one can enter a time to NET SEND, or multiple times to NET SEND, that would be excellent. The command format to do this would be:
AT hh:mm NET SEND %name% %msg%

Sorry for any inconvience this made, and thanks again.
DarkCrystal
__________________
Templin, Bryan M.
PVT, U.S. Army, ADA
14J10(Q3), 01-06 D.H.G.
Fort Bliss, TX

Laptop Specs:
Brand: ACER Ferrari WLMi 4005
CPU: AMD Turion64 ML-37 2.0GHz 1MB Cache
RAM: 1GB DDR PC2700 333MHz
HD: 100GB
Video: ATI Radeon Mobility X700 128MB LCD/TFT/WSXGA 15.4" 1680x1050
Devices: Dual Layer DVD+-RW, Sound Blaster Audigy 2 ZS, 5-in-1 Media Card Slot
LAN: 10/100/1000 Integrated (RJ45) & Wireless, 2.4GHz Bluetooth, 4MBps Infrared, 56KBps Modem
OS: WIN XP Pro SP2

Custom Built PC
MacFromOK's Avatar
Senior Member with 1,947 posts.
 
Join Date: Mar 2001
Location: Oklahoma
Experience: idiota de la aldea
06-Apr-2005, 07:37 PM #4
Quote:
Originally Posted by DarkCrystal
Thanks for the reply. Sorry for my delayed reply. Your help was fantastic, but I have already created a batch file (a few hours of reading involved). It is rather efficient as well. For your use, if you so desire, the code is below:

@ECHO OFF
set name=%1
set msg=%2
net send th-2156-mm%name% %msg%
Actually you could skip the var assignment and just use %1 and %2.

Quote:
However, if you can provide assistance in making it so that one can enter a time to NET SEND, or multiple times to NET SEND, that would be excellent. The command format to do this would be:
AT hh:mm NET SEND %name% %msg%
Unfortunately this is not possible without another utility.

You can however make this easier to use if you send more than one message to the same recipient. Just use the message as the first parameter, and make it so the %name% var is only reset when a second parameter is used. This does assume you keep the DOS session open though, otherwise the %name% var will be lost.
Code:
@ECHO OFF
if not "%2"=="" set name=%2
net send th-2156-mm%name% %1
Lol, just make sure ya don't send something embarrassing to the wrong person...

Cheers, Mac
__________________
MacFromOK : PC User
Do I have all the answers?
I don't even have all the questions!

____________________________________________________________
DarkCrystal's Avatar
Member with 51 posts.
 
Join Date: Jan 2005
Location: Wales, MA
Experience: spec=security.hardware;adv=soft;int=network
07-Apr-2005, 04:51 PM #5
Awesome! Thanks you very much. And now for my final request. I have found a slight bug in this system, but I'm pretty sure there's a way around. Just haven't read up to it yet...lol.

So here it is:
If I were to type "msg 4 this is a test", computer 4 would only get "this"
in order to send a full message, i must type "msg 4 this.is.a.test" and computer 4 will then recieve "this.is.a.test" Is there any way around this where I can use spaces, rather than using a JavaScript imitation? If not, its no big deal, just a little inconvienence. I can adapt.

Thanks again.
DarkCrystal
__________________
Templin, Bryan M.
PVT, U.S. Army, ADA
14J10(Q3), 01-06 D.H.G.
Fort Bliss, TX

Laptop Specs:
Brand: ACER Ferrari WLMi 4005
CPU: AMD Turion64 ML-37 2.0GHz 1MB Cache
RAM: 1GB DDR PC2700 333MHz
HD: 100GB
Video: ATI Radeon Mobility X700 128MB LCD/TFT/WSXGA 15.4" 1680x1050
Devices: Dual Layer DVD+-RW, Sound Blaster Audigy 2 ZS, 5-in-1 Media Card Slot
LAN: 10/100/1000 Integrated (RJ45) & Wireless, 2.4GHz Bluetooth, 4MBps Infrared, 56KBps Modem
OS: WIN XP Pro SP2

Custom Built PC
MacFromOK's Avatar
Senior Member with 1,947 posts.
 
Join Date: Mar 2001
Location: Oklahoma
Experience: idiota de la aldea
07-Apr-2005, 06:44 PM #6
Enclose the message sent in quotes when you type it:

msg 4 "this is a test"

Without quotes, DOS splits the parameters by spaces as follows:

%0 = msg
%1 = 4
%2 = this
%3 = is
%4 = a
%5 = test

You could send the message (in the batch file) as:

%2 %3 %4 %5 %6 %7 %8 %9

but your messages would have to be short since params only go to %9.

Cheers, Mac
__________________
MacFromOK : PC User
Do I have all the answers?
I don't even have all the questions!

____________________________________________________________
DarkCrystal's Avatar
Member with 51 posts.
 
Join Date: Jan 2005
Location: Wales, MA
Experience: spec=security.hardware;adv=soft;int=network
08-Apr-2005, 09:56 AM #7
geez. such simple remedy. I have this habit of overlooking the easy solutions. lol. thanks so much. this is why i love this site. there's always an answer out there.

Thanks again,
DarkCrystal
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 08:30 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.