Help With Msg Command Program

Intel CLONE
February 14, 2009 at 12:04:25
Specs: Windows XP, P4, 2040 mb
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



See More: Help With Msg Command Program

Report •


#1
February 16, 2009 at 06:17:54
use a loop

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


Report •

#2
February 16, 2009 at 07:20:02
@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


Report •

#3
February 17, 2009 at 09:45:59
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


Report •

Related Solutions

#4
February 18, 2009 at 00:31:57
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


Report •


Ask Question