2013-03-08 104 views
0

我试图建立一个批处理文件脚本,该脚本将复制为Outlook.pst文件,从用户的My Documents文件夹,并将其移动到服务器,我已经映射为一个驱动器, “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文件,它只是一遍又一遍地运行命令再次,直到我按Ctrl + C它...

由于

+0

只是出于好奇,有没有使用了'xcopy'而不是原因'copy'? – rojo 2013-03-08 12:39:48

回答

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

我希望为Outlook.pst从微软默认位置使用批处理文件在Windows XP中复制 到记忆棒,我发现XCOPY未能为Outlook.pst复制到记忆棒或我的文档

我现在XCOPY它在2个步骤,首先将C:\,然后到记忆棒

它工作可靠