8 replies
by sadj2885 Accepted solution
by rob miners Accepted solution
XP
@echo off
Set scut="C:\documents and settings"
del /s /q /f %scut%\name of shortcut.lnk
Vista
@echo off
Set scut=C:\users
del /s /q /f %scut%\name of shortcut.lnk
Edit: to add """
by rob miners Accepted solution
To obtain a list of Shortcuts from Documents and Settings run this. It will create a file on C:\> named SC.txt and it can be opened in NotePad.
@echo off
Set scut="C:\documents and settings"
dir /a /s %scut%\*.lnk >c:\sc.txt
by sadj2885 Accepted solution
Sorry forgot to mention. Just tried it, worked beautifully. Just one more question, if i want to delete multiple shortcuts i just add "del /s /q /f %scut%\name of shortcut.lnk" on the next line correct? Or do i need to type set scut...
And thanks for the quick responses.
by rob miners Accepted solution
@echo off
Set scut="C:\documents and settings"
del /s /q /f %scut%\100.lnk
goto A
:A
Set scut="C:\documents and settings"
del /s /q /f %scut%\echo.txt.lnk
goto B
:B
Set scut="C:\documents and settings"
del /s /q /f %scut%\Red Alert 3 Control Center.lnk
goto C
:C
Set scut="C:\documents and settings"
del /s /q /f %scut%\history.lnk
goto end
:END
The above sample will delete the first .lnk and then move on to the next command with the goto syntax and then delete the next .lnk and so on..........
You use the goto to go to the next set of instructions that you want to perform.
Depending on the amount of shortcuts that you want to remove will depend on the goto's that you will need to use. Also use the goto end to finish up the batch file. You could use wildcards but I find that it is dangerous and you could end up deleting all of the shortcuts.
Keep us informed as to your progress if you require further assistance. ;) :D
If you think that any of the posts that have been made by all TechRepublic Members, have solved or contributed to solving the problem, please Mark them as Helpful so that others may benefit from the outcome. ;) :D :-bd
How do I rate the answers to my posted Question?
Click on the answer. Click the Mark "Helpful" button displayed below the post. You may mark more than one answer as "Helpful."
The answers only have to be Helpful and don't necessarily have to be a definitive answer.
by rob miners Accepted solution
You will need two files and if you do it this way you will only have to modify delSC.txt for future use. Make sure that the text in delSC.txt has the double quotes surrounding it.
Copy between the -------- and paste this into NotePad and save it as SCdel.cmd
Save both files to C:\> and you can create a shortcut to the files to run or modify them.
------------------
set target="C:\documents and settings"
FOR /F " tokens=* " %%i in (delSC.txt) do del /s /q /f %target%\%%i
------------------
Contents of delSC.txt
"t1.txt"
"t2.txt"
and so on.........
eXample of the output:
C:\>set target="C:\documents and settings"
C:\>FOR /F " tokens=* " %i in (delSC.txt) do del /s /q /f "C:\documents and settings"\%i
C:\>del /s /q /f "C:\documents and settings"\"t2.txt"
Deleted file - C:\documents and settings\Administrator\Desktop\t2.txt
Deleted file - C:\documents and settings\All Users\Desktop\t2.txt
Deleted file - C:\documents and settings\black\Desktop\t2.txt
Deleted file - C:\documents and settings\blank\Desktop\t2.txt
Deleted file - C:\documents and settings\dave\Desktop\t2.txt
Deleted file - C:\documents and settings\jock\Desktop\t2.txt
Deleted file - C:\documents and settings\Rob\Cookies\t2.txt
Deleted file - C:\documents and settings\Rob\Desktop\t2.txt
C:\>del /s /q /f "C:\documents and settings"\"t1.txt"
Deleted file - C:\documents and settings\Administrator\Desktop\T1.txt
Deleted file - C:\documents and settings\All Users\Desktop\T1.txt
Deleted file - C:\documents and settings\black\Desktop\T1.txt
Deleted file - C:\documents and settings\blank\Desktop\T1.txt
Deleted file - C:\documents and settings\dave\Desktop\T1.txt
Deleted file - C:\documents and settings\jock\Desktop\T1.txt
Deleted file - C:\documents and settings\Rob\Cookies\T1.txt
Deleted file - C:\documents and settings\Rob\Desktop\T1.txt
C:\>pause
Press any key to continue . . .
Edit: modifed ws.txt to delSc.txt
and to add that it won't remove hidden links.
by sadj2885 Accepted solution
Set scut="C:\documents and settings"
del /s /q /f %scut%\"shortcut 1.lnk"
del /s /q /f %scut%\"shortcut 2.lnk"
del /s /q /f %scut%\"shortcut 3.lnk"
etc...
And it worked fine.
by rob miners Accepted solution
This discussion is closed to new replies.
Trending Software posts
Sort by Trending