Context.ps1

#Make sure we're running as admin
#[System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $filename + ".config")
if (!([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
     [Security.Principal.WindowsBuiltInRole] "Administrator"))
{
    
    Write-Output " "
    Write-Host -BackgroundColor Black -ForegroundColor Yellow "Qlik-Tools caller is non-administrator"
    Write-Output " "

}
#$path = ((Get-Module -Name Qlik-Tools).Path).Substring(0, ((Get-Module -Name Qlik-Tools).Path.IndexOf("Qlik-Tools")+ "Qlik-Tools".Length))
#[System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", "$($path)\Qlik-Tools.dll" + ".config")
#gcm -Module Qlik-Tools
#gci -File -Filter "Interceptor.exe" -Recurse | select Fullname | %{Stop-Process $_.FullName -NoNewWindow -Force }

#TODO: Make dynamic, disable only when debugging.
$interceptor = Get-Process Interceptor -ErrorAction SilentlyContinue
if ($interceptor) {
  # try gracefully first
  $interceptor.CloseMainWindow()
  # kill after five seconds
  Sleep 1
  if (!$interceptor.HasExited) {
    $interceptor | Stop-Process -Force
  }
}
Remove-Variable interceptor
gci -File -Filter "QlikTools.Interceptor.exe" -Recurse | select Fullname  | %{Start-Process $_.FullName -NoNewWindow }


Write-Output " "
    Write-Host -BackgroundColor Black -ForegroundColor Green "Checking for Qlik Tools Home"
Write-Output " "
$qtHome = "$($env:HOMEDRIVE)$($env:HOMEPATH)\Documents\Qlik-Tools"
If(!(test-path $qtHome))
{
Write-Output " "
    Write-Host -BackgroundColor Black -ForegroundColor Green "Qlik Tools Home not found. Creating Defaults"
Write-Output " "
    New-Item -ItemType Directory -Force -Path $qtHome
}