Try this, change strProcName and strProcPath in lines 6 & 7 Also change the message in line 17 to suit.
Some applications, such as UltraVNC run 2 processes, so for something like that, change the 0 in line 16 This has only been tested on WinXP SP3, so YMMV on later OSs. Quick and nasty, but gets round the issue of the users being able to delete the lock file. I use PrimalScript for all my scripting and the handiest thing I use it for is to compile scripts in exe's so that the code can't be changed to increase the number, but I'm sure google would throw up some alternatives. --8<------------------------------------------------------------ Option Explicit Dim objWMIService, colProcesses, objShell Dim strProcName, strProcPath strProcName = "notepad.exe" strProcPath = "c:\windows\system32\" Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\.\root\cimv2") Set colProcesses = objWMIService.ExecQuery _ ("SELECT * FROM Win32_Process WHERE Name = " & _ "'" & strProcName & "'") If colProcesses.Count > 0 Then MsgBox "UltraVNC is already running." & vbCrLf & vbCrLf & "Only 1 instance is permitted at a time.", vbOK, "Process already running." Else Set objShell = CreateObject("WScript.Shell") objShell.Run strProcPath & strProcName Set objShell = nothing End If --8<------------------------------------------------------------ Regards Tony Patton Desktop Operations Cavan Ext 8078 Direct Dial 049 435 2878 email: tony.pat...@quinn-insurance.com From: "Joseph L. Casale" <jcas...@activenetwerx.com> To: "NT System Admin Issues" <ntsysadmin@lyris.sunbelt-software.com> Date: 01/06/2010 18:18 Subject: RE: Limit the amount of times an application can be opened? Only problem with that is permissions. If ?I? am launching the app, I am creating the lock file, which isn?t secure. If someone is clever, or even in an accidental situation this can be bypassed? From: John Aldrich [mailto:jaldr...@blueridgecarpet.com] Sent: Tuesday, June 01, 2010 9:24 AM To: NT System Admin Issues Subject: RE: Limit the amount of times an application can be opened? Use a batchfile to create a ?.lock? file and check for the existence of that file and if it exists, have the batch file exit. From: Craig Gauss [mailto:gau...@rhahealthcare.org] Sent: Tuesday, June 01, 2010 11:10 AM To: NT System Admin Issues Subject: Limit the amount of times an application can be opened? We have one application that is absolute resource hog. Unfortunately the users will open it over and over again, usually bringing the system to a crawl. It has been very difficult to train them to only open it once. Anyone have any ideas on how we could limit the amount of times it is opened? Craig Gauss, Technical Supervisor/Security Officer Riverview Hospital Association This e-mail is intended only for the addressee named above. The contents should not be copied nor disclosed to any other person. Any views or opinions expressed are solely those of the sender and do not necessarily represent those of QUINN-Insurance Limited (Under Administration), unless otherwise specifically stated . As internet communications are not secure, QUINN-Insurance Limited (Under Administration) is not responsible for the contents of this message nor responsible for any change made to this message after it was sent by the original sender. Although virus scanning is used on all inbound and outbound e-mail, we advise you to carry out your own virus check before opening any attachment. We cannot accept liability for any damage sustained as a result of any software viruses. ==================================================================== QUINN-Insurance Limited (Under Administration) is regulated by the Financial Regulator and regulated by the Financial Services Authority for the conduct of UK business. ==================================================================== QUINN-Insurance Limited (Under Administration) is registered in Ireland, registration number 240768 and is a private company limited by shares. Its head office is at Dublin Road, Cavan, Co. Cavan. This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
<<image/jpeg>>
<<image/jpeg>>