Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


Sign in to follow this  
MICHELLIN

Delete shortcuts

Recommended Posts

hi

after successful installation of os i want to delete shortcuts from desktop.

how do i do it in batch mode

e.g del %userprofile%\desktop\real.lnk

tnks

Edited by MICHELLIN

Share this post


Link to post
Share on other sites

The following script will delete all the desktop shortcuts.

NoDeskLnk.vbs

Const DSK = &H10&
Const ADT = &H19&

Set oShell = CreateObject("Shell.Application")
Set FSO=CreateObject("Scripting.FileSystemObject")

Set oFolderItem = oShell.Namespace(DSK).Self
FSO.DeleteFile oFolderItem.Path & "\*.lnk", true

Set oFolderItem = oShell.Namespace(ADT).Self
FSO.DeleteFile oFolderItem.Path & "\*.lnk", true

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 code

works like a charm......

tnks again

Edited by MICHELLIN

Share this post


Link to post
Share on other sites
The following script will delete all the desktop shortcuts.

NoDeskLnk.vbs

Const DSK = &H10&
Const ADT = &H19&

Set oShell = CreateObject("Shell.Application")
Set FSO=CreateObject("Scripting.FileSystemObject")

Set oFolderItem = oShell.Namespace(DSK).Self
FSO.DeleteFile oFolderItem.Path & "\*.lnk", true

what 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

Share this post


Link to post
Share on other sites

Or, to use a batch file to do the same thing:

cd /d %userprofile%\desktop
del /F /Q *.lnk
cd /d %allusersprofile%\desktop
del /F /Q *.lnk

or

cd /d %userprofile%\desktop
mkdir folder
move /Y *.lnk "%userprofile%\desktop\folder"

to move to another folder

Edited by Idontwantspam

Share this post


Link to post
Share on other sites
Const DSK = &H10&

Set oFolderItem = CreateObject("Shell.Application").Namespace(DSK).Self
CreateObject("Wscript.Shell").CurrentDirectory = oFolderItem.Path

Set FSO=CreateObject("Scripting.FileSystemObject")

If Not FSO.FolderExists("Shortcut Folder") Then
FSO.CreateFolder "Shortcut Folder"
End If

FSO.CopyFile "*.lnk", "Shortcut Folder", true
FSO.DeleteFile "*.lnk"

MovDskSht.cmd

@Echo off & Setlocal enableextensions
Set "_=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.

Share this post


Link to post
Share on other sites

Thanks for the help :)

one more question

to move/delete multiple shortcuts

do 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 work

it creates the shortcut folder but doesn't copy the shortcut to it and doesn't delete it

it gives a runtime error on line 8 key 1 (key might be another word cause i had to translate it from dutch)

</Edit>

Edited by Yzöwl
Quote appended from unsolicited PM

Share this post


Link to post
Share on other sites

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 says

If Not FSO.FolderExists("Shortcut Folder") Then
And 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 either

  1. The shortcuts are not where you thought they were!
    Common Desktop, not Desktop for instance
  2. The shortcuts have 'not normal' attributes!
    read only or system files
  3. You are using a different setup to mine
    Please let us know your OS, script host version etc. before requesting solutions

Keep the topic informed of your progress please!

Share this post


Link to post
Share on other sites

EDIT : nvm, i found the error

FSO.CopyFile "*.lnk", "Shortcut Folder", true

has to be

FSO.CopyFile "*.lnk", "Shortcut Folder\", true

Edited by Daimao

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Just using xp pro sp3(dutch language)

if i don't add the \ after the name of the shortcut folder it simply won't work

always acces denied

do these scripts still work on vista btw?

Edited by Yzöwl
Removed additional question asked elsewhere!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...