-
Notifications
You must be signed in to change notification settings - Fork 2
/
cc.ps1
51 lines (51 loc) · 1.67 KB
/
cc.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using namespace System.Management.Automation.Host
$program = $host.ui.PromptForChoice(
'Enter the letter corrosponding to the CC program you want to launch:',
$null,
[ChoiceDescription[]](
[ChoiceDescription]::new('Photo&shop'),
[ChoiceDescription]::new('&Premiere Pro'),
[ChoiceDescription]::new('&Media Encoder'),
[ChoiceDescription]::new('&After Effects'),
[ChoiceDescription]::new('&Illustrator')
),
$null
)
$program = switch ($program) {
0 { 'Adobe Photoshop */Photoshop*.exe' }
1 { 'Adobe Premiere Pro */Adobe Premiere Pro*.exe' }
2 { 'Adobe Media Encoder */Adobe Media Encoder*.exe' }
3 { 'Adobe After Effects */Support Files/AfterFX*.exe' }
4 { 'Adobe Illustrator */Support Files/Contents/Windows/Illustrator*.exe' }
}
$job = Start-Job -ScriptBlock {
$program = (Get-ChildItem "$env:ProgramFiles/Adobe/$Using:program")[0]
$killable = [Collections.Generic.HashSet[string]](
'Adobe Crash Processor',
'AdobeExtensionsService',
'AdobeIPCBroker',
'AdobeNotificationClient',
'CCLibrary',
'CCXProcess',
'Creative Cloud'
)
$proc = Start-Process -PassThru $program
Start-Sleep 20
foreach ($_ in (Get-Process | Sort-Object -Descending -Property StartTime)) {
if ($_.Name -eq $program.BaseName) {
break
}
if ($killable.Contains($_.Name)) {
Stop-Process -Force $_
}
}
Wait-Process -InputObject $proc
Get-Process | ForEach-Object {
if ($killable.Contains($_.Name)) {
Stop-Process -Force $_
}
}
}
if ($myInvocation.InvocationName -eq '&') {
Wait-Job $job
}