Solution Update for index.exe

The thread has a solution

leo4u

New member
i have a problem to stop the program, make a update, and restart the program.
i use the HTTPserver on Port 8080 with automated start option for the index.exe

i have everything ready to make automated updates for my software
i call from php a batch. that call an powerscript.
then i make the StopMyHTTPServer
then i make the StopMyApp

the program closed from the hescript
the powerscript starts to work

The powerscript stops the service, if one.
copy the new version over the old version
start service, if one
restart the program (index.exe new version)

But i get an error. everything i try. i get the same Error.
the new version starts, but i get the Error and the http server did not work.

Error Message 1: Could not bind socket
Eroor Message 2: Could not start the external HTTP server

The new index.exe starts an run.
But no HTTP server.
And i need the HTTP Server

procedure StopMyHTTPServer;
begin
// Stops the HTTP server
StopHTTPServer;
end;

procedure StopMyApp;
begin
// Stops the App
ExitPublication;
end;
 
Last edited:
You should avoid using port 8080 because it is reserved by servers such as IIS on Windows. Moreover, some antivirus will classify your EXE file as malware just by using this common port.
Please try with another port to see if the error persists.
 
Hi! Did you manage to solve the update issue? I did it via bat, but the first launch always hangs on Just a moment, please, the second one is successful.
 
I did it with powerscript.
The application run as service and intranet server.
Can you share an example?
Also sometimes there is an error when loading after an update "Could not bind socket" and "Could not start the external HTTP server".
 
# ------------------ VARIABLEN ------------------
$exePath = "{old_prog}"
$newExePath = "{new_prog}"
$logFile = "{base_path}update.log"
$reportFile = "{base_path}update.txt"
$serviceName = "{dienst}"
$windowTitle = "{title}"
$checkPath = "{check_path}"
$checkPort =" {port}"
$selfPID = $PID # PID des aktuellen Skripts
$processName = [System.IO.Path]::GetFileNameWithoutExtension($exePath)
# ------------------ FUNKTIONEN ------------------
# Loggen von Nachrichten mit Zeitstempel und Pfadangaben
function Write-Log {
param ([string]$message)
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$logMessage = "$timestamp - $message"

# Log in Datei schreiben
$logMessage | Out-File -Append -Encoding utf8 $logFile
}
# Überprüfen, ob das Skript als Administrator läuft
function Test-AdminRights {
return ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
# Skript mit Admin-Rechten neu starten
function Request-AdminRights {
Write-Log "[INFO] Adminrechte erforderlich – Skript wird neu gestartet."
$procArgs = @{
FilePath = 'powershell.exe'
ArgumentList = "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`""
Verb = 'RunAs'
WindowStyle = 'Normal'
}
Start-Process @procArgs
exit
}
# Dienststatus abrufen
function Get-ServiceStatus {
try {
$service = Get-Service -Name $serviceName -ErrorAction Stop
return $service.Status
} catch {
Write-Log "[WARN] Dienst '$serviceName' nicht gefunden: $_"
return $null
}
}
# Datei ersetzen mit detailliertem Check
function Update-Exe {
try {
# Backup der alten Datei
if (Test-Path $exePath) {
Write-Log "[INFO] Erstelle Backup von '$exePath'..."
$backupPath = "$exePath.bak"
Move-Item -Path $exePath -Destination $backupPath -Force -ErrorAction Stop
Write-Log "[INFO] Backup erstellt: $backupPath"
}
# Kopiere neue Datei
Write-Log "[INFO] Kopiere '$newExePath' nach '$exePath'..."
Copy-Item -Path $newExePath -Destination $exePath -Force -ErrorAction Stop
# Erfolgsprüfung
if (Test-Path $exePath) {
$oldHash = (Get-FileHash $newExePath -Algorithm SHA256).Hash
$newHash = (Get-FileHash $exePath -Algorithm SHA256).Hash
if ($oldHash -eq $newHash) {
Write-Log "[SUCCESS] Datei erfolgreich ersetzt (Hash validiert)."
} else {
Write-Log "[ERROR] Datei kopiert, aber Hash stimmt nicht überein!"
}
} else {
Write-Log "[ERROR] Datei konnte nicht kopiert werden: '$exePath'"
}
} catch {
Write-Log "[ERROR] Fehler beim Aktualisieren: $_"
}
}
# ------------------ HAUPTLOGIK ------------------
Write-Log "[INFO] Warte - damit die Webseite noch angezeigt wird"
Start-Sleep -Seconds 8
# Adminrechte prüfen und ggf. anfordern
if (-not (Test-AdminRights)) {
Write-Log "[INFO] Admin Rechte angefordert"
Request-AdminRights
}
Write-Log "[INFO] Skript gestartet. Ziel: '$exePath'"
# Dienststatus merken
$serviceStatus = Get-ServiceStatus
Write-Log "[INFO] Dienststatus '$serviceName': $serviceStatus"
# Dienst stoppen, falls er läuft
if ($serviceStatus -eq 'Running') {
Write-Log "[INFO] Stoppe Dienst '$serviceName'..."
Stop-Service -Name $serviceName -Force
Start-Sleep -Seconds 5
}
# Datei aktualisieren
Update-Exe
# Dienst bei Bedarf neu starten
if ($serviceStatus -eq 'Running') {
Write-Log "[INFO] Starte Dienst '$serviceName'..."
Start-Service -Name $serviceName
# Dienststatus nach dem Start prüfen
$newServiceStatus = Get-ServiceStatus
if ($newServiceStatus -eq 'Running') {
Write-Log "[SUCCESS] Dienst '$serviceName' wurde erfolgreich gestartet."
} else {
Write-Log "[ERROR] Dienst '$serviceName' konnte nicht gestartet werden."
}
}
# Zweite Überprüfung des Dienstes (nochmals stoppen und starten)
# Write-Log "[INFO] Stoppe Dienst '$serviceName' zur Sicherheit..."
# Stop-Service -Name $serviceName -Force
# Start-Sleep -Seconds 5
# Write-Log "[INFO] Starte Dienst '$serviceName' erneut zur Sicherheit..."
# Start-Service -Name $serviceName
# Abschlussbericht
$finalCheck = Test-Path $exePath
$finalStatus = if ($finalCheck) { "[SUCCESS] '$exePath' existiert" } else { "[ERROR] '$exePath' fehlt" }
$reportMessage = "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') - Update Status: $finalStatus"
$reportMessage | Out-File -Encoding utf8 $reportFile
Write-Log "[INFO] Skript beendet. Status: $finalStatus"
 
Back
Top