Welcome to OCS Inventory NG community support, where you can ask questions and receive answers from other members of the community.

Please ask questions only in English or French.

Release 2.12.3 available

The official documentation can be found on https://wiki.ocsinventory-ng.org. Read it before asking your question.

Comment exécuter Ccleaner + Defraggler ? (silent) [closed]

Bonjour,

Je tente aujourd'hui d'exécuter un nettoyage silencieux Ccleaner sur des postes clients depuis le serveur OCS. J'arrive à déployer le logiciel silencieux en l'installant sur un client, sauf que j'aimerai par la suite qu'il exécute un nettoyage avec la commande CCleaner64.exe /AUTO à une certaine fréquence.

Faut il créer un autre paquet comprenant un script permettant de lancer cette commande en détectant le logiciel déjà installé ? Si oui comment faire ? (J'ai du mal avec l'exécution de script distant)

Est-il également possible de nettoyer le registre comme il est possible de le faire manuellement ? (J'ai cru comprendre que non)

Autre solution, la plus pratique 2 en 1, Ccleaner existe en exécutable uniquement, idéalement télécharger et "stocker" le paquet sur le client puis exécuter la commande CCleaner64.exe /AUTO, là encore comment configurer (le paquet) cela depuis le serveur ?

En ce qui concerne, Defragler (même éditeur), je pense que la réponse sera vite trouvée, mais je chercher pareil à lancer une défrag rapide en silencieur (mais la commande /AUTO ne semble pas marcher ici ^^), mais idéalement trouver un moyen d'executer une défrag rapide soit avec le logiciel installé sur la machine ou directement avec une version exécutable uniquement.

En vous remerciant par avance pour vos réponses.

Cordialement,

Hans.

Système

  • Nom du système :
  • Version :
  • RAM totale :
  • RAM disponible :
  • CPU :
  • Distribution :
  • Linux x86_64
  • 4.9.0-11-amd64
  • 7987 Mo
  • 6099 Mo
  • Intel(R) Xeon(R) Silver 4116 CPU @ 2.10GHz
  • Debian GNU/Linux 9 (stretch)

Logiciel

  • Version de PHP :
  • Serveur Web :
  • Serveur SQL :
  • Version OCSReports:
  • 7.0.33
  • Apache/2.4.25 (Debian)
  • MySQL Community Server (GPL) version 5.7.28
  • 2.6
closed with the note: Out of date because of new version
in OCS Inventory NG server for Windows by (380 points)
closed by

6 Answers

0 votes

just create an package with a script which executes the command to clean up the computer

you can ask OCS to force reinstall the package :

  1. "Use the advanced option of teledeploy" to "YES"
  2. Choose the package
  3. Check "Teledeploy force"

so you can deploy a package as often as you want

Another possibilty to create a local task via script and OCS-Inventory  .. (on the remote computer)

and if you don't want to use this task anymore.. just create a script which deletes this task on target computer.

here some information about how to create a task via cmd

https://ss64.com/nt/schtasks.html

I also want to have the possibilty to autimatically run a scheduled task in ocs-onventory server .. so a command will for example be executed every week. So a package will be downloaded every week on the client pc.. and will be executed "recuring server side task"

But this isn't possible right now

Kind regards

Sokatra

by (24.4k points)
0 votes
Dear Sokatra,

Firstable, thank you for taking time to answer to my request.

Il would like to apologize to did not answer you before.

It is ok now for Ccleaner, i can run it at the same time after deployed.

Now I would like to execute a bat file (whatever the action) from OCS to the client.

But, I don't know which action I must choose, do I have to "execute a command" or "execute a file" ?

When, I choose to execute a file, for example, my file is supposed to create a folder with a file inside on the desktop, even if the package is "successful" (everything is ok on the log) I don't have the action of my file on the desktop.

If I manually execute it, it works but I don't know how to set up in OCS to deploy on the client.

Or, maybe I can only make a command without uploading the bat on OCS, asking to get the bat from a specified path and launch it... ?

Thank you !
by (380 points)
0 votes
hy, first of all the explanation what is the difference between "execute a file" and "execute a command"

https://wiki.ocsinventory-ng.org/05.Deployment/Deploying-packages-or-executing-commands-on-client-hosts/

quote"

Execute a file: to deploy a ZIP or TAR.GZ file and launch, with or without parameters, an executable file included in ZIP or TAR.GZ file. The ZIP or TAR.GZ file will be uncompressed into a temporary directory, and the associated command (name of executable file without path!) will be launched into this temporary directory"

You should use "execute a file" .. because the bat you want to deploy is not already on the client.

with execute a command .. you can launch a command which is already on the client like "shutdown.exe". .

The commands on the client are executed in "system context" .. so you have to write a script which copys something to a users desktop from your ocs-inventory package.

here is a very good manual how you can do that

https://home.memftw.com/copying-files-to-every-users-profile/

you can flag this answer as best answer if you want and it helps you

Kind regards

sokatra
by (24.4k points)
0 votes
Hi,

Thank you for your response.

My main point was to execute a batch file (.bat) from OCS server to several clients.

Now it works, I can manage it from OCS.

However, I have to do the same with a powershell script (.ps1) but it seems that it does not work properly as a batch file. No action after building the package on the client.

Here is the file I wan to execute (a cleanup script) :

##################################################################################
# DiskCleanUp
##################################################################################
## Variables ####
$objShell = New-Object -ComObject Shell.Application
$objFolder = $objShell.Namespace(0xA)
$temp = get-ChildItem "env:\TEMP"
$temp2 = $temp.Value
$WinTemp = "c:\Windows\Temp\*"
# Remove temp files located in "C:\Users\USERNAME\AppData\Local\Temp"
write-Host "Removing Junk files in $temp2." -ForegroundColor Magenta  
Remove-Item -Recurse  "$temp2\*" -Force -Verbose
# Empty Recycle Bin # http://demonictalkingskull.com/2010/06/empty-users-recycle-bin-with-powershell-and-gpo/
write-Host "Emptying Recycle Bin." -ForegroundColor Cyan  
$objFolder.items() | %{ remove-item $_.path -Recurse -Confirm:$false}
# Remove Windows Temp Directory  
write-Host "Removing Junk files in $WinTemp." -ForegroundColor Green
Remove-Item -Recurse $WinTemp -Force  
#6# Running Disk Clean up Tool  
write-Host "Finally now , Running Windows disk Clean up Tool" -ForegroundColor Cyan
cleanmgr /sagerun:1 | out-Null  
$([char]7)
Sleep 1  
$([char]7)
Sleep 1      
write-Host "Clean Up Task Finished !!!"
##### End of the Script ##### ad

Thank you for response.

Best Regards,
by (380 points)
0 votes

Hy, i don't know if new ocs-inventory clients can natively use powershell .. but i know that the following works

just create a batch file

@echo off

start /wait PowerShell -executionPolicy Bypass -File .\yourpowershellscript.ps1

Thats it

Kind regards

by (24.4k points)
0 votes
Hi Sokatra, thank you for you answer. I am going to close this subject because it was first for Ccleaner + Defragler. I read your previsous answer I think that I am going to open a new topic because the server and client version have changed and now i am facing other issues :)
by (380 points)
 
Powered by Question2Answer
...