###################################################################
# GPSM (c) 2012, Saint-Petersburg, Russia
# Developer: Andrey Bushman
# Site: https://sites.google.com/site/bushmansnetlaboratory/
#
# This script is a installer of AdminCAD local client.
###################################################################
###### RETURN CODES ################################
$ExitCode_Success = 0 # Successful end of a script operation.
$ExitCode_AcadNotInstalled = 1 # On the local machine is not installed any AutoCAD version.
$ExitCode_NoAutoCADCorrectVersions = 2 # On the local machine is not installed necessary AutoCAD versions.
$ExitCode_AutoCADWorkingProcess = 4 # At the moment of performance of a script worked AutoCAD
###################################################################
###### TEXT MESSAGES ########################################
$Message_HostTitle = "Install/Update AdminCAD local client"
$Message_ScriptOperationIsStopped = "Script operation is interrupted."
$Message_Success = "Script operation is completed successfully."
$Message_PressEnterKeyToExit = "Press 'Enter' key for exit..."
$Message_AcadNotInstalled = "On the local machine is not installed any AutoCAD version."
$Message_NoAutoCADCorrectVersions = "On the local machine is not installed necessary AutoCAD versions."
###################################################################
$Host.UI.RawUI.WindowTitle = $Message_HostTitle
#$ErrorActionPreference = "SilentlyContinue"
# Server directory of AdminCAD
$ServerDir = "C:Documents and SettingsDeveloperDesktopGPSMAdminCAD"
# We check: whether it is installed AutoCAD on the computer...
$LMRegKey = Get-Item "HKLM:SOFTWAREAutodeskAutoCAD"
if ($LMRegKey -eq $NULL) {
$Message_AcadNotInstalled
Write-Host $Message_ScriptOperationIsStopped
Write-Host $Message_PressEnterKeyToExit
#Read-Host
Exit $ExitCode_AcadNotInstalled
}
# We receive versions AutoCAD with which it is allowed to work AdminCAD
$AllowedVersions = @()
Get-ChildItem -Path "$ServerDirpluginsversions" | Select-Object @{Name = "Version";
Expression ={"R$($_.PSChildName)".ToUpper().Replace("X86","").Replace("X64","")}} -Unique | ForEach-Object {$AllowedVersions += $_.Version}
# Directory "$ServerDirpluginsversions" contains subdirectories:
# 17.2
# 17.2x86
# 17.2x64
# 18.0
# $LMRegKey contains subkey:
# R17.2
# We check: whether is available among installed AutoCAD those versions with which it is allowed to work AdminCAD...
$LMSubKeys = $LMRegKey | Get-ChildItem | Where-Object {$AllowedVersions.Contains(
$_.PSChildName.ToUpper())}
if ($LMSubKeys -eq $NULL) {
$Message_NoAutoCADCorrectVersions
Write-Host $Message_ScriptOperationIsStopped
Write-Host $Message_PressEnterKeyToExit
##Read-Host
Exit $ExitCode_NoAutoCADCorrectVersions
}
# PROBLEM: $LMSubKeys is $NULL. Why?
#...
# Successful end of a script operation
Write-Host $Message_PressEnterKeyToExit
#Read-Host
Exit $ExitCode_Success