I have a requirement. usually we delete recyclebin contents by right clicking the mouse and empty the recyclebin. but i have a requirement where i need to delete recyclebin contents using a command through command prompt. Is it possible? if so how can i achieve it?
You can effectively "empty" the Recycle Bin from the command line by permanently deleting the Recycle Bin directory on the drive that contains the system files. (In most cases, this will be the C: drive, but you shouldn't hardcode that value because it won't always be true. Instead, use the %systemdrive% environment variable.)
The reason that this tactic works is because each drive has a hidden, protected folder with the name $Recycle.bin, which is where the Recycle Bin actually stores the deleted files and folders. When this directory is deleted, Windows automatically creates a new directory.
So, to remove the directory, use the rd command (r?emove d?irectory) with the /s parameter, which indicates that all of the files and directories within the specified directory should be removed as well:
rd /s %systemdrive%\$Recycle.bin
Do note that this action will permanently delete all files and folders currently in the Recycle Bin from all user accounts. Additionally, you will (obviously) have to run the command from an elevated command prompt in order to have sufficient privileges to perform this action.
本文地址：IT屋 ? how to empty recyclebin through command prompt?
I want to capture the errors from a script into a file instead of to the screen.
In *nix, this is done with stderr redirection, usually
echo "Error" 2> errorfile.log
How do I do it in a CMD script under Windows?
PSKILL NOTEPAD >output.txt 2>&1
This will direct stdout and stderr to a file name output.txt.
See Underused features of Windows batch files for more details.
本文地址：IT屋 ? How to capture stderr on Windows/DOS?
By default, copying from the command prompt will prompt you to overwrite files that already exist in the target location.
You can add "/Y" to say "Yes to all" replacements.
But how can you say "No to all" ?
In other words, I want to copy everything from one directory that does not already exist in the target.
The closest thing I see is the XCOPY argument to only copy things after a specific mod-datetime.
Unless there's a scenario where you'd not want to copy existing files in the source that have changed since the last copy, why not use XCOPY with /D without specifying a date?
本文地址：IT屋 ? How to say no to all "do you want to overwrite" prompts in a batch file copy?
Since I'm seing many people having their files hidden by flash drive viruses, I'm giving them a Windows command line using attrib (or using Linux) to solve the problem when the infected files are removed and the their files are still "missing". The command removing file and folders properties system, hidden and arquive (not really needed):