Hi,
I need to empty the recycle bin in a windows service program, and
the SHEmptyRecycleBin(NULL, NULL, SHERB_NOCONFIRMATION |
SHERB_NOPROGRESSUI | SHERB_NOSOUND) cannot realize it. This function
can take effect in normal applications. So how can I realize the
function of emptying the recycle bin in my service program?

Thanks

Re: how to empty the recycle bin in the windows service by kim

kim
Wed May 30 06:18:24 CDT 2007

Hi steven,

> I need to empty the recycle bin in a windows service program, and
> the SHEmptyRecycleBin(NULL, NULL, SHERB_NOCONFIRMATION |
> SHERB_NOPROGRESSUI | SHERB_NOSOUND) cannot realize it.

How do you mean "cannot realize it"? Nothing happens? It fails? If so, with
what error code?

I would assume that every user has their own recycle bin, and you cannot
empty another user's recycle bin without jumping through some hoops.
Your service is probably not running as the interactive user.

- Kim



Re: how to empty the recycle bin in the windows service by Bruno

Bruno
Wed May 30 09:12:12 CDT 2007

>> I need to empty the recycle bin in a windows service program, and
>> the SHEmptyRecycleBin(NULL, NULL, SHERB_NOCONFIRMATION |
>> SHERB_NOPROGRESSUI | SHERB_NOSOUND) cannot realize it.
>
> How do you mean "cannot realize it"? Nothing happens? It fails? If so,
> with what error code?
>
> I would assume that every user has their own recycle bin, and you cannot
> empty another user's recycle bin without jumping through some hoops.
> Your service is probably not running as the interactive user.

Interactive user is not the first problem (if it is a problem at all).
Each user has it's own recycle bin, and a service is running with local
system privileges by default.
You can run as a specific user but then you can only empty the recycle bin
of that user.
You could use impersonation, and then empty the recycle bin and revert to
self afterwards.

--
Kind regards,
Bruno van Dooren MVP - VC++
http://msmvps.com/blogs/vanDooren
bruno_nos_pam_van_dooren@hotmail.com