Solved

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

Posted on 2014-10-27
8
434 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 23

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 28

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 24

Expert Comment

by:lionelmm
ID: 40410506
What version of Windows do you want this to work on or do you have computers other than just Windows?
0
 

Author Comment

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

Rgds
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

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

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 28

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now