簡単なバッチファイルを実行しようとしています。
@echo off <-- don't print this line or any of the preceeding lines to the console window.
pushd "K:\" <-- in the quoted directory
for %%j in (*) <-- for every file in the directory
do
if %%~zj <-- if the size of the file
lss 37000 <-- is less than 37k
del %%j <-- delete the file
popd <-- go back to original directory.
しかし、cmd.exe
でpushd
を試すとうまく実行されます。私は、何か簡単なことを見逃しているのでしょう。
何か思い当たることはありますか?
バッチファイルを起動するためにプログラムを使用し、バッチファイルが最初にcmd.exe /cを呼び出していない場合に起こります。pushd.exeはcmd.exeの下にあるビルトインコマンドです。しかし、プログラムがバッチファイルを呼び出すとき、バッチファイルは直接起動されます - cmd.exeはありません。
解決策です。解決策: これを実行する前に、cmd.exe /c を実行します。
つまり、deletelittlefiles.batを実行しているならば、cmd.exe /c deletelittlefiles.batに変更します。
ソースはこちら私はソフトウェアテストチームのラボマネージャーで、私たちのテストハーネスはcmd.exeで起動せずに実行することができますが、実行する必要はないのです。