-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall-voicemeeter-fix.ps1
More file actions
65 lines (55 loc) · 2.77 KB
/
install-voicemeeter-fix.ps1
File metadata and controls
65 lines (55 loc) · 2.77 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Run the script as administrator in a new window
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
$scriptPath = $MyInvocation.MyCommand.Path
Write-Host "Requesting administrative privileges..."
if (Get-Command pwsh -ErrorAction SilentlyContinue) {
Start-Process pwsh -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$scriptPath`""
# Start-Process powershell -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File", `"$scriptPath`"
}
else {
Start-Process powershell -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$scriptPath`""
}
}
# Check if voicemeeter is install in Program Files(x86)
if (-not (Test-Path -Path "${env:ProgramFiles(x86)}\VB\Voicemeeter\voicemeeter.exe")) {
Write-Host "Voicemeeter not found in: `"$env:ProgramFiles(x86)\VB\Voicemeeter\voicemeeter.exe`"" -ForegroundColor Red
$prompt = Read-Host "Do you want to continue? (Y/n)"
If ($prompt -eq 'y' -or $prompt -eq '') {
Write-Host "Continuing..." -ForegroundColor Green
}
else {
exit
}
}
# Define the PowerShell script content to set audiodg.exe affinity
$psContent = @'
$Process = Get-Process audiodg -ErrorAction SilentlyContinue
if ($Process) {
$Process.ProcessorAffinity = 1
$Process.PriorityClass = [System.Diagnostics.ProcessPriorityClass]::High
}
'@
# Save the PowerShell script to the user profile directory
$psScriptPath = "$env:USERPROFILE\set-audiodg-affinity.ps1"
Set-Content -Path $psScriptPath -Value $psContent
# Define the VBScript content to run the PowerShell script hidden
$vbScriptContent = @'
Set objShell = CreateObject("WScript.Shell")
objShell.Run "powershell.exe -ExecutionPolicy Bypass -File """ & WScript.Arguments(0) & """", 0, False
'@
# Save the VBScript to the user profile directory
$vbScriptPath = "$env:USERPROFILE\run-hidden.vbs"
Set-Content -Path $vbScriptPath -Value $vbScriptContent
# Remove old version of the scheduled task if present
schtasks /delete /f /tn audiodg-affinity
schtasks /delete /f /tn audiodg-affinity-recurring
# Create scheduled task to set audiodg.exe affinity on logon
schtasks /create /sc ONLOGON /tn audiodg-affinity /delay 0000:20 /tr "wscript.exe $vbScriptPath $psScriptPath" /rl HIGHEST
# Create recurring scheduled task to set audiodg.exe affinity every hour
schtasks /create /sc MINUTE /tn audiodg-affinity-recurring /mo 60 /tr "wscript.exe $vbScriptPath $psScriptPath" /rl HIGHEST
# Run the PowerShell script once to set the affinity for the current session
powershell.exe -ExecutionPolicy Bypass -File $psScriptPath
# Output completion message
Write-Host "INSTALLATION FINISHED!"
Write-Host "Note: Ignore 'Access is denied' in Windows Terminal in case you see it." -ForegroundColor Blue
Pause