Skip to content

Commit

Permalink
update rules for google software
Browse files Browse the repository at this point in the history
  • Loading branch information
metablaster committed Nov 23, 2023
1 parent 13db268 commit 0d7fd8f
Show file tree
Hide file tree
Showing 6 changed files with 258 additions and 198 deletions.
27 changes: 17 additions & 10 deletions Modules/Ruleset.ProgramInfo/Public/Search-Installation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,30 @@ function Search-Installation
}
break
}
"GoogleUpdate"
{
# TODO: This is for system wide installation, if program such Chrome is installed
# the path will be in user profile which is currently handled by Google.ps1 script
Edit-Table "%ProgramFiles% (x86)\Google\Update"
break
}
"GooglePlay"
{
# TODO: This was not tested
Update-Table -Search "GooglePlay"
#Edit-Table "%ProgramFiles%\Google\Play Games"
break
}
"Chrome"
{
Update-Table -Search "Google Chrome" -UserProfile
break
}
"GoogleDrive"
{
Update-Table -Search "Google Drive"
break
}
"dotnet"
{
# TODO: No algorithm to find this path
Expand Down Expand Up @@ -319,11 +336,6 @@ function Search-Installation
Update-Table -Search "Arena Chess"
break
}
"GoogleDrive"
{
Update-Table -Search "Google Drive"
break
}
"ColorMania"
{
Update-Table -Search "ColorMania"
Expand Down Expand Up @@ -591,11 +603,6 @@ function Search-Installation
# NOTE: ask user for standalone installation directory of SteamCMD
break
}
"Chrome"
{
Update-Table -Search "Google Chrome" -UserProfile
break
}
"Firefox"
{
Update-Table -Search "Firefox" -UserProfile
Expand Down
1 change: 1 addition & 0 deletions Modules/Ruleset.ProgramInfo/Scripts/TargetProgram.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ SOFTWARE.
# Services and store apps are not part of this enumeration
enum TargetProgram
{
GoogleUpdate
BlueStacks
BlueStacksServices
GooglePlay
Expand Down
42 changes: 21 additions & 21 deletions Modules/Ruleset.Utility/Public/Invoke-Process.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ function Invoke-Process
}
}

