<p>I'm looking for a c# snippet which I can insert in a Windows service. The code must empty the recycle bin for all users on the computer.</p>

<p>I have previously tried using <code>SHEmptyRecycleBin</code> (ref <a href="http://www.codeproject.com/KB/cs/Empty_Recycle_Bin.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/cs/Empty_Recycle_Bin.aspx</a>) however the code doesn't work when ran from a windows service as the service is running with local system privileges.</p>

[{'answer_id': 8678, 'author': 'kokos', 'author_id': 1065, 'author_profile': 'https://Stackoverflow.com/users/1065', 'pm_score': 2, 'selected': False, 'text': '<p>I think doing something like this is against Microsoft recommended practices. What are you trying to do that requires emptying the Recycle Bin from a Windows service?</p>\n'}, {'answer_id': 8772, 'author': 'Keith', 'author_id': 905, 'author_profile': 'https://Stackoverflow.com/users/905', 'pm_score': 2, 'selected': False, 'text': "<p>Hopefully you can't.</p>\n\n<p>A service running as the local machine should not be clearing my Recycle bin, ever.</p>\n\n<p>You could promote the service to run as an Admin account then it would have the right (and be a security risk), but why do you want to do this? It sounds like the sort of think Viruses try to do.</p>\n"}, {'answer_id': 8774, 'author': 'Coincoin', 'author_id': 42, 'author_profile': 'https://Stackoverflow.com/users/42', 'pm_score': 1, 'selected': False, 'text': "<p>First, have you tried running the service on an interactive user account? Maybe SHEmptyRecycleBin requires an interactive user even though it doesn't necessarily display a Window.</p>\n\n<p>Second, I'm not sure it's a good idea to delete other users' stuff but I guess you have a very good reason?</p>\n"}]
['https://Stackoverflow.com/questions/8648', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/254/']