Set objFSO = Wscript.CreateObject("Scripting.FileSystemObject") Set objShell = Wscript.CreateObject("Wscript.Shell") ' default: strparm = "c:" ' for context menu extension, use: ' 0 = "%1" ' strParm = LCase(Trim(WScript.Arguments(0))) ' for batch mode, use (without ending \ ): strparm = "c:\PROGRA~2\EmEditor" Set objFolder = objFSO.GetFolder(strParm) ' "%1" will *not* have the ending "\" in it strPath = objFolder.Path & "\" ' Mode: ' for re-registering a bunch at once 'strMode = "Batch" ' or not to see if an app is portable strMode = "Test" lngCount = 0 strOutput = "" For Each objFile In objFolder.Files ' 4 includes the beginning "." of extension Select Case UCase(Right(objFile.Name, 4)) Case ".DLL", ".OCX" Select Case strMode Case "Batch" objShell.Exec "c:\windows\system32\Regsvr32.exe /s " & strPath & objFile.Name Case "Test" Set objRetVal = objShell.Exec("c:\windows\system32\Regsvr32.exe " & strPath & objFile.Name) End Select lngCount = lngCount + 1 Case ".EXE" ' you can't do this because it would run the program Case Else End Select Next Set objFSO = Nothing Set objShell = Nothing varToUser = MsgBox("Done. " & lngCount & " attempts processed", VBInformation, "Register Automation Servers Context Menu Item")