I wrote a batch file which looks through all the subdirectories of a directory, then copies the basename of the .exe file from each subdirectory, creates a desktop.ini file inside that subdirectory, and inserts the relative filename into it, (as the IconResource).
The problem is that the desktop.ini is created correctly, but only in one subdirectory. I need it to be created in all subdirectories of the initial directory, which should be the parent of the running batch file.
@echo off
for /d %%D in (*) do (
set "exefile="
for /f "delims=" %%F in ('dir /b /a-d "%%D\*.exe"') do (
set "exefile=%%F"
set "foldpath=%%D"
goto :next
)
:next
if defined exefile (
echo [.ShellClassInfo]>>"%foldpath%\desktop.ini"
echo ConfirmFileOp=0 >>"%foldpath%\desktop.ini"
echo IconResource=.\%exefile%>>"%foldpath%\desktop.ini"
echo IconIndex=0 >>"%foldpath%\desktop.ini"
attrib +s +h "%foldpath%\desktop.ini"
)
)
This is the entry in desktop.ini:
[.ShellClassInfo]
ConfirmFileOp=0
IconResource=.\AltTabTer.exe
IconIndex=0
How it works
Executing a batch file