Script to delete unwanted LoadRunner vugen files

Today it was quiet on the performance testing front so I had time to create a vbscript to delete unwanted loadrunner vugen files.

The script is run from the cscript command and will be prompted for the folder for your loadrunner vugen script. It deletes .log, .idx and .txt files and make sure you have closed vugen before you run the script.


On Error Resume Next
Const WINDOW_HANDLE = 0
Const BIF_EDITBOX = &H10
Const BIF_NONEWFOLDER = &H0200
Const BIF_RETURNONLYFSDIRS = &H1
Set objShell = CreateObject("Shell.Application")
Set wshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'**Browse For Folder To Be Processed
strPrompt = "Please select the folder to process."
intOptions = BIF_RETURNONLYFSDIRS + BIF_NONEWFOLDER + BIF_EDITBOX
strFolderPath = Browse4Folder(strPrompt, intOptions, strTargetPath)

Set fso=CreateObject("Scripting.FileSystemObject")

For Each file In fso.GetFolder(strFolderPath).Files
strExtension = Right(file.Name,4)
If strExtension = ".log" Or strExtension = ".idx" Or strExtension = ".txt" Then
Wscript.Echo file.Name
file.Delete
End If
Next

Function Browse4Folder(strPrompt, intOptions, strRoot)
Dim objFolder, objFolderItem
On Error Resume Next
Set objFolder = objShell.BrowseForFolder(0, strPrompt, intOptions, strRoot)
If (objFolder Is Nothing) Then
Wscript.Quit
End If
Set objFolderItem = objFolder.Self
Browse4Folder = objFolderItem.Path
Set objFolderItem = Nothing
Set objFolder = Nothing
End Function

Thanks to SaswatPadhi for the orginal code to prompt for the folder and list the files.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s