Tangent: this is something the OS generally does better than VBA even using Windows Script Host objects.
For what it's worth, the following batch file produces CSV output with the desired information.
@echo off
@setlocal enableextensions enabledelayedexpansion
if "%~1" == "" (echo %0: missing starting directory & exit /B 1)
if "%~2" == "" (echo %0: missing search pattern & exit /B 2)
for /F "usebackq delims=" %%a in (`findstr /S /M /R "%~2" "%~1"\*`) do call :PROC "%%~a"
exit /B
:PROC
if not "%~x1" == "" (
for /F "usebackq tokens=2 delims==" %%b in (`assoc %~x1`) do (
for /F "usebackq skip=2 tokens=1,2,*" %%c in (`reg query HKCR\%%b /ve`) do set t=%%e
)
) else (
set t=no file association
)
echo "%~dp1","%~fs1","%~dps1","%t%"
My point in mentioning this is that you could keep batch files in ranges in very hidden worksheets, write them to disk and run them as needed, redirecting output to files when running them, opening or importing the files created, and finally deleting those ad hoc files.
Going on a different tangent, you could include a VBA project reference to the Windows Script Host (WSH), namely, scrrun.dll, to make its classes' properties and methods available in the VBA Editor as if they were built-in classes. Then you could use
Dim FSO As New FileSystemObject
as well as using the actual object types for all the WSH classes.
Bookmarks