[英]How to delete a shortcut if a file does not exists in a Windows .BAT file?
我的文件C:\\testing\\file.exe
被刪除,但快捷方式保留在桌面上。
如何使用.bat文件刪除快捷方式?
如果我手動刪除,但我必須編寫一個.bat文件並進行一些更新,並且其他用戶將在其筆記本電腦中運行相同的腳本,則它可以工作。
這是我在.bat文件中擁有的命令
REM delete the old shotcut lnk file
del "C:\Users\Public\Desktop\fileshortcut.lnk"
您可以檢查快捷方式 js.bat。使用-examine
開關可以列出快捷方式屬性。如果在同一目錄中有快捷方式,請使用以下命令:
@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%"
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.