From e711c6aea2f2b3cb50d04399b810e1907b88bed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=9C=D0=BE?= =?UTF-8?q?=D0=B6=D0=B5=D0=B2=D0=B8=D1=82=D0=B8=D0=BD?= Date: Wed, 17 Jun 2026 17:04:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BE=D1=87=D0=BD=D1=8B=D0=B5=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF?= =?UTF-8?q?=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/add_odbc_connection.ps1 | 23 +++++++++++++++++++++-- tools/remove_odbc_connection.ps1 | 20 +++++++++++++++++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/tools/add_odbc_connection.ps1 b/tools/add_odbc_connection.ps1 index 29095b3..e49e082 100644 --- a/tools/add_odbc_connection.ps1 +++ b/tools/add_odbc_connection.ps1 @@ -1,3 +1,22 @@ -$targetdir="DefaultDir="+(Split-Path (Get-Location))+"\components" +$script = $MyInvocation.MyCommand.Path + +$isAdmin = [Security.Principal.WindowsPrincipal]::new([Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) +if (-not $isAdmin) { + Write-Warning "Not running as administrator. Restarting with elevated privileges..." + Start-Process powershell -Verb RunAs -ArgumentList "-ExecutionPolicy Bypass -File `"$script`"" + exit +} + +$targetdir=Join-Path (Split-Path (Split-Path $script)) "components" Write-Host 'Installing GhOST Library to' $targetdir -Add-OdbcDsn -Name "GhOST Library" -DriverName "Microsoft Access Text Driver (*.txt, *.csv)" -DsnType "User" -Platform "64-bit" -SetPropertyValue $targetdir \ No newline at end of file + +try { + Add-OdbcDsn -Name "GhOST Library" -DriverName "Microsoft Access Text Driver (*.txt, *.csv)" -DsnType "User" -Platform "64-bit" -SetPropertyValue "DefaultDir=$targetdir" -ErrorAction Stop + Write-Host "`nSUCCESS: ODBC connection 'GhOST Library' created." -ForegroundColor Green +} +catch { + Write-Host "`nERROR: $_" -ForegroundColor Red +} + +Write-Host "`nPress any key to exit..." -ForegroundColor Yellow +$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") diff --git a/tools/remove_odbc_connection.ps1 b/tools/remove_odbc_connection.ps1 index f61ffc8..892e754 100644 --- a/tools/remove_odbc_connection.ps1 +++ b/tools/remove_odbc_connection.ps1 @@ -1 +1,19 @@ -Remove-OdbcDsn -Name "GhOST Library" -DsnType "User" -Platform "64-bit" -ErrorAction 'SilentlyContinue' \ No newline at end of file +$script = $MyInvocation.MyCommand.Path + +$isAdmin = [Security.Principal.WindowsPrincipal]::new([Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) +if (-not $isAdmin) { + Write-Warning "Not running as administrator. Restarting with elevated privileges..." + Start-Process powershell -Verb RunAs -ArgumentList "-ExecutionPolicy Bypass -File `"$script`"" + exit +} + +try { + Remove-OdbcDsn -Name "GhOST Library" -DsnType "User" -Platform "64-bit" + Write-Host "`nSUCCESS: ODBC connection 'GhOST Library' removed." -ForegroundColor Green +} +catch { + Write-Host "`nERROR: $_" -ForegroundColor Red +} + +Write-Host "`nPress any key to exit..." -ForegroundColor Yellow +$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")