We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


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

Medium Priority
Last Modified: 2008-02-01
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)


Watch Question

Shane Russell2nd Line Desktop Support

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 Support



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,

2nd Line Desktop Support
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 )


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
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.

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.