![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | empty recycle bin I need to write a simple script that will empty the recycle bin on a single desktop computer. -- Ryan Denver, CO |
My System Specs![]() |
| | #2 (permalink) |
| | RE: empty recycle bin This should work: $objShell = New-Object -Com Shell.Application $objFolder = $objShell.Namespace(0xA) $objFSO = New-Object -ComObject Scripting.FileSystemObject foreach ($item in $objFolder.Items()) { If ($item.type -eq "File Folder") { $objFSO.DeleteFolder($item.path) } Else { $objFSO.DeleteFile($item.path) } } "Ryan" wrote: Quote: > I need to write a simple script that will empty the recycle bin on a single > desktop computer. > -- > Ryan > Denver, CO |
My System Specs![]() |
| | #3 (permalink) |
| | Re: empty recycle bin One shortcut that can simplify this further is to use Remove-Item; that reduces it to a 2-line solution: $objShell = New-Object -Com Shell.Application $objShell.Namespace(0xA).Items() | Remove-Item -Recurse And in the obligatory "oh yeah, it can be a one-liner" form :(New-Object -Com Shell.Application).Namespace(0xA).Items()| ri -r "Mike Pfeiffer" <MikePfeiffer@xxxxxx> wrote in message news:A69F8DD8-F9B8-4AE0-ABF5-4A6D5C27AD0F@xxxxxx Quote: > This should work: > > $objShell = New-Object -Com Shell.Application > $objFolder = $objShell.Namespace(0xA) > $objFSO = New-Object -ComObject Scripting.FileSystemObject > > foreach ($item in $objFolder.Items()) { > If ($item.type -eq "File Folder") > { > $objFSO.DeleteFolder($item.path) > } > Else { > $objFSO.DeleteFile($item.path) > } > } > > "Ryan" wrote: > Quote: >> I need to write a simple script that will empty the recycle bin on a >> single >> desktop computer. >> -- >> Ryan >> Denver, CO |
My System Specs![]() |
| | #4 (permalink) |
| | Re: empty recycle bin "Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com> wrote in message news:u5tcnc55JHA.4116@xxxxxx Quote: > One shortcut that can simplify this further is to use Remove-Item; that > reduces it to a 2-line solution: > > $objShell = New-Object -Com Shell.Application > $objShell.Namespace(0xA).Items() | Remove-Item -Recurse > > And in the obligatory "oh yeah, it can be a one-liner" form :> > (New-Object -Com Shell.Application).Namespace(0xA).Items()| ri -r zero-liner solution! Now that would be truly something. Or perhaps nothing. /Al Quote: > "Mike Pfeiffer" <MikePfeiffer@xxxxxx> wrote in message > news:A69F8DD8-F9B8-4AE0-ABF5-4A6D5C27AD0F@xxxxxx Quote: >> This should work: >> >> $objShell = New-Object -Com Shell.Application >> $objFolder = $objShell.Namespace(0xA) >> $objFSO = New-Object -ComObject Scripting.FileSystemObject >> >> foreach ($item in $objFolder.Items()) { >> If ($item.type -eq "File Folder") >> { >> $objFSO.DeleteFolder($item.path) >> } >> Else { >> $objFSO.DeleteFile($item.path) >> } >> } >> >> "Ryan" wrote: >> Quote: >>> I need to write a simple script that will empty the recycle bin on a >>> single >>> desktop computer. >>> -- >>> Ryan >>> Denver, CO |
My System Specs![]() |
| | #5 (permalink) |
| | Re: empty recycle bin "Al Dunbar" <alandrub@xxxxxx> wrote in message news:Oxn$9k65JHA.5920@xxxxxx Quote: > > "Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com> > wrote in message news:u5tcnc55JHA.4116@xxxxxx Quote: >> One shortcut that can simplify this further is to use Remove-Item; that >> reduces it to a 2-line solution: >> >> $objShell = New-Object -Com Shell.Application >> $objShell.Namespace(0xA).Items() | Remove-Item -Recurse >> >> And in the obligatory "oh yeah, it can be a one-liner" form :>> >> (New-Object -Com Shell.Application).Namespace(0xA).Items()| ri -r > One-liner, nothing. I'm still waiting for someone to come up with a > zero-liner solution! Now that would be truly something. Or perhaps > nothing. > to the Windows "garbage collector". ; ) |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| I can't empty my recycle bin | Vista file management | |||
| 5K in Recycle Bin - 5 minutes to empty? | Vista performance & maintenance | |||
| Recycle Bin won't empty | Vista General | |||
| Can't Empty the Recycle Bin | Vista General | |||
| Recycle Bin Will Not Empty | Vista file management | |||