Skip to content

Instantly share code, notes, and snippets.

@ethzero
Last active October 31, 2023 22:47
Show Gist options
  • Save ethzero/ce9bad9071c0ca4feb6b0fd4dc39dcfc to your computer and use it in GitHub Desktop.
Save ethzero/ce9bad9071c0ca4feb6b0fd4dc39dcfc to your computer and use it in GitHub Desktop.
Restart PowerShell Script for when the Corsair iCUE software occassionally stop animating RAM LEDs
#requires -version 2
<#
.SYNOPSIS
A PowerShell restart script for when the Corsair iCUE software occassionally stops animating the RAM LEDs
.DESCRIPTION
The script first terminates the iCUE desktop application, then restarts the CorsairLLAService (which acts as data proxy between iCUE and the hardware), then finally relaunches iCUE
.PARAMETER <Parameter_Name>
<Brief description of parameter input required. Repeat this attribute if required>
.INPUTS
<Inputs if any, otherwise state None>
.OUTPUTS
<Outputs if any, otherwise state None - example: Log file stored in C:\Windows\Temp\<name>.log>
.NOTES
Version: 1.0
Author: <Name>
Creation Date: <Date>
Purpose/Change: Initial script development
.EXAMPLE
<Example goes here. Repeat this attribute for more than one example>
#>
$runRegistryKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
$iCUERunKey = "Corsair iCUE5 Software"
$iCueName = "iCUE"
$CorsairLLAService_Name = "CorsairLLAService"
if (Test-Path -Path $runRegistryKey) {
$registryKey = Get-Item -LiteralPath $runRegistryKey
if ($registryKey.GetValueNames() -contains $iCUERunKey) {
$iCUEStartupPath = $registryKey.GetValue($iCUERunKey)
} else {
Write-Host "'$iCUEStartupPath' not found in the registry key."
}
} else {
Write-Host "Registry key not found: $runRegistryKey"
}
Write-Host -ForegroundColor Cyan -NoNewline "# Stopping $iCueName Desktop application... "
$iCueProcess = (Get-Process -Name $iCueName -ErrorAction SilentlyContinue | Select-Object -First 1)
if ($iCueProcess) {
$resultStopProcess = (Stop-Process -InputObject $iCueProcess -PassThru)
if ($resultStopProcess) {
"Stopped [Id: $($resultStopProcess.Id)]"
} else {
"FAILED to stop"
}
} else {
Write-Host "Cannot find $iCueName process"
}
Write-Host -ForegroundColor Cyan -NoNewline "# Restarting $CorsairLLAService_Name service... "
$resultService = Restart-Service -Name $CorsairLLAService_Name -PassThru
if ($resultService) {
Write-Host "Started"
} else {
Write-Host "NOT STARTED"
}
Write-Host -ForegroundColor Cyan -NoNewline "# Restarting $iCueName Desktop application... "
$executablePath, $arguments = $iCUEStartupPath -split ' --', 2
$arguments = "--$arguments"
$newProcess = Start-Process -PassThru -FilePath $executablePath -ArgumentList $arguments
if ($newProcess) {
Write-Host "Started [Id: $($newProcess.Id)]"
} else {
Write-Host "NOT STARTED"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment