Skip to content

Commit

Permalink
Adjust service install script to require PS Core
Browse files Browse the repository at this point in the history
  • Loading branch information
nike4613 committed Mar 30, 2021
1 parent ef25ee4 commit 676afe2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions install-service.ps1
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
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 powershell "-ExecutionPolicy","Unrestricted","-File",('"{0}"' -f $MyInvocation.MyCommand.Path) -Verb RunAs
Start-Process pwsh "-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 Automatic
New-Service -Name "AudioDGFix" -BinaryPathName "`"$(resolve-path .\AudioDGFix.exe)`" -s" -DependsOn "audiosrv" -StartupType AutomaticDelayedStart
# Immediately start the Service
Start-Service -Name "AudioDGFix"
6 changes: 5 additions & 1 deletion uninstall-service.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#Requires -Version 6.0
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))
Expand Down

0 comments on commit 676afe2

Please sign in to comment.