[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
而且很纳闷, 为啥第19行输出的 都变成了 Public

C:\Users\Public\AppData\Local\Microsoft\Outlook\outlook.ost

TOP

文件还是没删掉....

TOP

回复 6# find

重新改过了.
  1.     @echo off
  2. ::枚举用户文件夹名字写入list.txt
  3. dir /ad /b c:\users > list.txt
  4. Set RootFolder=C:\Users\
  5. Set SubFolder=\AppData\Local\Microsoft\Outlook\
  6. echo %RootFolder%
  7. echo %SubFolder%
  8. ::读取list.txt 连接成绝对路径
  9. for /f %%i in (list.txt) do (
  10. echo %RootFolder%%%i%SubFolder%
  11. :: 连接成为绝对路径, (路径正确如: C:\Users\Default\AppData\Local\Microsoft\Outlook\)
  12. Set MyPath=%RootFolder%%%i%SubFolder%
  13. echo %MyPath%outlook.ost
  14. echo ..
  15. ::判断路径是否存在, 如果存在就做删除操作.
  16. if exist %MyPath%outlook.ost (del /s /f %MyPath%outlook.ost)
复制代码
结果:

C:\Users\
\AppData\Local\Microsoft\Outlook\
C:\Users\All\AppData\Local\Microsoft\Outlook\
C:\Users\Public\AppData\Local\Microsoft\Outlook\outlook.ost
..
C:\Users\Default\AppData\Local\Microsoft\Outlook\
C:\Users\Public\AppData\Local\Microsoft\Outlook\outlook.ost
..
C:\Users\Default\AppData\Local\Microsoft\Outlook\
C:\Users\Public\AppData\Local\Microsoft\Outlook\outlook.ost
..
C:\Users\admin\AppData\Local\Microsoft\Outlook\
C:\Users\Public\AppData\Local\Microsoft\Outlook\outlook.ost
..
C:\Users\Public\AppData\Local\Microsoft\Outlook\
C:\Users\Public\AppData\Local\Microsoft\Outlook\outlook.ost

TOP

回复 5# ppappa2001


等号两边的空格还没有删完

TOP

本帖最后由 ppappa2001 于 2012-2-16 23:30 编辑

去掉过后, 路径对了..


但是在判断文件是否存在时候,  删除动作没执行. 也没报错..

C:\Users\
\AppData\Local\Microsoft\Outlook\
C:\Users\All\AppData\Local\Microsoft\Outlook\
C:\Users\Default\AppData\Local\Microsoft\Outlook\
C:\Users\Default\AppData\Local\Microsoft\Outlook\
C:\Users\admin\AppData\Local\Microsoft\Outlook\
C:\Users\Public\AppData\Local\Microsoft\Outlook\

修改以后的代码如下:
  1. @echo off
  2. ::枚举用户文件夹名字写入list.txt
  3. dir /ad /b c:\users > list.txt
  4. Set RootFolder=C:\Users\
  5. Set SubFolder=\AppData\Local\Microsoft\Outlook\
  6. echo %RootFolder%
  7. echo %SubFolder%
  8. ::读取list.txt 连接成绝对路径
  9. for /f %%i in (list.txt) do (
  10. echo %RootFolder%%%i%SubFolder%
  11. :: 连接成为绝对路径, (路径显示不正确.)
  12. Set MyPath = %RootFolder%%%i%SubFolder%
  13. ::判断路径是否存在, 如果存在就做删除操作.
  14. if exist %MyPth% (del /s /f %MyPath%outlook.ost)
  15. )
  16. PAUSE
复制代码

TOP

回复 3# ppappa2001


连接的时候不需要使用&符号

TOP

回复 2# find


    谢谢Find..   但是执行结果还是不对.  可能是路径连接的地方有问题. 我把变量 这样写echo %RootFolder%&%%i&%SubFolder%, 还是不对... 请指教

list.txt 文件内容是:
All Users
Default
Default User
admin
Public

命令行执行结果如下:

C:\Users\
\AppData\Local\Microsoft\Outlook\
C:\Users\
'All' is not recognized as an internal or external command,operable program or batch file.
'\AppData\Local\Microsoft\Outlook\' is not recognized as an internal or external command,operable program or batch file.
'All' is not recognized as an internal or external command,operable program or batch file.
'\AppData\Local\Microsoft\Outlook\' is not recognized as an internal or external command,operable program or batch file.
C:\Users\
'Default' is not recognized as an internal or external command,operable program or batch file.
'\AppData\Local\Microsoft\Outlook\' is not recognized as an internal or external command,operable program or batch file.
'Default' is not recognized as an internal or external command,operable program or batch file.
'\AppData\Local\Microsoft\Outlook\' is not recognized as an internal or external command,operable program or batch file.
C:\Users\
'Default' is not recognized as an internal or external command,operable program or batch file.
'\AppData\Local\Microsoft\Outlook\' is not recognized as an internal or external command,operable program or batch file.
'Default' is not recognized as an internal or external command,operable program or batch file.
'\AppData\Local\Microsoft\Outlook\' is not recognized as an internal or external command,operable program or batch file.
C:\Users\
'admin' is not recognized as an internal or external command,operable program or batch file.
'\AppData\Local\Microsoft\Outlook\' is not recognized as an internal or external command,operable program or batch file.
C:\Users\
'Public' is not recognized as an internal or external command,operable program or batch file.
'\AppData\Local\Microsoft\Outlook\' is not recognized as an internal or external command,operable program or batch file.
'Public' is not recognized as an internal or external command,operable program or batch file.
'\AppData\Local\Microsoft\Outlook\' is not recognized as an internal or external command,operable program or batch file.

TOP

把等号两边的空格全部删掉

TOP

返回列表