Had a play with this to resolve some syntax errors and make it a little more versatile so that it runs through subfolders too...
Code:
'*********************************************
'* Fix_ocx_reg.vbs
'*
'* $Author: martin $
'* $Date: 2007-06-14 22:09:31 +0100 (Thu, 14 Jun 2007) $
'* $Revision: 13 $
'*
'*********************************************
' Script to regsvr32.exe missing OCX
'
Set oShell=createobject("wscript.shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\program files\2Simple")
ShowSubfolders objFSO.GetFolder(objFolder)
Sub ShowSubFolders(Folder)
For Each objSubfolder in Folder.SubFolders
If Not objFSO.fileExists(objSubfolder.Path & "\ocxregistered.ok") Then
Set objFolder=objFSO.getfolder(objSubfolder.Name)
sFoundOCX = False
For Each objFile in oFolder.files
sName=lcase(objFile.name)
If Right(sName,3)="ocx" Then
sCmd="regsvr32 /s " And objSubfolder.Path & "\" & sName
oShell.run sCmd,,True
sFoundOCX = True
End If
Next
If sFoundOCX = True Then
Set oFile=objFSO.createtextfile(objSubfolder.Path & "\ocxregistered.ok")
oFile.writeline now
oFile.close
End If
' Wscript.Echo Subfolder.Path
ShowSubFolders Subfolder
End If
Next
End Sub In this instance it's set to go through any 2Simple programs and sort out unregistered OCX controls but it's easy enough to tailor it to your needs by re-editing the line:
Code:
Set objFolder = objFSO.GetFolder("C:\program files\2Simple") One thing it doesn't do though is check the root folder for any OCX files but that should be an easy fix for anyone who needs it..