Removing Desktop Icons

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 8 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

Re: Removing Desktop Icons

Post by dan.potter »

use remove-item for both the shortcut and the file.

PS H:\> gci $ENV:USERPROFILE\desktop


Directory: C:\Users\\desktop


Mode LastWriteTime Length Name
---- ------------- ------ ----

-a--- 8/24/2015 8:31 AM 1122 service request form SC.lnk
-a--- 8/24/2015 8:30 AM 11249 service request form.docx
-a--- 3/9/2015 7:51 AM 5729 ts.exe - Shortcut.lnk


PS H:\> Remove-Item $ENV:USERPROFILE\Desktop\'Service Request Form.docx'
PS H:\> gci $ENV:USERPROFILE\desktop


Directory: C:\Users\\desktop


Mode LastWriteTime Length Name
---- ------------- ------ ----

-a--- 8/24/2015 8:31 AM 1122 service request form SC.lnk
-a--- 3/9/2015 7:51 AM 5729 ts.exe - Shortcut.lnk




PS H:\> Remove-Item $ENV:USERPROFILE\Desktop\'Service Request Form sc.lnk'
PS H:\> gci $ENV:USERPROFILE\desktop


Directory: C:\Users\\desktop


Mode LastWriteTime Length Name
---- ------------- ------ ----

-a--- 3/9/2015 7:51 AM 5729 ts.exe - Shortcut.lnk




Also I had no issue moving a shortcut to my recycle bin after the file had been deleted. Can you post the error message?
This topic is 8 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked