jausenbrot

Batch-Script für Backup auf USB-Stick

Hey Leute,

ich soll für eine unserer Außenstelle ein kleines Backup-Script schreiben, so dass die Daten bei jedem Logoff gesichert werden. Leider stirbt mein Script immer beim Builden des Ausgabestrings, falls bestimmte Anwendungen noch laufen. Ich kann allerdings keinen Fehler erkennen face-sad

setlocal

set lw=R:\

:checkapps
echo "Pruefe Anwendungen..."
tasklist |find /i "Price32.exe"
set pricerunning=%errorlevel%
tasklist |find /i "dbnt1sv.exe"
set dbrunning=%errorlevel%

echo %pricerunning%
echo %dbrunning%

if %pricerunning%==1 (
if %dbrunning%==1 goto checkdrive
)

set output=Bitte
if %pricerunning%==0 set output=%output%Price
if %pricerunning%==0 ( <---- Sterbepunkt
if %dbrunning==0 (
set output=%output%und
)

if %dbrunning%==0 set output=%output%SQLBase Server
set output=%output%beenden und danach eine Taste drücken...
echo %output%
pause
goto checkapps


:checkdrive
echo "Pruefe Laufwerk..."
if exist %lw% goto backup
echo "Bitte Backup-Laufwerk anschließen und eine Taste druecken..."
pause
goto checkdrive


:backup
echo "Starte Backupvorgang..."
xcopy "%homepath%\Desktop" "%lw%" /S /E /C /H /R /D /Y /EXCLUDE:nocopy.txt
xcopy "%homepath%\Eigene Dateien" "%lw%" /S /E /C /H /R /D /Y /EXCLUDE:nocopy.txt
echo "Backup fertig!"
endlocal
Auf Facebook teilen
Auf X (Twitter) teilen
Auf Reddit teilen
Auf Linkedin teilen

Content-ID: 112444

Url: https://administrator.de/forum/batch-script-fuer-backup-auf-usb-stick-112444.html

Ausgedruckt am: 29.04.2025 um 15:04 Uhr