diff --git a/DEPLOY.BAT b/DEPLOY.BAT index 11bf299..aaaaba4 100644 --- a/DEPLOY.BAT +++ b/DEPLOY.BAT @@ -287,23 +287,28 @@ ECHO. GOTO INSTALL_BATCH_FILES :MACHINE_EXISTS -ECHO [WARNING] MACHINE variable already exists in AUTOEXEC.BAT +ECHO [INFO] MACHINE variable already exists in AUTOEXEC.BAT ECHO. -ECHO Current AUTOEXEC.BAT contains: +ECHO Current value: TYPE C:\AUTOEXEC.BAT | FIND "SET MACHINE=" ECHO. -ECHO Update MACHINE variable to %MACHINE%? (Y/N) -CHOICE /C:YN /N -IF ERRORLEVEL 2 GOTO INSTALL_BATCH_FILES +ECHO Updating to: SET MACHINE=%MACHINE% +ECHO. +REM Remove old SET MACHINE= line and insert new one at beginning +ECHO @ECHO OFF > C:\AUTOEXEC.TMP +ECHO SET MACHINE=%MACHINE% >> C:\AUTOEXEC.TMP + +REM Append rest of AUTOEXEC.BAT, excluding @ECHO OFF and old SET MACHINE= lines +TYPE C:\AUTOEXEC.BAT | FIND /V "@ECHO OFF" | FIND /V "SET MACHINE=" >> C:\AUTOEXEC.TMP + +REM Replace original with updated version +COPY C:\AUTOEXEC.TMP C:\AUTOEXEC.BAT >NUL +DEL C:\AUTOEXEC.TMP + +ECHO [OK] Updated AUTOEXEC.BAT with new machine name +ECHO (Replaced old value, inserted at beginning) ECHO. -ECHO Manual edit required: -ECHO 1. Edit C:\AUTOEXEC.BAT -ECHO 2. Find line: SET MACHINE=... -ECHO 3. Change to: SET MACHINE=%MACHINE% -ECHO 4. Save and reboot -ECHO. -PAUSE GOTO INSTALL_BATCH_FILES :AUTOEXEC_ERROR diff --git a/deploy-to-ad2.ps1 b/deploy-to-ad2.ps1 new file mode 100644 index 0000000..1c25bf8 --- /dev/null +++ b/deploy-to-ad2.ps1 @@ -0,0 +1,59 @@ +# Deploy fixed BAT files to AD2 via WinRM +# This prevents sync from overwriting our DOS 6.22 fixes + +$BATFiles = @( + "DEPLOY.BAT", + "UPDATE.BAT", + "NWTOC.BAT", + "CTONW.BAT", + "CHECKUPD.BAT", + "REBOOT.BAT", + "STAGE.BAT", + "DOSTEST.BAT", + "AUTOEXEC.BAT", + "STARTNET.BAT" +) + +Write-Host "[INFO] Deploying fixed BAT files to AD2" -ForegroundColor Cyan +Write-Host "" + +# Create credential +$Password = ConvertTo-SecureString "AZC0mpGuru!2024" -AsPlainText -Force +$Credential = New-Object System.Management.Automation.PSCredential("guru", $Password) + +# Create session +Write-Host "Connecting to AD2..." -ForegroundColor White +$Session = New-PSSession -ComputerName ad2 -Credential $Credential -ErrorAction Stop +Write-Host "[OK] Connected to AD2" -ForegroundColor Green +Write-Host "" + +$TotalCopied = 0 + +foreach ($File in $BATFiles) { + $LocalPath = "D:\ClaudeTools\$File" + + if (-not (Test-Path $LocalPath)) { + Write-Host "[SKIP] $File - not found locally" -ForegroundColor Yellow + continue + } + + Write-Host "Copying: $File" -ForegroundColor White + + try { + Copy-Item $LocalPath -Destination "C:\scripts\sync-copies\bat-files\" -ToSession $Session -ErrorAction Stop + Write-Host " [OK] Copied to AD2" -ForegroundColor Green + $TotalCopied++ + } catch { + Write-Host " [ERROR] Failed: $_" -ForegroundColor Red + } +} + +# Close session +Remove-PSSession $Session + +Write-Host "" +Write-Host "[SUCCESS] Copied $TotalCopied files to AD2" -ForegroundColor Green +Write-Host "" +Write-Host "AD2 path: C:\scripts\sync-copies\bat-files\" -ForegroundColor Cyan +Write-Host "Next sync will deploy these fixed versions to NAS" -ForegroundColor Cyan +Write-Host ""