Skip to main content
added 380 characters in body
Source Link

You can access the Recycle Bin in the path C:$Recycle.bin so you can use the xcopy command in your script. Take into account that you can have a folder like that in more than one drive.

I would xcopy all files and folders from the Recycle Bin and in the next line I would delete all its contents.

The script will be like this:

xcopy C:\$Recycle.bin C:\Temp /E /R /Y
rd /s /q C:\$Recycle.bin

There is no way the Recycle Bin can be issued an "empty" command. By deleting this folder you are in fact emptying it. Windows recreates this folder as needed.

You can read the command line reference in Microsoft's Technet to learn about all the available parameters for xcopy and rd.

To address @JdeBP remarks: If you have more than one user account in your computer, you can use C:$Recycle.bin\USER-SID instead. To find out the different SID and the one that corresponds to your user account, use this registry entry.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList

The ProfileImagePath key contains the user name.

You can access the Recycle Bin in the path C:$Recycle.bin so you can use the xcopy command in your script. Take into account that you can have a folder like that in more than one drive.

I would xcopy all files and folders from the Recycle Bin and in the next line I would delete all its contents.

The script will be like this:

xcopy C:\$Recycle.bin C:\Temp /E /R /Y
rd /s /q C:\$Recycle.bin

There is no way the Recycle Bin can be issued an "empty" command. By deleting this folder you are in fact emptying it. Windows recreates this folder as needed.

You can read the command line reference in Microsoft's Technet to learn about all the available parameters for xcopy and rd.

You can access the Recycle Bin in the path C:$Recycle.bin so you can use the xcopy command in your script. Take into account that you can have a folder like that in more than one drive.

I would xcopy all files and folders from the Recycle Bin and in the next line I would delete all its contents.

The script will be like this:

xcopy C:\$Recycle.bin C:\Temp /E /R /Y
rd /s /q C:\$Recycle.bin

There is no way the Recycle Bin can be issued an "empty" command. By deleting this folder you are in fact emptying it. Windows recreates this folder as needed.

You can read the command line reference in Microsoft's Technet to learn about all the available parameters for xcopy and rd.

To address @JdeBP remarks: If you have more than one user account in your computer, you can use C:$Recycle.bin\USER-SID instead. To find out the different SID and the one that corresponds to your user account, use this registry entry.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList

The ProfileImagePath key contains the user name.

Source Link

You can access the Recycle Bin in the path C:$Recycle.bin so you can use the xcopy command in your script. Take into account that you can have a folder like that in more than one drive.

I would xcopy all files and folders from the Recycle Bin and in the next line I would delete all its contents.

The script will be like this:

xcopy C:\$Recycle.bin C:\Temp /E /R /Y
rd /s /q C:\$Recycle.bin

There is no way the Recycle Bin can be issued an "empty" command. By deleting this folder you are in fact emptying it. Windows recreates this folder as needed.

You can read the command line reference in Microsoft's Technet to learn about all the available parameters for xcopy and rd.