Solved

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

Posted on 2014-10-27
8
441 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
robocopy for today files 14 175
Folder replication and file move 3 74
bat script to open stickynote with text 3 103
Xcopy / Robocopy Question 7 68
Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

837 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