2013-03-08 2 views
0

outlook.pst 파일을 사용자의 내 문서 폴더에서 복사하여 드라이브로 매핑 한 서버로 옮기는 배치 파일 스크립트를 작성하려고합니다. "B : \"xcopy 배치 파일 pst 백업

@echo on 
xcopy "c:\Documents and Settings\%username%\My Documents\outlook.pst" "B:\PST\%username%\" -c -d -i -y 
exit 

스크립트는 Windows XP 용 설계

이것은 내가 지금까지 가지고있는 코드입니다. 나는 클라이언트 시스템에이 코드를 실행하면

그러나, 그것은 단지, 또 다시 명령을 실행에서 .pst 파일을 복사하지 않습니다 I Ctrl + C 그것 ... 때까지

감사합니다

+0

을 일했다

메모리 스틱에, 당신보다는'xcopy'를 사용하는 이유가있다 '복사? – rojo

답변

0

정확하게 기억한다면 PST 파일의 기본 위치는 %localappdata%\Microsoft\Outlook\입니다. 그리고 사용자가 여러 위치에 PST 파일을 가지고 있다면 다른 폴더에있는 동일한 이름을 가진 폴더가 둘 이상있을 수 있습니다. 좋은 시간.

사용자가 My Documents 이외의 위치에 PST 파일을 가지고있을 가능성이있는 경우 몇 가지 사소한 변경만으로 스크립트를 수정하는 것이 좋습니다.

@echo off 
setlocal enabledelayedexpansion 
for /r "%userprofile%" %%I in (*.pst) do (

    rem avoid overwriting in case "outlook.pst" exists in two locations, for instance 
    if exist "B:\PST\%username%\%%~nxI" (
     set cnt=000 

     rem get count of files matching b:\pst\username\filename*.pst 
     for /f %%a in ('dir "B:\PST\%username%\%%~nI*%%~xI" 2^>NUL ^| find " File(s) "') do (
      set "cnt=!cnt!%%a" 
     ) 

     rem file of the same name will become filename001.pst, filename002.pst, etc. 
     set "dest=%%~nI!cnt:~-3!%%~xI" 

    rem otherwise leave the filename alone 
    ) else set "dest=%%~nxI" 
    set /P "=Copying !dest!... "<NUL 
    copy "%%~fI" "B:\PST\%username%\!dest!" 
    echo Done. 
) 
0

나는 내가 그 xcopy는 메모리 스틱 또는 내 문서

을에 Outlook.pst는 복사하는 데 실패 발견 윈도우 XP 에 배치 파일을 사용하여 메모리 스틱은 마이크로 소프트의 기본 위치에서 Outlook.pst는 복사하는 것을 바랬다

지금은 먼저 C에, 2 단계를 XCOPY : \ 다음 그것은 그냥 호기심에서 안정적으로