Compartilhar via

Cleanmgr.exe does not work by CLI, only GUI

Anônima
2023-12-17T20:29:33+00:00

Hello! I'm trying to make cleanmgr.exe execution by PowerShell or CMD, neither does work, I've tried many things to make it work, switched parameters, tried both PowerShell (start-process, start, invoke-expression) and CMD (cleanmgr /SAGERUN:1) admin mode, reboot, restore the system, etc, also tested in other 3 PCs but got the same problem, using CLI commands, it shows me the cleanmgr.exe window open and being executed, but when I check it again after the process is "done", all the files that were meant to be deleted are still there, like a false execution, but when I try to do this by GUI it works and deletes all the files. Someone can help?

I use W11 pro

Windows para casa | Windows 11 | Falhas de desempenho e do sistema

Pergunta bloqueada. Essa pergunta foi migrada da Comunidade de Suporte da Microsoft. É possível votar se é útil, mas não é possível adicionar comentários ou respostas ou seguir a pergunta.

0 comentários Sem comentários

2 respostas

Classificar por: Mais útil
  1. Anônima
    2023-12-17T23:37:42+00:00

    Hello!

    I'm sorry to hear that you're having trouble with cleanmgr.exe. It's possible that the command line parameters you're using are not correct. Here's an example of how to use cleanmgr.exe with the /SAGERUN parameter:

    cleanmgr /SAGERUN:1

    This should run the Disk Cleanup tool with the settings saved in the first SAGERUN key in the registry. If this doesn't work, you can try running the command with elevated privileges by opening PowerShell or CMD as an administrator.

    If you're still having trouble, you can try using the PowerShell cmdlet "Invoke-WmiMethod" to run the Disk Cleanup tool. Here's an example:

    Invoke-WmiMethod -Class Win32_Process -Name Create -ArgumentList "cleanmgr.exe /SAGERUN:1"

    This should run the Disk Cleanup tool with the same settings as before. If this doesn't work, you may need to troubleshoot further for additional assistance.

    Hello! Thanks for the reply

    I have already tried both ways and got the same result. As I already said, I've tried many parameters as of course the cleanmgr.exe /SAGERUN:1 On both CMD and PowerShell, and all the possible powershell's commands such as the invoke-expression, invoke-wmimethod-class, start-process and so on, none worked. I have tested in more than 10 PCs plus of course I tried to use the help of Google bard and chatgpt before coming here, nothing worked in none of them. As I said, when I try to run the cleanmgr.exe via CLI, it OPENS the utility's window and RUNS as it should apparently without issues, but when I OPEN AGAIN the cleanmgr.exe just to see if the files were deleted, boom, they are all there, no matter if I put Verb RunAs on code to make it run with admin permissions. But if try to run it via GUI it works perfectly, just clicking on "ok" and it really deletes all the files it should delete. That said, I believe the problem is more low-level system than just see if the code sintax is right and try many different ways of doing the same thing.

    Esta resposta foi útil?

    0 comentários Sem comentários
  2. Dio Xavier 286.5K Pontos de reputação Moderador Voluntário
    2023-12-17T22:44:37+00:00

    Hello!

    I'm sorry to hear that you're having trouble with cleanmgr.exe. It's possible that the command line parameters you're using are not correct. Here's an example of how to use cleanmgr.exe with the /SAGERUN parameter:

    cleanmgr /SAGERUN:1

    This should run the Disk Cleanup tool with the settings saved in the first SAGERUN key in the registry. If this doesn't work, you can try running the command with elevated privileges by opening PowerShell or CMD as an administrator.

    If you're still having trouble, you can try using the PowerShell cmdlet "Invoke-WmiMethod" to run the Disk Cleanup tool. Here's an example:

    Invoke-WmiMethod -Class Win32_Process -Name Create -ArgumentList "cleanmgr.exe /SAGERUN:1"

    This should run the Disk Cleanup tool with the same settings as before. If this doesn't work, you may need to troubleshoot further for additional assistance.

    Esta resposta foi útil?

    0 comentários Sem comentários