$InvocationName = $MyInvocation.InvocationName
[ScriptBlock] $Code = {
param (
$Path,
Expand All @@ -199,7 +200,8 @@ function Invoke-Process
[PSCredential] $RunAsCredential,
$ArgumentList,
$Async,
$Domain
$Domain,
[string] $InvocationName = $InvocationName
)

$CommandName = Split-Path -Path $Path -Leaf
Expand Down Expand Up @@ -272,18 +274,16 @@ function Invoke-Process
{
# A collection of command-line arguments to use when starting the application
$Process.StartInfo.Arguments = $ArgumentList
Write-Verbose -Message "[$($MyInvocation.InvocationName)] $CommandName argument list is '$ArgumentList'"
Write-Verbose -Message "[$InvocationName & Code] $CommandName argument list is '$ArgumentList'"
}

$InvocationName = $MyInvocation.InvocationName

$Raw = $Raw
$Async = $Async
$Timeout = $Timeout

if ($Async)
{
Write-Verbose -Message "[$($MyInvocation.InvocationName)] Hooking up event handlers for asynchronous operations"
Write-Verbose -Message "[$InvocationName & Code] Hooking up event handlers for asynchronous operations"

if ($Raw)
{
Expand Down Expand Up @@ -322,7 +322,7 @@ function Invoke-Process
{
# NOTE: Explicit -Debug or INFA is needed inside event
Write-Debug -Message "[$InvocationName & OutputDataReceived] OutputDataReceived: $($OutLine.Data)"
Write-Information -Tags $InvocationName -MessageData "INFO: $($OutLine.Data)" -INFA "Continue"
Write-Information -Tags "[$InvocationName & OutputDataReceived]" -MessageData "INFO: $($OutLine.Data)" -INFA "Continue"
}
}

Expand Down Expand Up @@ -401,7 +401,7 @@ function Invoke-Process

try
{
Write-Verbose -Message "[$($MyInvocation.InvocationName)] Starting process '$CommandName'"
Write-Verbose -Message "[$InvocationName & Code] Starting process '$CommandName'"

# true if a process resource is started; false if no new process resource is started
if (!$Process.Start())
Expand Down Expand Up @@ -435,7 +435,7 @@ function Invoke-Process
{
if (!$Raw)
{
Write-Verbose -Message "[$($MyInvocation.InvocationName)] Starting asynchronous read"
Write-Verbose -Message "[$InvocationName & Code] Starting asynchronous read"
}

try
Expand All @@ -451,7 +451,7 @@ function Invoke-Process
Write-Error -Category InvalidOperation -TargetObject $Process -Message $_.Exception.Message

$Async = $false
Write-Warning -Message "[$($MyInvocation.InvocationName)] Fallback to synchronous mode"
Write-Warning -Message "[$InvocationName & Code] Fallback to synchronous mode"
}

# Define the cancellation token
Expand All @@ -470,7 +470,7 @@ function Invoke-Process
{
if ($Timeout -ge 0)
{
Write-Information -Tags $MyInvocation.InvocationName `
Write-Information -Tags "[$InvocationName & Code]" `
-MessageData "INFO: Waiting up to $($Timeout / 1000) seconds for process '$CommandName' to finish on '$Domain' computer..."

if ($Async)
Expand All @@ -486,13 +486,13 @@ function Invoke-Process

if (!$StatusWait)
{
Write-Warning -Message "[$($MyInvocation.InvocationName)] Process '$CommandName' is taking too long, aborting..."
Write-Warning -Message "[$InvocationName & Code] Process '$CommandName' is taking too long, aborting..."
}
}
else
{
$StatusWait = $true
Write-Information -Tags $MyInvocation.InvocationName `
Write-Information -Tags "[$InvocationName & Code]" `
-MessageData "INFO: Waiting infinitely for process '$CommandName' to finish on '$Domain' computer..."

if ($Async)
Expand All @@ -511,7 +511,7 @@ function Invoke-Process

if ($Async -and $CancelSource.IsCancellationRequested)
{
Write-Warning -Message "[$($MyInvocation.InvocationName)] The task has been canceled"
Write-Warning -Message "[$InvocationName & Code] The task has been canceled"
}
else
{
Expand Down Expand Up @@ -554,7 +554,7 @@ function Invoke-Process

if ($Raw)
{
Write-Verbose -Message "[$($MyInvocation.InvocationName)] Starting raw asynchronous read"
Write-Verbose -Message "[$InvocationName & Code] Starting raw asynchronous read"

$StandardOutput = $OutputBuilder.ToString()
if (![string]::IsNullOrEmpty($StandardOutput))
Expand All @@ -571,7 +571,7 @@ function Invoke-Process
}
elseif ($Raw)
{
Write-Verbose -Message "[$($MyInvocation.InvocationName)] Starting raw synchronous read"
Write-Verbose -Message "[$InvocationName & Code] Starting raw synchronous read"

# Reads all characters from the current position to the end of the stream (returns [string])
$StandardOutput = $Process.StandardOutput.ReadToEnd()
Expand All @@ -588,7 +588,7 @@ function Invoke-Process
}
else
{
Write-Verbose -Message "[$($MyInvocation.InvocationName)] Starting synchronous read"
Write-Verbose -Message "[$InvocationName & Code] Starting synchronous read"

# true if the current stream position is at the end of the stream
while (!$Process.StandardOutput.EndOfStream)
Expand All @@ -600,10 +600,10 @@ function Invoke-Process

if (![string]::IsNullOrEmpty($StreamLine))
{
Write-Information -Tags $MyInvocation.InvocationName -MessageData "INFO: $StreamLine"
Write-Information -Tags "[$InvocationName & Code]" -MessageData "INFO: $StreamLine"
}

Write-Debug -Message "[$($MyInvocation.InvocationName)] Sleeping..."
Write-Debug -Message "[$InvocationName & Code] Sleeping..."
Start-Sleep -Milliseconds 300
}

Expand All @@ -616,7 +616,7 @@ function Invoke-Process
Write-Error -Category FromStdErr -TargetObject $Process -Message $StreamLine
}

Write-Debug -Message "[$($MyInvocation.InvocationName)] Sleeping..."
Write-Debug -Message "[$InvocationName & Code] Sleeping..."
Start-Sleep -Milliseconds 300
}
}
Expand All @@ -625,9 +625,9 @@ function Invoke-Process
# closes the process handle, and clears process-specific properties.
# NOTE: Close does not close the standard output, input, and error readers and writers in
# case they are being referenced externally
Write-Debug -Message "[$($MyInvocation.InvocationName)] Closing process '$CommandName'"
Write-Debug -Message "[$InvocationName & Code] Closing process '$CommandName'"
$Process.Close()
}
} # [ScriptBlock] $Code

Invoke-Command @SessionParams -ArgumentList $Path, $NoNewWindow, $WorkingDirectory,
$LoadUserProfile, $Timeout, $Raw, $RunAsCredential, $ArgumentList, $Async, $Domain -ScriptBlock $Code
Expand Down
Loading

0 comments on commit 0d7fd8f

Please sign in to comment.