Run bleachbit_console in "Unattended mode"

Forums: 

I'm having a weird issue with the following powershell script,
pretty simple stuff to launch bleachbit console,
clean some crap and logs everything it does.

$logTime = (Get-Date).ToString("dd-MM-yyyy_HH-mm-ss")
$bleachbitCmd = "C:\test\BleachBit-Portable\bleachbit_console.exe"
$bleachbitLog = "C:\test\BleachBit_log-$logTime.log"
cmd /C "$bleachbitCmd -p -o --preset" | Out-file $bleachbitLog

This works fine if I launch with user logged in windows session.
If I launch in the system context or without a desktop session running, it hangs until timeout doing nothing (empty logs).
Is there any way I can run bleachbit_console unattended without desktop session within system context?
thanks

BleachBit version 4.0.0
Build number 1628
GTK version 3.18.9

BleachBit version: 
4.0.0
Your operating system: 
Windows 10

For troubleshooting, what if you replace --preset with something like internet_explorer.cache in case it is related to a specific cleaner? One special case is system.clipboard which requires the user interface. Another special cache are many cleaners that required administrator privileges.

How do you launch it in the system context or without a desktop session running? Do you use Windows Task Scheduler?

Could you run it in the user context with the desktop session running?

---
Andrew, lead developer

Ok I've tried with just a few cleaners and it runs !!
the line
cmd /c "$bleachbitCmd -p adobe_reader.* firefox.cache microsoft_office.* system.tmp" | Out-file $bleachbitLog
works. There is something related to specify cleaners, I've read most of the docs but I coundn't remember anything about cleaner permission, is there anything about ? How can I troubleshoot ?

For the system context I use "psexec.exe -i -s powershell.exe" and also tried with the windows task scheduler.

Yes in user context with desktop sessions the original runs fine.
I have an additional question; is there a way to clean every local profile, not just the running user ?
Thanks

There is something related to specify cleaners, I've read most of the
docs but I coundn't remember anything about cleaner permission, is there
anything about ? How can I troubleshoot ?

I would start by cleaning user applications such as web browsers, Adobe Reader, Flash, Microsoft Office: these should work fine. These clean stuff under %userprofile%. If you examine the CleanerML (xml) files, you will notice they reference %userprofile%, %appdata%, %localappdata%, and HKCU (registry hive).

Windows Explorer thumbnails might not work because it launches taskkill.exe and explorer.exe . (You can see this in its XML file.)

I would avoid cleaning system.clipboard and system.free_disk_space.

I have an additional question; is there a way to clean every local profile, not just the running user ?

As of BleachBit 4.0.0, there is nothing built in. Some options are

1. Use psexec to switch to the other users' contexts
2. Run as a logon script for each user
3. Use Windows Task Scheduler to run as each user

---
Andrew, lead developer

Rod Lockwood's picture

Have you tried setting the SYSTEM as the user in Task Manager? This automatically takes the option to run without needing the user to be logged in. I have not checked, but it seems to me that all user profiles would be checked even if it started while a particular user was logged on at the time. Alternately, you could have it run as SYSTEM after a boot/reboot when no user is logged on yet. I am about to schedule a task for BleachBit to run and I always set my tasks to run as SYSTEM. I thought it would include an update check, but apparently it does not.

Rod Lockwood

Sorry for late reply, covid related issues ...
I tried with scheduled task as SYSTEM but didnt'work for me. Process start, I can see bleachit_console.exe as running in task list but then freeze. Do you had better luck ?
I ended up deploying a logoff script for each user to clean profiles, that way it works fine.
federico