Link to home
Start Free TrialLog in
Avatar of duanelitchfield
duanelitchfield

asked on

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)

regards,

Duane
Avatar of Shane Russell
Shane Russell
Flag of United Kingdom of Great Britain and Northern Ireland image

Look here :

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_process.asp

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
    objProcess.Terminate()
Next

If you need any more help please post back.
Avatar of duanelitchfield
duanelitchfield

ASKER

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,

Duane
ASKER CERTIFIED SOLUTION
Avatar of Shane Russell
Shane Russell
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial