@echo off

%~d0
cd %~dp0

if %errorlevel% NEQ 0 GOTO :ERRORELEVATION

pushd %~dp0


reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell /f /v "Path" /d "c:\windows\system32\windowspowershell\v1.0\powershell.exe"
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell /f /v "ExecutionPolicy" /d "unrestricted"

TIMEOUT /T 10 >nul
powershell .\PIN.ps1

TIMEOUT /T 5 >nul

reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell /f /v "Path" /d "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell /f /v ExecutionPolicy

Goto :end

:ERRORELEVATION
echo.
color 0c
echo ERROR, script has not been run elevated.
echo Right click script and choose Run as Administrator or run from elevated command prompt
echo.
pause
color

:end


:end

TIMEOUT /T 2 >nul
EXIT