0
@echo off
title Remote Message
set /p input1= "Type the PC name: "
set pcname=%input1%
set /p input2=echo Type a message:
set msgmsg=%input2%
cmd msg /server:%pcname% */time:999 "%msgmsg%"
pause

Above is the batch script

how can I allow user input the pc name and the message he wanted to send remotely thru cmd? I tried 100times above code and keep modify but still not work.

4
  • remove the cmd command before the msg command (what it's supposed to do anyway?). Commented Aug 28, 2020 at 8:19
  • I often use remote desktop to user pc for troubleshooting..before I remote, I need to send a msg to user inform them...so I use cli msg Commented Aug 28, 2020 at 8:37
  • remove the cmd command before the msg will keep looping asking the input Commented Aug 28, 2020 at 8:38
  • uhh - how did you name your batch file? Commented Aug 28, 2020 at 9:04

1 Answer 1

1

No need to set variables from variables, and please do NOT name your batch file msg.bat or msg.cmd just call it something like send_message.cmd:

@echo off
title Remote Message
set /p "pcname=Type the PC name: "
set /p "msgmsg=Type a message: "
msg /server:%pcname% */time:999 "%msgmsg%"
pause
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.