"The way in which project requirements meet developers at our company is a WTF in and of itself," writes Kevin, "but suffice it to say that a certain developer was tasked with writing a Windows Service that would periodically review a list of files from the network and purge them if necessary."

"Of course, to this certain developer, 'Windows Service' means something that is left running on a desktop somewhere. In his world, VB6 is also a 'simpler, cleaner, and easier to use' platform, and thus is his platform of choice... to this day. Here's what he delivered after a couple days of work."

Option Explicit
Dim objFSO As FileSystemObject
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub Main()

   Dim objKillFolder As Folder, objFile As File
   Dim strIniFileLoc As String, strKillFileLoc As String
   Dim blnLoopEternal As Boolean
   
   On Error GoTo Oops:
   
   Set objFSO = New FileSystemObject
   
   blnLoopEternal = False
   Do Until blnLoopEternal = True
      'stop program for 1 minute
      Sleep 60000
      
      'get the location for the ini file
      strIniFileLoc = CreateFilePath("Lemming.ini")
      
      'get the loc folder to be searched from the ini file
      strKillFileLoc = GetPathFromIni(strIniFileLoc)
      
      'open the folder
      Set objKillFolder = objFSO.GetFolder(strKillFileLoc)
      
      'search all the files in the folder to see if they're on the list
      For Each objFile In objKillFolder.Files
         SearchListForFile objFile.Name, strKillFileLoc
      Next
   Loop
     
   Set objFSO = Nothing
   Exit Sub
Oops:
   WriteError Err.Number, Err.Description, "Main"
End Sub

Kevin continues, "my first reaction to the code was wondering how one might stop this 'service'? His response was simply 'just move or rename the Lemming.ini file'."

"After failing miserably to reason on other solutions, the code was deployed to production. After about the 50th page fault on the server, the 'service' was 'stopped' and promptly removed from existence.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!