Trädvy Permalänk
Medlem
Plats
sverige
Registrerad
Mar 2008

windows backupscript

Håller på och meckar ihop ett backupscript i windows där man får välja vilken extern källa man vill kopiera till.

Hittills ser koden ut såhär:

@echo off :start echo. echo Please type your flash drive letter (D - Z) and press Enter set /p drive= if ‘%drive%’ == ‘D’ goto download if ‘%drive%’ == ‘E’ goto download if ‘%drive%’ == ‘F’ goto download if ‘%drive%’ == ‘G’ goto download if ‘%drive%’ == ‘H’ goto download if ‘%drive%’ == ‘I’ goto download if ‘%drive%’ == ‘J’ goto download if ‘%drive%’ == ‘K’ goto download if ‘%drive%’ == ‘L’ goto download if ‘%drive%’ == ‘M’ goto download if ‘%drive%’ == ‘N’ goto download if ‘%drive%’ == ‘O’ goto download if ‘%drive%’ == ‘P’ goto download if ‘%drive%’ == ‘Q’ goto download if ‘%drive%’ == ‘R’ goto download if ‘%drive%’ == ‘S’ goto download if ‘%drive%’ == ‘T’ goto download if ‘%drive%’ == ‘U’ goto download if ‘%drive%’ == ‘V’ goto download if ‘%drive%’ == ‘W’ goto download if ‘%drive%’ == ‘X’ goto download if ‘%drive%’ == ‘Y’ goto download if ‘%drive%’ == ‘Z’ goto download if ‘%drive%’ == ‘d’ goto download if ‘%drive%’ == ‘e’ goto download if ‘%drive%’ == ‘f’ goto download if ‘%drive%’ == ‘g’ goto download if ‘%drive%’ == ‘h’ goto download if ‘%drive%’ == ‘i’ goto download if ‘%drive%’ == ‘j’ goto download if ‘%drive%’ == ‘k’ goto download if ‘%drive%’ == ‘l’ goto download if ‘%drive%’ == ‘m’ goto download if ‘%drive%’ == ‘n’ goto download if ‘%drive%’ == ‘o’ goto download if ‘%drive%’ == ‘p’ goto download if ‘%drive%’ == ‘q’ goto download if ‘%drive%’ == ‘r’ goto download if ‘%drive%’ == ‘s’ goto download if ‘%drive%’ == ‘t’ goto download if ‘%drive%’ == ‘u’ goto download if ‘%drive%’ == ‘v’ goto download if ‘%drive%’ == ‘w’ goto download if ‘%drive%’ == ‘x’ goto download if ‘%drive%’ == ‘y’ goto download if ‘%drive%’ == ‘z’ goto download cls goto error :error echo. echo That drive letter was not recognized. Let's try again... echo. pause cls goto start :download set backupcmd=%drive%:\reinstall\xcopy /c /e /h /i /r /y cls mkdir %drive%:\reinstall\"%username%" :notes mkdir %drive%:\reinstall\"%username%"\notes %backupcmd% "C:\Program Files\IBM\Lotus\Notes" %drive%:\reinstall\"%username%"\notes\ :mydocuments mkdir %drive%:\reinstall\"%username%"\mydocuments %backupcmd% "C:\Documents and Settings\%username%\My Documents\" %drive%:\reinstall\%username%\mydocuments\ pause exit

Den fastnar på my documents kopieringen.
Notes data mappen går bra att kopiera men när den ska kopiera my documents så får jag "Invalid number of parameters". Hur jag kan få det? Det är väll samma parameters som vid första kopieringen? Klagar den på sökvägen?

Trädvy Permalänk
Medlem
Plats
Uppsala
Registrerad
Jul 2008

"%userprofile%\My Documents\"

Blir kortare än det du hade från början iaf.

Varför har du citattecken kring %username%?

mkdir "%drive%:\reinstall\%username%\mydocuments" %backupcmd% "%userprofile%\My Documents\" "%drive%:\reinstall\%username%\mydocuments\"

Sen är det väl bättre att ha

if not exist "%drive%:\reinstall\%username%\mydocuments" then md "%drive%:\reinstall\%username%\mydocuments" else goto :something