Fix IT Scripts
0 like 0 dislike
117 views
I want a script that will run Ccleaner
asked in MaxFocus RMM by (150 points)
reshown by | 117 views

1 Answer

0 like 0 dislike
# Silent Install CCleaner
# http://www.piriform.com/ccleaner/download


# Path for the workdir
$workdir = "c:\temp\"

$sixtyFourBit = Test-Path -Path "C:\Program Files (x86)"

$cCleanerInstalled = Test-Path -Path "C:\Program Files\CCleaner"

If ($cCleanerInstalled){ 
    Write-Host "Installed - running the cleaner!"
    Start-Process -FilePath "C:\Program Files\CCleaner\CCleaner64.exe" -ArgumentList "/AUTO"
} ELSE { 
    Write-Host "Doing the installation first"



    # Check if work directory exists if not create it

    If (Test-Path -Path $workdir -PathType Container){ 
        Write-Host "$workdir already exists" -ForegroundColor Red
    } ELSE { 
        New-Item -Path $workdir  -ItemType directory 
    }

    # Download the installer

    $source = "http://download.piriform.com/ccsetup537.exe"
    $destination = "$workdir\ccsetup.exe"

    # Check if Invoke-Webrequest exists otherwise execute WebClient

    if (Get-Command 'Invoke-Webrequest'){
        Invoke-WebRequest $source -OutFile $destination
    } else {
        $WebClient = New-Object System.Net.WebClient
        $webclient.DownloadFile($source, $destination)
    }

    # Start the installation
    Start-Process -FilePath "$workdir\ccsetup.exe" -ArgumentList "/S"

    Start-Sleep -s 35

    Start-Process -FilePath "C:\Program Files\CCleaner\CCleaner64.exe" -ArgumentList "/AUTO"
}
answered by (3.1k points)

Related questions

0 like 0 dislike
1 answer
asked Aug 10, 2017 in MaxFocus RMM by doughall (3.1k points) | 107 views
0 like 0 dislike
1 answer
asked Aug 10, 2017 in Operating Systems by doughall (3.1k points) | 34 views
0 like 0 dislike
0 answers
asked Jul 19 in MaxFocus RMM by djm (150 points) | 16 views
0 like 0 dislike
0 answers
0 like 0 dislike
1 answer
30 questions
24 answers
17 comments
626 users