Using this very simple\straight foreward vbscript, you can cycle through all currently running processes and kill the one you name below.

This can be handy if you have an application/instance which has become non responsive, such as IE when loading flash based pages maybe…

  strComputer = "."  Set objWMIService = GetObject("winmgmts:" _      & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")    Set colProcessList = objWMIService.ExecQuery _      ("Select * from Win32_Process Where Name = 'iexplore.exe'")  	resp = msgbox("All internet explorer windows must be closed in order to continue" & vbCrLf & "Click Yes to close them now or No to cancel", vbYesNo)  	  For Each objProcess in colProcessList  If resp = vbNo Then  		'Nothing To do  	Else  		objProcess.Terminate()  	End If  Next  
Tagged with:  

I was recently approached by one of my colleagues with a dilema, he had to go round our 30+ servers and stop and start a couple of Sophos’s Windows Services.

Now, as you can imagine this was starting to look like a fairly large and mundane task. Which is when I came up with this little VBScript.

Using this script below, you can pass it a text file with a list of machines you would like it to perform the process on.

In the script below you will see a “” change this to your text file containing machines, full file path.

The format of the text file is one machine per line.

This script is by no means ‘bullet proof’ and could be enhanced easily with little time and effort. It could also be modfied to stop\start any services you like.

Const ForReading = 1    Set objFSO = CreateObject("Scripting.FileSystemObject")  Set objTextFile = objFSO.OpenTextFile _      ("", ForReading)    Do Until objTextFile.AtEndOfStream      strComputer = objTextFile.Readline    	Set objWMIService = GetObject("winmgmts:" _  	    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")    	Set colServiceList = objWMIService.ExecQuery _  	    ("Select * from Win32_Service where Name='Sophos Message Router'")    	For Each objService in colServiceList  	    errReturn = objService.StopService()  	    WScript.Echo errReturn  	Next    	Wscript.Sleep 20000    	Set colServiceList = objWMIService.ExecQuery _  	    ("Select * from Win32_Service where Name='Sophos Message Router'")    	For Each objService in colServiceList  	    errReturn = objService.StartService()  	    WScript.Echo errReturn  	Next    Loop
Tagged with:  

I was approached a few days ago to develop a solution for monitoring access to a folder on a server (with auditing enabled). My first approach was to try and monitor the files last access time, but I found this to be somewhat unreliable. So my next method was to monitor the systems event logs. This proved much more reliable. If not a little too much at times.

Drop the code below in a .vbs file, execute and sit back and relax.

  strComputer =  'TODO: Enter the servers name here  Set objWMIService = GetObject("winmgmts:" _  & "{impersonationLevel=impersonate, (Security)}!\\" & _  strComputer & "\root\cimv2")    Set colMonitoredEvents = objWMIService.ExecNotificationQuery _  ("Select * from __instancecreationevent where " _  & "TargetInstance isa 'Win32_NTLogEvent' " _  & "and TargetInstance.EventCode = '560' " ) 'TODO: modify the event code to fire on what ever you require    Do  Set objLatestEvent = colMonitoredEvents.NextEvent  strAlertToSend = objLatestEvent.TargetInstance.User _  & " has accessed a folder on a server"   'TODO: Modify the alert you would like to receive  Wscript.Echo strAlertToSend    Set objEmail = CreateObject("CDO.Message")    objEmail.From = 'TODO: Specify a from address  objEmail.To = 'TODO: Enter a To address  objEmail.Subject = strAlertToSend  objEmail.Textbody = strAlertToSend  objEmail.Configuration.Fields.Item _  ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2  objEmail.Configuration.Fields.Item _  ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _  'TODO: Specify your mail servers name here  objEmail.Configuration.Fields.Item _  ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25  objEmail.Configuration.Fields.Update  objEmail.Send  Loop  
Tagged with:  

The following vbs script will list all of the currently installed Microsoft Hotfixes as per their KB number, a brief description, there installation date and who it was installed by. You may want to pass the computer name, to check a remote computer. Leaving as is will run the scan on the local machine.

Also you may find it beneficial to output this to an excel spreadsheet or a CSV etc.

  strComputer = "."  Set objWMIService = GetObject("winmgmts:" _      & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")    Set colQuickFixes = objWMIService.ExecQuery _      ("Select * from Win32_QuickFixEngineering")    For Each objQuickFix in colQuickFixes      Wscript.Echo "Computer: " & objQuickFix.CSName  
Tagged with:  

Active directory can be a bit of a beast if not managed and maintained correctly. Using this code in a .vbs file you can output all currently disabled accounts.

You may want to expand this by using the file system object to output to a file?

  Const ADS_UF_ACCOUNTDISABLE = 2     Set objConnection = CreateObject("ADODB.Connection")  objConnection.Open "Provider=ADsDSOObject;"  Set objCommand = CreateObject("ADODB.Command")  objCommand.ActiveConnection = objConnection  objCommand.CommandText = _      ";(objectCategory=User)" & _          ";userAccountControl,distinguishedName;subtree"    Set objRecordSet = objCommand.Execute     intCounter = 0  Do Until objRecordset.EOF  
Tagged with:  
Page 1 of 3123

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!