なぜこれが起こっているのかわかりませんが、私が取り組んでいるこのバッチ スクリプトの else コマンドは、一度に 1 行ずつではなく、一度にすべて実行されているようです。助言がありますか?
set getprocesslistlocal=wmic process get name,processid,workingsetsize
echo Type the name of the remote machine to view processes of (or type local for local machine), and press Enter.
set /P remotemachine=
if %remotemachine%==local (
%getprocesslistlocal%
) else (
echo Type the user name to access %remotemachine% with, then press Enter.
set /P remoteuser=
echo Type the password for %remoteuser% on %remotemachine%, then press Enter. ^(Will be displayed in plaintext^)
set /P remotepassword=
wmic /node:%remotemachine% /user:%remoteuser% /password:%remotepass% process get name,processid
)
echo End of list.
pause
echo Type the process id to terminate and hit Enter.
set /P killid=
if %remotemachine%==local (
wmic process where processid="%killid%" call terminate
) else (
wmic /node %remotemachine% /user:%remoteuser% /password:%remotepass% process where processid="%killid%" call terminate
)
echo Process id %killid% terminated.
pause