Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

A script batch to send a Message to WKS in the LAN

Posted on 2014-10-27
8
Medium Priority
?
473 Views
Last Modified: 2014-10-29
i need a batch script to send an Alert message to One or many computers in the LAN

the script should take some variables that the user will key in which are:
The Number of WKS to send the message (Var  1)
The Names of the WKS to send the messages (Var2)
The Message to be sent (Var "3)

and the script will use the command msg to send var 3 to WKS in VAr 2

I hope i made this clear . the script should be enough User friendly that why I see a dialogue to collect the variables

Thx
0
Comment
Question by:gazambey
8 Comments
 
LVL 25

Expert Comment

by:NVIT
ID: 40407161
What is Number of WKS for?

How about this?
set /p NumWKS=Number of WKS?
set /p NameWKS=Name of WKS?
set /p Msg=Message?
msg %NameWKS% %Msg%

Open in new window

0
 
LVL 29

Accepted Solution

by:
becraig earned 2000 total points
ID: 40407164
powershell version:
If you want your script to run interactively you could go for comma separated values in your computername string. For example:
$message = read-host -prompt "type your message here"
$computername = Read-Host -Prompt "type a computername or multiple separated by comma"
$session = "*"
foreach ($computer in ($computername -split ',')) {
msg $session /server:$computer $message
}

Open in new window


If you want to have a parameterized script you could do something like this, allowing you to call this script with 1 or more computer names:
param (
[string]$Message,
[string[]]$ComputerName
[string]$Session = '*'
)
foreach ($Computer in $ComputerName) {
msg $session /server:$computer $message
}

Open in new window


Taken from:
http://powershell.com/cs/forums/p/13545/25028.aspx
0
 
LVL 26

Expert Comment

by:Lionel MM
ID: 40410506
What version of Windows do you want this to work on or do you have computers other than just Windows?
0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

Author Comment

by:gazambey
ID: 40410659
hello all my machines are Windows

Rgds
0
 

Author Comment

by:gazambey
ID: 40410660
Most of them are Windows 7
0
 
LVL 29

Expert Comment

by:becraig
ID: 40410964
Do neither of the two script options I provided above work for you ?
0
 

Author Comment

by:gazambey
ID: 40411077
Yes the scripts are working fine . I choose the Interactive one . The Only thing for certains Machines there is one Registry key that have to be changed otherwise there will be an error
0
 
LVL 29

Expert Comment

by:becraig
ID: 40411102
Is that something you need help with, or do you pretty much have a handle on it ?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question