VBScript? to display message on all computers in domain that are running a specific exe

We have some software that runs on our network with only 25 user licenses. When all are in use the next person who tries to use it cannot log in to it.

That work fine until we have people who leave a session open on their system and forget about it.

I want to be able to display a message to all users on our local domain, who currently have that program running, and ask them to log out if they have finished using it.

Any thoughts on how I might tackle this would be welcome. ( I was thinking a vbscript that I could run from my machine, but I am open to suggestions)


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shane Russell2nd Line Desktop SupportCommented:
Look here :


Which has the following script :

strComputer = "FullComputerName"       '<-- You can use an InputBox here instead so it prompts you
strDomain = "DOMAIN"              '<-- Put your FQDN in here
strUser = InputBox("Enter user name")    '<-- You could hard code this in
strPassword = InputBox("Enter password")    '<-- you could hard code this in
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer(strComputer, _
    "root\CIMV2", _
    strUser, _
    strPassword, _
    "MS_409", _
    "ntlmdomain:" + strDomain)
Set colProcessList = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_Process WHERE Name = 'notepad.exe'")   '<-- Change the name of the process name
For Each objProcess in colProcessList

If you need any more help please post back.
Shane Russell2nd Line Desktop SupportCommented:
duanelitchfieldAuthor Commented:
Whoa - I need to clarify a bit here I think.

The script you posted wil terminate the target process on the machine it is found on.

I just want to put up a message on THAT computer asking them to close the target app if they are not currently using it.

If I replace the line

objProcess.Terminate() with

msgbox("Please close notepad.exe if you are not using it")

I get a message box on the machine I ran the script on not the one that notepad.exe was found on.

Hope that makes more sense.

Thanks & regards,

Shane Russell2nd Line Desktop SupportCommented:
If I am right, I think you have to have the messenger service enabled and use net send

to get that to work you would need something like so

Set objShell = CreateObject("Wscript.Shell")

objShell.Run "cmd.exe"
wscript.sleep 250
wscript.sendkeys "Net Send " & strComputer & " " & strDomain

or something to that extent , take a look here :

NET SEND {name | * | /DOMAIN[:name] | /USERS} message
Sends messages to other users, computers, or messaging names on the network. The Messenger service must be running to receive messages.

You can send a message only to an name that is active on the network. If the message is sent to a username, that user must be logged on and running the Messenger service to receive the message.

name       Is the username, computername, or messaging name to send the message to. If the name is a computername that contains blank characters, enclose the alias in quotation marks (" ").
*       Sends the message to all the names in your group.
/DOMAIN[:name]        Sends the message to all the names in the workstation domain. If name is specified, the message is sent to all the names in the specified domain or workgroup.
/USERS       Sends the message to all users connected to the server.
message       Is text to be sent as a message.

which I got from here :


and also the code project example ( which has source code )


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Hi Duane,

I think Shane (gecko) just forgot to substitute the "net send" for the "terminate" code in the example script.  His idea should work, but you will need to wrap some more code around it.  Specifically, you need to iterate through a list of computer names and run the code against each one of them to see if that machine is currently running the executable in question.  That can be accomplished by enumerating all the computers in Active Directory... but, if you have very many machines it could take a considerable amount of time to query them all.  This will be especially true if some of those computers might be powered off at the time you run this script but that can be partially compensated for by pinging each machine prior to attempting the WMI query.  

Another approach might be possible... if the launch-process for this licensed app can be modified (such as placing it in a batch file and pointing desktop icons to the batch file) to create/write a filename consisting of just the computername to a common shared directory each time a user launches the app then this script can locate all those files with the current date and use that list to send the message to.  This could significantly reduce the amount of time the script has to spend querying the remote machines.

Let us know if you think that might work and also if you need any assistance with the script itself.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.