これは、TeamViewer (任意のバージョン) サービス実行可能ファイルの位置を取得するための文字列です。
for /f "skip=1 delims=" %A in ('wmic path win32_service where "name like 'TeamViewer%'" get pathname') do set POSITION=%A
この問題はwmic
、結果の最後に空の行が含まれているため (Windows 7 コマンドで)、次の出力が原因で発生します。
C:\Users\giovanni>for /f "skip=1 delims=" %A in ('wmic path win32_service where "name like 'TeamViewer%
'" get pathname') do set POSITION=%A
:\Users\giovanni>set POSITION="C:\Program Files\TeamViewer\Version8\TeamViewer_Service.exe"
:\Users\giovanni>set POSITION=
C:\Users\giovanni>echo %position%
ECHO enabled.
実行可能ファイルの正しい位置で出力の 2 行目だけを取得するにはどうすればよいですか? (またはもちろん、最新の行をスキップします)。
よろしくお願いします。良い一日を。ジョバンニ。
これは checktv.bat です。
for /f "skip=1 delims=" %%A in ('wmic path win32_service where "name like 'TeamViewer%'" get pathname ^| findstr /r /v "^$"') do set POSITION=%%A
echo %POSITION%