Cleanup and reuse unused Copy&Paste disk space occupied by VMware

Posted by ads on Monday, 2013-09-09
Posted in [Software]

Whenever you Copy&Paste (or Cut&Paste) something into or from a VMware instance, the software first copies the files into a temporary directory and later on sends the copy/move job to Windows. Since the Windows task is asynchronous, VMware has no chance to find out when this actually finishes - so it is supposed to clean up this temporary directory at boot time.

However, waiting for the next reboot can clog up quite some disk space (when I develop something I often have to copy many files around between several virtual machines and the desktop) - despite that Windows still likes to BSoD on me from time to time. And sometimes VMware does not get the cleanup right at reboot and the files are still there.

So I wrote myself a little Cygwin shell script (you should really consider installing Cygwin when you have to work on Windows) and the execution of this script is scheduled every night by the Windows Scheduler.

First create a shell script cleanup-VMwareDnD.sh in <your folder>\AppData\Local, with the following content:

1
2
3
4
#!/usr/bin/bash
 set -e
 cd /cygdrive/c/Users/<your username>/AppData/Local/Temp/vmware-<your username>/VMwareDnD || exit 1
 /usr/bin/find . -depth -mindepth 1 -maxdepth 1 -type d -mmin +720 -exec /usr/bin/rm -rf {} \;

Then follow the instructions in these screen shots to install this script in the Windows Scheduler:

Open the &lsquo;Control Panel&rsquo;, search for &lsquo;Schedule&rsquo;
Open the 'Control Panel', search for 'Schedule'

Click on &lsquo;Create Basic Task&rsquo;
Click on 'Create Basic Task'

Enter a descriptive name (I used &lsquo;Cleanup VMwareDnD directory&rsquo; here)
Enter a descriptive name (I used 'Cleanup VMwareDnD directory' here)

Select &lsquo;daily&rsquo; when asked for the scheduling frequency
Select 'daily' when asked for the scheduling frequency

Enter a time which fits your requirements, early in the morning is just fine for me
Enter a time which fits your requirements, early in the morning is just fine for me

Select &lsquo;Start a program&rsquo; when asked for the scheduling action
Select 'Start a program' when asked for the scheduling action

Enter the path to the Cygwin Bash shell, specify the path to the script as option
Enter the path to the Cygwin Bash shell, specify the path to the script as option

Windows asks you to separate program and parameters, agree here
Windows asks you to separate program and parameters, agree here

If everything is ok, press &lsquo;Finish&rsquo;
If everything is ok, press 'Finish'

Make sure you can see your new job in the &lsquo;Active Tasks&rsquo; list
Make sure you can see your new job in the 'Active Tasks' list

Voila, now Windows will clean up old entries not only when you restart the operating system. The script above removes all directories which data was last modified 720 minutes ago, or more. That’s 12 hours - should be reasonable enough.


Categories: [Software]

Share: