Monday, January 14, 2008

How to automatically delete unused folders?

Below is a Visual Basic Script that can delete all the sub folders older than 30days from the current date. The folder from which the sub folders need to be deleted can set by  changing the value for strMainFolder variable. This script can also be used to manage files and folder in remote computers just by setting the required computer name/IP to strComputer variable.

The script can be used very effectively by scheduling a job from Windows Task Scheduler.

strComputer = "."
strMainFolder = "C:\"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSubfolders = objWMIService.ExecQuery("Associators of" _
& {Win32_Directory.Name='" & strMainFolder _
& "'} Where AssocClass = Win32_Subdirectory ResultRole = PartComponent")

For Each objFolder in colSubfolders
   dtmFolderCreationDate= CDate(Mid(objFolder.CreationDate,5,2) _
    & "/" & Mid(objFolder.CreationDate, 7, 2) & "/" _
    & Left(objFolder.CreationDate, 4) & " " _
    & Mid (objFolder.CreationDate, 9, 2) & ":" _
    & Mid(objFolder.CreationDate, 11, 2) & ":" _
    & Mid(objFolder.CreationDate,13, 2))
    If (DateDiff("d",dtmFolderCreationDate,Now)>30) Then
    'Wscript.Echo objFolder.Name
    'Wscript.Echo objFolder.CreationDate 
    errResults = objFolder.Delete
    End If

-- Lakshminarasimha Mohan

In God I TRUST everything else I TEST.

Saturday, January 12, 2008

IE popup window disappears while QTP Script Execution!!

A strange problem of Mercury QuickTest Pro 9.2 with Internet Explorer 7.0 is discussed with solution.

Problem: While executing scripts in IE 7.0 if another browser is opened by the script as a result of an operation or test step, the pop up window automatically disappears. The issues looks strange but the window disappears without any clue.  

Due to this issue there are many other problems including problem in executing Navigate method of IE object etc., I have not tested it on IE6. However, the problem might also exist in IE6 as well.

Example scenario: A QTP 9.2 automation script for the following scenario in the admin mode of EPiServerCMS web site fails to execute on IE 7.0.

Steps for Simulation:

  1. Login to EPiServerCMS Admin Mode (Ensure that the Role and membership providers are set to Multiplexing providers with SQL Server providers as default provider)
  2. Click on Administer Groups
  3. Create a new Group
  4. Click on the Delete button corresponding to the newly created Group the pop up window disappears only when a QTP script for this scenario is executed. However, the scenario works perfectly fine on manual execution of the same steps.


Solution: The solution for this problem is just enable the "BHOManager Class" Add-on in the IE. (This can be done by going to IE-> Tools -> Manage Add-ons -> Enable/Disable Add-ons...)

What is "BHOManager Class" add-on or BHOManager.DLL?

A Browser Helper Object, or BHO, is just a small program that runs automatically every time the Internet explorer browser is started.

BHOManager.DLL is installed on the system when QTP is installed. This is a helper class that assists QTP for execution of QTP scripts on the browser. BHOManager.DLL is located in the folder C:\Windows\System32. The unique ID or CLSID of this BHO is {474264BC-9571-47C1-85B9-780F756DC9CE}.

Additional Information about BHOs:

BHOs are not stopped by personal firewalls, because they are identified by the firewall as browser itself. They are also known to conflict with other running programs, causing a variety of page faults, run time errors, and the like, and generally impede browsing performance.

BHODemon is small tool that can be used to view, enable or disable all the BHO's on a computer. It is a free tool that can be downloaded from BHODemon.

Other known BHOs:

The other known BHOs include the following:

  1. Microsoft.VisualStudio.QualityTools.RecorderBarBHO.dll - This BHO is used by Visual Studio Team Suite for web tests

For more information BHOManager.dll and other BHOs refer to