2016-06-02 8 views
2

マイファイルC:\testing\file.exeが削除されますが、ショートカットはデスクトップに残ります。ファイルがWindowsの.BATファイルに存在しない場合、ショートカットを削除する方法はありますか?

.batファイルを使用してショートカットを削除するにはどうすればよいですか?

手動で削除すると動作しますが、一部のアップデートで.batファイルを書き込む必要があり、他のユーザーはラップトップで同じスクリプトを実行します。

これはあなたが同じディレクトリの使用でこれをショートカットを持ってproperties.Ifショートカットを一覧表示することができます-examineスイッチ.With shortcutjs.batを確認することができ、私の.batファイルに私が持っているコマンド

REM delete the old shotcut lnk file 
del "C:\Users\Public\Desktop\fileshortcut.lnk" 

答えて

0

です:

@echo off 

:: Set the path to the shortcut you want to check 
set "shortcut=C:\Shortcut.lnk" 

for /f "tokens=1* delims=:" %%A in ('shortcutjs.bat -examine "%shortcut%"^|findstr /b /i "Target"') do (
    set "target=%%B" 
) 
echo %target% 
if not exist "%target%" (
    REM if the command is ok delete the ECHO word bellow 
    echo del /q /f "%shortcut%" 
) 
関連する問題