0

目標: コンピューター内のすべての dll ファイルを regsvr32.exe に渡す

達成: cd\
::REM すべてのファイルとディレクトリ (/s) を c: のルートにある dir.txt というファイル名 (/b)
dir /s /b>>dir.txt
::REMのみのファイルにエクスポートします。 、これにはすべての拡張タイプが含まれます。必要なのは dll だけなので、それを dll.txt に見つけます:
findstr ".dll$" dir.txt>>dll.txt

キンク:

ここで、現在dll.txtにあるすべてのファイルをregsvr32.exe「ファイル」にしたい場合、各行に個別にあるすべてのファイル名を取得する必要があります。ファイルの各行を変数にエクスポートできるサードパーティのコマンド ライン ツールがあるかどうか疑問に思っていました。このようにして、次のことができました。

==========

::REM このツールには、行番号のスイッチ /l と、使用する変数のスイッチ /v:"" があり、最後に "file" を使用したと仮定します。

set line=1  
:loop  
set dll=  
tool.exe /l %line% /v:"dll" "dll.txt"  
::REM We if defined here because if the line doesn't exist in dll.txt, the tool would return nothing to %dll%
if not defined %dll% exit  
::REM With the variable defined, we can continue  
regsvr32.exe %dll%  
set /a line=%line%+1  
goto loop  

=======================

その後、ツールは自動的に終了するまでファイルの各行の各パスを処理します。これは、行がなくなるためです。ループの直後に、「定義されていない場合」が毎回機能するように、dll を何も設定しないことに注意してください。

このタイプのサードパーティ ツールが実行できない場合、for でそれを実行する方法はありますか?? 正直なところ、私はそれを学んだことはなく、しようとしましたが、決して理解できませんでした。

どんな助けでも大歓迎です!

これがすでに回答されている場合は申し訳ありません。

編集/更新: この作業を行う方法を発見しました。

おかげで: http://pyrocam.com/re-register-all-dlls-to-fix-no-such-interface-supported-error-in-windows-7-after-installing-ie7-standalone/
と :読むバッチファイルの行ごとのtxt

最初のリンクは、先頭を手動で regsvr32.exe に置き換えることを
示しています

コード:

@echo off
color 1f
title Register .dll
echo.
echo Exporting file list . . .
echo.
cd /d c:
cd\
if exist dll.txt del dll.txt
if exist dir.txt del dir.txt
if exist dll.bat del dll.bat
echo Part 1 of 3 . . .
echo.
dir /s /b>>dir.txt
echo Part 2 of 3 . . .
echo.
findstr ".dll$" dir.txt>>dll.txt
del dir.txt
echo Part 3 of 3 . . .
echo.
for /f "delims=" %%i IN ('type dll.txt') do echo regsvr32.exe /s "%%i">>dll.bat
del dll.txt
echo Ready to begin regsvr32.exe . . .
echo.
pause
echo.
echo Beginning registration . . .
echo *This will take time, close any popups that occur
echo.
call dll.bat
echo.
echo Deleting registration file . . .
if exist dll.bat del dll.bat
echo.
echo DONE.
echo.
pause >nul
4

1 に答える 1

1

必要なコマンドはですfor /f

for /f %%f in ('type dll.txt') do regsvr32.exe %%f

これは、の出力を受け取り、type dll.txt一度に1行ずつに入れ%%fます。%%fその後、他のコマンドの引数として使用できます。

以上のことをしたい場合はregsvr32.exe %%f、別のバッチファイルを作成して次のように呼び出すことができます。

for /f %%f in ('type dll.txt') do call process.bat %%f

次に、process.batはファイル名を。として受け取ります%1

于 2012-07-03T01:03:41.187 に答える