исправлены установочные скрипты

This commit is contained in:
2026-06-17 17:04:26 +03:00
parent 302efecd3a
commit e711c6aea2
2 changed files with 40 additions and 3 deletions
+21 -2
View File
@@ -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
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")
+19 -1
View File
@@ -1 +1,19 @@
Remove-OdbcDsn -Name "GhOST Library" -DsnType "User" -Platform "64-bit" -ErrorAction 'SilentlyContinue'
$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")