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
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
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
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
Please also mark the comments that contributed to the solution of the article
Content-Key: 112444
Url: https://administrator.de/contentid/112444
Printed on: April 19, 2024 at 11:04 o'clock