Skip to main content

vbscript – Ensure single instance of the script running at time.

Following Sub allows to ensure that only one instance of the script is running at time. Usage: Call EnsureSingleInstance Code: Sub EnsureSingleInstance() dim svc, squery, ncount set svc=getobject(“winmgmts:root\cimv2″)     squery=”SELECT commandline FROM win32_process WHERE commandline LIKE ‘%” & wscript.scriptname & “%'”         ncount=svc.execquery(squery).count     set svc=nothing if ncount>1 then ‘ The script got executed […]

Read More

Script Event log creation

How to script Log Event creation? … By default the vbscript does not allow to log events with custom Source or custom Event ID; however the command line tool eventcreate does it.   Please find default and custom way of writing in Event Viewer log. ‘ ############ Event Types for LogInEV_A ‘ Ref: http://technet.microsoft.com/en-us/library/ee156617.aspx Const […]

Read More