MICHELLIN Posted May 2, 2008 Share Posted May 2, 2008 (edited) hiafter successful installation of os i want to delete shortcuts from desktop.how do i do it in batch modee.g del %userprofile%\desktop\real.lnktnks Edited May 2, 2008 by MICHELLIN Link to comment Share on other sites More sharing options...
Yzöwl Posted May 2, 2008 Share Posted May 2, 2008 The following script will delete all the desktop shortcuts.NoDeskLnk.vbsConst DSK = &H10&Const ADT = &H19&Set oShell = CreateObject("Shell.Application")Set FSO=CreateObject("Scripting.FileSystemObject")Set oFolderItem = oShell.Namespace(DSK).SelfFSO.DeleteFile oFolderItem.Path & "\*.lnk", trueSet oFolderItem = oShell.Namespace(ADT).SelfFSO.DeleteFile oFolderItem.Path & "\*.lnk", true Link to comment Share on other sites More sharing options...
engjcowi Posted May 2, 2008 Share Posted May 2, 2008 Hi There is a program included withing the tools package of Windows post installer. i cant remember the link sory but i fyou google it you will find it. You just run the program and it cleans your desktp of all shortcuts Link to comment Share on other sites More sharing options...
MICHELLIN Posted May 3, 2008 Author Share Posted May 3, 2008 (edited) Thanks Guys will try .vbs and let youknow if it works for me......10 min later..... deleted just the shortcuts i wanted {changing \*.lnk}and del last two lines in codeworks like a charm......tnks again Edited May 3, 2008 by MICHELLIN Link to comment Share on other sites More sharing options...
Daimao Posted May 3, 2008 Share Posted May 3, 2008 The following script will delete all the desktop shortcuts.NoDeskLnk.vbsConst DSK = &H10&Const ADT = &H19&Set oShell = CreateObject("Shell.Application")Set FSO=CreateObject("Scripting.FileSystemObject")Set oFolderItem = oShell.Namespace(DSK).SelfFSO.DeleteFile oFolderItem.Path & "\*.lnk", truewhat would i need to change in that script to move the shortcuts instead of deleting them?i want shortcuts from c:/docs and sett/user/desktop to desktop/folder Link to comment Share on other sites More sharing options...
Idontwantspam Posted May 4, 2008 Share Posted May 4, 2008 (edited) Or, to use a batch file to do the same thing: cd /d %userprofile%\desktopdel /F /Q *.lnkcd /d %allusersprofile%\desktopdel /F /Q *.lnkorcd /d %userprofile%\desktopmkdir foldermove /Y *.lnk "%userprofile%\desktop\folder"to move to another folder Edited May 4, 2008 by Idontwantspam Link to comment Share on other sites More sharing options...
Yzöwl Posted May 4, 2008 Share Posted May 4, 2008 Const DSK = &H10&Set oFolderItem = CreateObject("Shell.Application").Namespace(DSK).SelfCreateObject("Wscript.Shell").CurrentDirectory = oFolderItem.PathSet FSO=CreateObject("Scripting.FileSystemObject")If Not FSO.FolderExists("Shortcut Folder") Then FSO.CreateFolder "Shortcut Folder"End IfFSO.CopyFile "*.lnk", "Shortcut Folder", trueFSO.DeleteFile "*.lnk"MovDskSht.cmd@Echo off & Setlocal enableextensionsSet "_=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"For /f "tokens=3 delims= " %%# In ( 'Reg query "%_%" /v Desktop^|Find "_SZ"') Do ( Xcopy "%%#\*.lnk" "%%#\Shortcut Folder" /c/i/q/y>Nul && Del "%%#\*.lnk")where delims=<tab>Both methods take into account possible file/directory overwrites. Link to comment Share on other sites More sharing options...
Daimao Posted May 4, 2008 Share Posted May 4, 2008 (edited) Thanks for the help one more questionto move/delete multiple shortcutsdo i just copy the last two lines and change the filenamùe or can i put all the filesnames between "'s with ,'s<Edit>it doesn't workit creates the shortcut folder but doesn't copy the shortcut to it and doesn't delete itit gives a runtime error on line 8 key 1 (key might be another word cause i had to translate it from dutch)</Edit> Edited May 5, 2008 by Yzöwl Quote appended from unsolicited PM Link to comment Share on other sites More sharing options...
Yzöwl Posted May 5, 2008 Share Posted May 5, 2008 Firstly, please direct questions regarding topics to the topic itself, not as a Personal Message.If the VBS, I'm guessing that's what you're referring to by the error message you're stating, isn't working I'm suggesting that you've failed to either copy it correctly or use it according to the information you provided for me to write in in the first instance. I'm guessing that you've altered the file in some was since line 8 saysIf Not FSO.FolderExists("Shortcut Folder") ThenAnd as you've stated that folder has already been created, that line has already run.Please try running the script again, copied properly AND UNALTERED. If it doesn't work then it's likely that eitherThe shortcuts are not where you thought they were!Common Desktop, not Desktop for instanceThe shortcuts have 'not normal' attributes!read only or system filesYou are using a different setup to minePlease let us know your OS, script host version etc. before requesting solutionsKeep the topic informed of your progress please! Link to comment Share on other sites More sharing options...
Daimao Posted May 5, 2008 Share Posted May 5, 2008 (edited) EDIT : nvm, i found the errorFSO.CopyFile "*.lnk", "Shortcut Folder", truehas to beFSO.CopyFile "*.lnk", "Shortcut Folder\", true Edited May 5, 2008 by Daimao Link to comment Share on other sites More sharing options...
Yzöwl Posted May 5, 2008 Share Posted May 5, 2008 Don't use the word error incorrectly!There is no error, the script works fine for me, without adding or removing anything from its original content.I tested it prior to posting, as I usually do unless stated otherwise, and again after your PM!If you are using an Operating System or something else which differs from mine then it is your responsibility to inform me of that if you wish to improve the chances of a flawless solution to your problem.Thank you. Link to comment Share on other sites More sharing options...
Daimao Posted May 5, 2008 Share Posted May 5, 2008 (edited) Just using xp pro sp3(dutch language)if i don't add the \ after the name of the shortcut folder it simply won't workalways acces denieddo these scripts still work on vista btw? Edited May 6, 2008 by Yzöwl Removed additional question asked elsewhere! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now