I am trying to make an easy messenger program for our office. I'm not sure what I am missing, but everytime I try running the code for options, it just messages my computer and not the one I am trying to message. I am able to message the other computer if I don't have the easy options. Please Help!
I would like to just choose a number and have the program paste that choice to the prompt. ex the user chose 1, that is person a (code for person a is /server:ECRCL). The code "/server:ECRCL" is now showing on the prompt for the "c" in the msg code. (%c% %m%)*
Here is my code:
@echo off
Title Doodle's Messenger Program
echo Messenger
chdir /
echo Select a Person
echo 1) Person a
echo 2) Person b
echo 3) Person c
echo 4) Person d
:START
echo ========================================
set /p c=Choose the number of the person you would like to message:
if %c%=="1" echo /server:ECRCL
if %c%=="2" echo /server:ECRCB
if %c%=="3" echo /server:ECRCCI
if %c%=="4" echo /server:ECRCCO
:A
set /p m=Message:
msg * %c% %m%
GoTo A
:1
: echo %/server:ECRCL /time:300 /v /w%
:2
:/server:ECRCB
:3
:/server:ECRCCI
:4
:/server:ECRCCO
The following script does work for messaging but I would like to make it easier for others with typing 1
, 2
, 3
, or 4
@echo Copy one of the following computers you would like to message and paste it where it asks for the computer name.
@echo person a - /server:ECRCL
@echo person b - /server:ECRCB
@echo person c - /server:ECRCCI
@echo person d - /server:ECRCCO
:START
set /p c=Enter Selection:
:A
set /p m=Message:
msg * %c% %m%
GoTo A
Here's an example which may assist you.
@Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
Title Doodle's Messenger Program
Set "msg=%SYSTEMROOT%\System32\msg.exe"
If %PROCESSOR_ARCHITECTURE:~-2% Equ 86 If Defined PROCESSOR_ARCHITEW6432 Set "msg=%SYSTEMROOT%\SysNative\msg.exe"
For %%G In ("%msg%") Do If "%%~aG" Lss "-" (Set "msg=") Else If "%%~aG" GEq "d" Set "msg="
If Not Defined msg (Echo Error! The system file msg.exe is missing.
"%__AppDir__%timeout.exe" /T 3 /NoBreak 1> NUL
GoTo :EOF)
:Start
Echo(
Echo Messenger Selection List
Echo 1. Viktor [//ECRCL]
Echo 2. Rashi [//ECRCB]
Echo 3. Kian [//ECRCCI]
Echo 4. Cedric [//ECRCCO]
Echo(
"%__AppDir__%choice.exe" /C 1234 /N /M "Enter the number for the user you would like to message."
If %ErrorLevel% Equ 1 Set "Svr=ECRCL"
If %ErrorLevel% Equ 2 Set "Svr=ECRCB"
If %ErrorLevel% Equ 3 Set "Svr=ECRCCI"
If %ErrorLevel% Equ 4 Set "Svr=ECRCCO"
:AskMessage
Set "m="
Set /P "m=Please type your message, then press the enter key>"
If Not Defined m (
Echo Empty messages are not allowed!
"%__AppDir__%timeout.exe" /T 2 /NoBreak 1> NUL
GoTo AskMessage
)
%msg% * /server:%svr% %m%
GoTo Start