Solved

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

Posted on 2014-10-27
8
443 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 24

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 500 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 25

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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

679 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