My file C:\\testing\\file.exe
is deleted but the shortcut remains on desktop.
How do i delete the shortcut using .bat file ?
It works if i manually delete but i have to write a .bat file with some updates and other users will run the same script in their laptop.
This is the command which i have in my .bat file
REM delete the old shotcut lnk file
del "C:\Users\Public\Desktop\fileshortcut.lnk"
you can check the shortcutjs.bat .With the -examine
switch you can list a shortcut properties.If you have shortcut in the same directory use this:
@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%"
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.