Skip to content

Instantly share code, notes, and snippets.

@b4tman
Last active February 7, 2025 10:37
Show Gist options
  • Save b4tman/ec3a398a2c842d74c59182a286476218 to your computer and use it in GitHub Desktop.
Save b4tman/ec3a398a2c842d74c59182a286476218 to your computer and use it in GitHub Desktop.
установка обновлений 1с (запуск установщиков из zip архивов)
#!/bin/sh +ex
ZDIR="."
if [ -d "$1" ]; then
ZDIR="$1";
fi
# распаковка
UDIR=$(mktemp -d)
find $ZDIR -iname "*.zip" -exec sh -exc "ZIP={};NAME=\${ZIP##*/};exec unzip \$ZIP -d $UDIR/\${NAME%.*}" ';'
# установка
find "$UDIR" -name setup -exec sh {} \;
# очистка каталогов
rm -rvf "$UDIR"
$randomfile = [System.IO.Path]::GetRandomFileName()
$temp = Microsoft.PowerShell.Management\Join-Path ([System.IO.Path]::GetTempPath()) "$randomfile"
New-Item -ItemType Directory -Force -Path $temp
Get-ChildItem "*.zip" | %{
$zip = $_
$dest = Microsoft.PowerShell.Management\Join-Path ($temp) $zip.BaseName
New-Item -ItemType Directory -Force -Path $dest
Expand-Archive -Path $zip -DestinationPath $dest
$setup = Microsoft.PowerShell.Management\Join-Path ($dest) "setup.exe"
if (Get-ChildItem $setup) {
Start-Process -FilePath $setup -NoNewWindow -Wait
}
}
if ($temp) {
Remove-Item -Recurse -Force $temp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment