09. november 2006 - 14:05Der er
5 kommentarer og 1 løsning
backup scirpt på XP
Hej alle
jeg er ved at lave et script der skal tage backup af Favorites, my documents og desktoppen for derefter at kopiere dem til et netdrev, men hvorfor sletter den hele tiden desktop folderen på netværket efter kopiering ??
@echo off setlocal set DefaultDocAndSet=%USERPROFILE:~0,3% set DefaultBackup=D:\Backup if [%temp%]==[] set TempFile=c:\temp.tmp.tmp if NOT [%temp%]==[] set TempFile=%temp%\temp.tmp.tmp
set PassOver=All Users Default User
:MainMenu cls set ValidChoice=SBR set Choice= echo. echo - Hoved menu - echo. echo S = Slut echo B = Backup echo R = Restore echo. set /p Choice="Indtast dit Valg: " if {%Choice%}=={} goto MainMenu call set Test=%%ValidChoice:%Choice:~0,1%=%% if "%Test%" EQU "%ValidChoice%" goto MainMenu goto MainChoice-%Choice:~0,1%
:MainChoice-S goto :EOF
:MainChoice-B set Task=Backup set FromDrive=%DefaultDocAndSet% call :GetBackupPath if /I [%VerifyAnswer%]==[f] goto :MainMenu set LogTxt=%Task% log: %date% %time% set LogTxt=%LogTxt:~0,-3% set logFile=%ToDrive%%Task%.txt goto :SubMenu
:MainChoice-R set Task=Restore set ToDrive=%DefaultDocAndSet% call :GetBackupPath if /I [%VerifyAnswer%]==[f] goto :MainMenu set LogTxt=%Task% log: %date% %time% set LogTxt=%LogTxt:~0,-3% set logFile=%ToDrive%%Task%.txt goto :SubMenu
:SubMenu cls set ValidChoice=SHA set Choice= set /a Counter=0 echo. echo - %Task% menu - echo. echo S = Slut echo H = Hoved menu echo A = Alle brugere for /f "delims=" %%a in ('dir /A:D/B "%FromDrive%Documents and Settings/"') do ( echo %PassOver% | find "%%a" >nul if errorlevel 1 call :WriteSubMenu "%%a" ) echo. set /p Choice="Indtast dit Valg: " if {%Choice%}=={} goto SubMenu call set Test=%%ValidChoice:%Choice%=%% if "%Test%" EQU "%ValidChoice%" goto SubMenu if "%Choice:~0,1%" GTR "9" goto SubChoice-%Choice:~0,1% call :FindUser %Choice% goto SubMenu
:SubChoice-H goto :MainMenu
:SubChoice-S goto :EOF
:SubChoice-A call :CopyAllUsers goto :SubMenu
:WriteSubMenu set /a Counter+=1 set Name=%1 echo %Counter% = %Name:"=% set ValidChoice=%ValidChoice%%Counter% goto :EOF
:FindUser set /a Counter=0 for /f "delims=" %%a in ('dir /A:D/B "%FromDrive%Documents and Settings/"') do ( echo %PassOver% | find "%%a" >nul if errorlevel 1 call :CopyUser %1 "%%a" ) goto :EOF
:CopyUser set User=%2 set User=%User:"=% set /a Counter+=1 if not %Counter% EQU %1 goto :eof
cls echo. echo Starter %Task% af "%User%". echo. echo Tast Ctrl+c for at afbryde. echo %LogTxt% > %logFile% echo. >>%logFile% set /A NumError = 0 set /A NumFiles = 0 if exist [%TempFile%] del [%TempFile%] call :CopySingleUser "%User%" echo Antal fejl: %NumError% Filer kopieret: %NumFiles% >>%logFile% cls echo. echo F‘rdig, tryk p† en tast! pause >nul start Notepad %logFile% goto :EOF
:CopyAllUsers cls echo. echo Starter %Task% af "Alle brugere". echo. echo Tast Ctrl+c for at afbryde. echo %LogTxt% > %logFile% echo. >>%logFile% set /A NumError = 0 set /A NumFiles = 0 if exist [%TempFile%] del [%TempFile%] for /f "delims=" %%a in ('dir /A:D/B "%FromDrive%Documents and Settings/"') do call :CopyThisUser "%%a" echo Antal fejl: %NumError% Filer kopieret: %NumFiles% >>%logFile% cls echo. echo F‘rdig, tryk p† en tast! pause >nul start Notepad %logFile% goto :EOF
:GetBackupPath set BD= Echo Tast enter, hvis du bruger [%DefaultBackup%] ellers indtast en ny :NewBackupPath set /P BD="Indtast Backup sti: " if [%BD%]==[] set BD=%DefaultBackup% if NOT [%BD:~1,1%]==[:] set BD=%BD%: if NOT [%BD:~-1%]==[\] set BD=%BD%\ call :VerifyBackup %BD% if [%VerifyAnswer%]==[n] goto :NewBackupPath if [%VerifyAnswer%]==[c] goto :NewBackupPath if [%VerifyAnswer%]==[f] goto :eof
if [%Task%]==[Backup] ( set ToDrive=%BD% ) else ( set FromDrive=%BD% ) set BD= goto :eof
:UpdateStat for /F %%I in (%TempFile%) do set xxx=%%I type %TempFile%>> %logFile% del %TempFile% if [%xxx%]==[0] set /A NumError += 1 if not [%xxx%]==[0] set /A NumFiles += %xxx% set xxx= goto :eof
:CopyThisUser echo %PassOver% | find %1 >nul if not errorlevel 1 goto :eof :CopySingleUser echo Kopierer filer fra %FromDrive% til %ToDrive% for %~1 >>%logFile% echo. >>%logFile% xcopy "%FromDrive%Documents and Settings\%~1\Lokale indstillinger\Application Data\Microsoft\Outlook" "%ToDrive%Documents and Settings\%~1\Lokale indstillinger\Application Data\Microsoft\Outlook" /s/e/h/k/y/i/f/r/o/c >%TempFile% 2>&1 call :UpdateStat xcopy "%FromDrive%Documents and Settings\%~1\Foretrukne" "%ToDrive%Documents and Settings\%~1\Foretrukne" /s/e /h/k/y/i/f/r/o/c >%TempFile% 2>&1 call :UpdateStat xcopy "%FromDrive%Documents and Settings\%~1\Dokumenter" "%ToDrive%Documents and Settings\%~1\Dokumenter" /s/e/h/k/y/i/f/r/o/c >%TempFile% 2>&1 call :UpdateStat xcopy "%FromDrive%Documents and Settings\%~1\Application Data\Microsoft\Address Book" "%ToDrive%Documents and Settings\%~1\Application Data\Microsoft\Address Book" /s/e/h/k/y/i/f/r/o/c >%TempFile% 2>&1 call :UpdateStat xcopy "%FromDrive%Documents and Settings\%~1\Skrivebord" "%ToDrive%Documents and Settings\%~1\Skrivebord" /s/e/h/k/y/i/f/r/o/c >%TempFile% 2>&1 call :UpdateStat xcopy "%FromDrive%Documents and Settings\%~1\Application Data\Microsoft\Outlook" "%ToDrive%Documents and Settings\%~1\Application Data\Microsoft\Outlook" /s/e/h/k/y/i/f/r/o/c >%TempFile% 2>&1 call :UpdateStat echo. >>%logFile% goto :eof
:VerifyBackup set VerifyAnswer=j if exist %1. goto :eof if [%task%]==[Restore] goto :AskRestore %1 set Answer= set /P Answer="Stien %1 findes ikke, skal den oprettes [Ja/Nej/Fortryd]: " if /I [%Answer%]==[n] set VerifyAnswer=n& goto :eof if /I [%Answer%]==[nej] set VerifyAnswer=n& goto :eof if /I [%Answer%]==[j] goto :AnswerOk if /I [%Answer%]==[ja] goto :AnswerOk if /I [%Answer%]==[f] set VerifyAnswer=f& goto :eof if /I [%Answer%]==[fortryd] set VerifyAnswer=f& goto :eof echo Ugyldig svar &goto :VerifyBackup
:AnswerOk md %1 >nul 2>&1 if exist %1. goto :eof :AnswerNotOk set Answer= set /P Answer="Kunne ikke oprette stien %1, vil du v‘lge en ny [Ja/Fortryd]: " if /I [%Answer%]==[j] set VerifyAnswer=c& goto :eof if /I [%Answer%]==[ja] goto VerifyAnswer=c& goto :eof if /I [%Answer%]==[f] set VerifyAnswer=f& goto :eof if /I [%Answer%]==[fortryd] set VerifyAnswer=f& goto :eof echo Ugyldig svar& goto :AnswerNotOk goto :eof
:AskRestore set Answer= set /P Answer="Stien %1 findes ikke, vil du v‘lge en ny [Ja/Fortryd]: " if /I [%Answer%]==[j] set VerifyAnswer=n& goto :eof if /I [%Answer%]==[ja] set VerifyAnswer=n& goto :eof if /I [%Answer%]==[f] set VerifyAnswer=f& goto :eof if /I [%Answer%]==[fortryd] set VerifyAnswer=f& goto :eof echo Ugyldig svar &goto :AskRestore
jeg har et lille problem det er når jeg går ind i explore 7 og skal gå ind i chatten på jubii så kommer den med Your scripting is turned off. Please go here to fix it. når man ikke er god til engelsk så hjælper det heller ikke så´n noget her hilsen stefan (mgholme) p.s håber du kan jeg hjælpe mmig
denne er ikek længere relevant da jeg har skiftet job
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.