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

WMIC – How to test WMI on a remote machine?

I was recently searching for a quick way of testing the WMI on remote machine. Apparently you can accomplish this task by using PowerShell or VBScript etc. However there seems to be much easier way. The Windows Management Instrumentation Command (WMIC) perfectly fits here. Following command allows checking the state of Server service on a […]

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

Class Tasks – Execute a Task or a Method after specified time elapsed.

Class Tasks – Execute a Task or a Method after specified time elapsed.

Parameters: Public Sub New(ByVal TaskName As String, ByVal ExecutionDelayTime As Integer, ByVal BlockCurrentThread As Boolean, Optional ByVal Message As String = “”) ExecutionDelayTime – Timer interval in milliseconds. (How long to wait before executing a task) TaskName – The name of the Task which will be chosen from Select Case statement BlockCurrentThread – If set […]

Read More