File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol
1111* [ check-mac-address.ps1] ( Scripts/check-mac-address.ps1 ) - checks the given MAC address for validity
1212* [ check-xml-file.ps1] ( Scripts/check-xml-file.ps1 ) - checks the given XML file for validity
1313* [ clone-repos.ps1] ( Scripts/clone-repos.ps1 ) - clones well-known Git repositories
14+ * [ close-chrome.ps1] ( Scripts/close-chrome.ps1 ) - closes Google Chrome gracefully
1415* [ close-program.ps1] ( Scripts/close-program.ps1 ) - closes the given program gracefully
16+ * [ close-thunderbird.ps1] ( Scripts/close-thunderbird.ps1 ) - closes Mozilla Thunderbird gracefully
1517* [ close-windows-terminal.ps1] ( Scripts/close-windows-terminal.ps1 ) - closes Windows Terminal gracefully
1618* [ configure-git.ps1] ( Scripts/configure-git.ps1 ) - sets up the Git configuration
1719* [ csv-to-text.ps1] ( Scripts/csv-to-text.ps1 ) - converts the given CSV file into a text list
Original file line number Diff line number Diff line change 1+ # !/snap/bin/powershell
2+
3+ # Syntax: ./close-chrome.ps1
4+ # Description: closes Google Chrome gracefully
5+ # Author: Markus Fleschutz
6+ # Source: github.com/fleschutz/PowerShell
7+ # License: CC0
8+
9+ $ExitCode = close-program.ps1 " chrome"
10+ exit $ExitCode
Original file line number Diff line number Diff line change @@ -14,15 +14,16 @@ try {
1414 $ProgramName = read-host " Enter program to close"
1515 }
1616 $List = Get-Process - name $ProgramName - erroraction ' silentlycontinue'
17- $NumProc = 0
18- $List | Foreach-Object { $NumProc ++ ; $_.CloseMainWindow () | Out-Null } | stop-process - force
19- if ($NumProc -eq 0 ) {
20- write-error " ERROR: No processes for program '$ProgramName ' found"
21- exit 1
22- } else {
23- write-output " Done - $NumProc processes stopped."
24- exit 0
17+ $NumProcKilled = 0
18+ $List | Foreach-Object {
19+ $_.CloseMainWindow () | Out-Null
20+ $NumProcKilled ++
21+ } | stop-process - force
22+ if ($NumProcKilled -eq 0 ) {
23+ throw " program '$ProgramName ' is not started yet"
2524 }
25+ write-output " OK - program '$ProgramName ' has been closed ($NumProcKilled processes)."
26+ exit 0
2627} catch {
2728 write-error " ERROR in line $ ( $_.InvocationInfo.ScriptLineNumber ) : $ ( $Error [0 ]) "
2829 exit 1
Original file line number Diff line number Diff line change 1+ # !/snap/bin/powershell
2+
3+ # Syntax: ./close-thunderbird.ps1
4+ # Description: closes Mozilla Thunderbird gracefully
5+ # Author: Markus Fleschutz
6+ # Source: github.com/fleschutz/PowerShell
7+ # License: CC0
8+
9+ $ExitCode = close-program.ps1 " thunderbird"
10+ exit $ExitCode
Original file line number Diff line number Diff line change 11# !/snap/bin/powershell
22
33# Syntax: ./close-windows-terminal.ps1
4- # Description: closes the Windows Terminal program gracefully
4+ # Description: closes Windows Terminal gracefully
55# Author: Markus Fleschutz
66# Source: github.com/fleschutz/PowerShell
77# License: CC0
88
9- close-program.ps1 " WindowsTerminal"
10- # try {
11- # exit 0
12- # } catch {
13- # write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
14- # exit 1
15- # }
9+ $ExitCode = close-program.ps1 " WindowsTerminal"
10+ exit $ExitCode
You can’t perform that action at this time.
0 commit comments