diff --git a/install-service.ps1 b/install-service.ps1 index 4e2caf3..4c40d61 100644 --- a/install-service.ps1 +++ b/install-service.ps1 @@ -1,19 +1,14 @@ -if ($PSEdition -neq "Core") { - Write-Host "This script requires PowerShell Core. Get it here: https://github.com/powershell/powershell#get-powershell" - $HOST.UI.RawUI.ReadKey(“NoEcho,IncludeKeyDown”) | OUT-NULL - $HOST.UI.RawUI.Flushinputbuffer() -} - # Ensure that the script is elevated If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { # Relaunch as an elevated process: - Start-Process pwsh "-ExecutionPolicy","Unrestricted","-File",('"{0}"' -f $MyInvocation.MyCommand.Path) -Verb RunAs + Start-Process powershell "-ExecutionPolicy","Unrestricted","-File",('"{0}"' -f $MyInvocation.MyCommand.Path) -Verb RunAs exit } Set-Location -LiteralPath $PSScriptRoot + # Create the service -New-Service -Name "AudioDGFix" -BinaryPathName "`"$(resolve-path .\AudioDGFix.exe)`" -s" -DependsOn "audiosrv" -StartupType AutomaticDelayedStart +sc.exe create "AudioDGFix" type= own start= delayed-auto binpath= "`"$(resolve-path .\AudioDGFix.exe)`" -s" depend= "audiosrv" # Immediately start the Service Start-Service -Name "AudioDGFix" diff --git a/uninstall-service.ps1 b/uninstall-service.ps1 index 8a5d7ed..2d609bc 100644 --- a/uninstall-service.ps1 +++ b/uninstall-service.ps1 @@ -1,17 +1,12 @@ -if ($PSEdition -neq "Core") { - Write-Host "This script requires PowerShell Core. Get it here: https://github.com/powershell/powershell#get-powershell" - $HOST.UI.RawUI.ReadKey(“NoEcho,IncludeKeyDown”) | OUT-NULL - $HOST.UI.RawUI.Flushinputbuffer() -} # Ensure that the script is elevated If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { # Relaunch as an elevated process: - Start-Process pwsh "-File",('"{0}"' -f $MyInvocation.MyCommand.Path) -Verb RunAs + Start-Process powershell "-File",('"{0}"' -f $MyInvocation.MyCommand.Path) -Verb RunAs exit } # Remove the service -Stop-Service -Name "AudioDGFix" -Remove-Service -Name "AudioDGFix" \ No newline at end of file +sc.exe stop "AudioDGFix" +sc.exe delete "AudioDGFix" \ No newline at end of file