Computing.Net > Forums > Programming > Help With Msg Command Program

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.

Help With Msg Command Program

Reply to Message Icon

Name: Waylen
Date: February 14, 2009 at 12:04:25 Pacific
OS: Windows XP
CPU/Ram: P4, 2040 mb
Product: Intel / CLONE
Subcategory: Batch
Comment:

Hello,

I'm really new to scripting with batch files, and I'm working on a program for a messaging system on our terminal server network. I had three issues to overcome. The first was how to send a single message using the msg command to a group of users, How to send a message to all users, and the last one I can't solve, which is sending to 2 or 10 users by typing in their login names. I'm mostly using the msg command to create this system, but I can't figure out or find a way to use the msg command to do this. It only seems to be capable of sending to a @list.txt of users, a single user, or all users.

This is an example of what I'm trying to do in my script, but I can only send to one user. I need to figure out a way to send to 2 - 15 users by typing in their login account names. All of the account names are a 4 digit number, 1901, 1902, 1903, etc.

Script:
@echo off
:A
Cls
echo MESSENGER
set /p a=User:
set /p b=Message:
msg %a% /Server:ts1 %b%
Pause
Goto A

On the user I need to be able to do multiples.

I would be so thankful for any help.

Sincerely,
~Waylen




Sponsored Link
Ads by Google

Response Number 1
Name: reno
Date: February 16, 2009 at 06:17:54 Pacific
Reply:

use a loop

:loop
set a=
set /p a=user?
if "%a%" neq "" goto:loop


0

Response Number 2
Name: Mechanix2Go
Date: February 16, 2009 at 07:20:02 Pacific
Reply:

@echo off & setLocal EnableDelayedExpansion

:loop
echo sending msg to %1
shift
if not %1'==' goto :loop


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 3
Name: Waylen
Date: February 17, 2009 at 09:45:59 Pacific
Reply:

I can't seem to get it right guys. This is what I'm trying, where am I messing up? The loop repeats to let me enter new users in each loop, then I hit the enter key with no value for a and it goes to the message, but when I hit enter it says that the message doesn't exist.

@echo off
:A
Cls
echo MESSENGER

:loop
set a=
set /p a=user?
if "%a%" neq "" goto:loop

set /p b=Message:
msg %a% /Server:ts1 %b%
Pause
Goto A


0

Response Number 4
Name: Mechanix2Go
Date: February 18, 2009 at 00:31:57 Pacific
Reply:

By using neq you've got it looping around doing nothing.

====================================
@echo off

:A

:loop
set a=
set /p a=user?
if "%a%" equ "" goto :eof

set /p b=Message:
msg %a% /Server:ts1 %b%
Pause
Goto :A


=====================================
If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


parallel port progm. in a... For Loop in C



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Help With Msg Command Program

Help with my C++ program www.computing.net/answers/programming/help-with-my-c-program/1813.html

Help with making C++ Program www.computing.net/answers/programming/help-with-making-c-program/4217.html

Help with a C Program / Newbie www.computing.net/answers/programming/help-with-a-c-program-newbie/8071.html