diff --git a/win/setup.ps1 b/win/setup.ps1 index 2b694d0..c7e7e77 100644 --- a/win/setup.ps1 +++ b/win/setup.ps1 @@ -1,10 +1,11 @@ +# execute this first +Set-ExecutionPolicy RemoteSigned + if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`""; exit; } -Set-ExecutionPolicy RemoteSigned - # link config files $dotfiles=(Get-Item $PSScriptRoot).Parent.FullName New-Item -ItemType SymbolicLink -Target $dotfiles\win\profile.ps1 -Path $profile -Force @@ -17,7 +18,9 @@ if (Test-Path $sshconf -PathType Leaf) { } # fix Shift key toggling Cn/En fro MS wubi -$wubiAction = New-ScheduledTaskAction -Execute 'Powershell.exe' ` - -Argument "-NoProfile -WindowStyle Hidden -File $PSScriptRoot\wubi-no-shift.ps1" -$wubiTrigger = New-ScheduledTaskTrigger -AtLogOn -Register-ScheduledTask -Action $wubiAction -Trigger $wubiTrigger -TaskName "Wubi No Shift" -Description "Disable Shift key toggling CN/EN" -RunLevel Highest \ No newline at end of file +if (-not (Get-ScheduledTask -TaskName "Wubi No Shift")) { + $wubiAction = New-ScheduledTaskAction -Execute 'Powershell.exe' ` + -Argument "-NoProfile -WindowStyle Hidden -File $PSScriptRoot\wubi-no-shift.ps1" + $wubiTrigger = New-ScheduledTaskTrigger -AtLogOn + Register-ScheduledTask -Action $wubiAction -Trigger $wubiTrigger -TaskName "Wubi No Shift" -Description "Disable Shift key toggling CN/EN" -RunLevel Highest +} \ No newline at end of file