标题: [系统相关] [求助]批处理代码无法在开关机脚步运行 [打印本页]
作者: crist 时间: 2012-11-9 16:45 标题: [求助]批处理代码无法在开关机脚步运行
做了个清理chrome垃圾的批处理,代码如下:- @echo off
- title %~n0
-
- if exist "%userprofile%\Local Settings\Application Data\Google\Chrome" (
- del/f/q/s/a "%userprofile%\Local Settings\Application Data\Google\Chrome\User Data\*Archived*" >nul 2>nul
- del/f/q/s/a "%userprofile%\Local Settings\Application Data\Google\Chrome\User Data\*Cookies*" >nul 2>nul
- del/f/q/s/a "%userprofile%\Local Settings\Application Data\Google\Chrome\User Data\*History*" >nul 2>nul
- del/f/q/s/a "%userprofile%\Local Settings\Application Data\Google\Chrome\User Data\*Index*" >nul 2>nul
- del/f/q/s/a "%userprofile%\Local Settings\Application Data\Google\Chrome\User Data\*journal*" >nul 2>nul
- del/f/q/s/a "%userprofile%\Local Settings\Application Data\Google\Chrome\User Data\*Links*" >nul 2>nul
- del/f/q/s/a "%userprofile%\Local Settings\Application Data\Google\Chrome\User Data\*Session*" >nul 2>nul
- del/f/q/s/a "%userprofile%\Local Settings\Application Data\Google\Chrome\User Data\*Shortcuts*" >nul 2>nul
- del/f/q/s/a "%userprofile%\Local Settings\Application Data\Google\Chrome\User Data\*Sites*" >nul 2>nul
- del/f/q/s/a "%userprofile%\Local Settings\Application Data\Google\Chrome\User Data\*Tabs*" >nul 2>nul
- del/f/q/s/a "%userprofile%\Local Settings\Application Data\Google\Chrome\User Data\*.bak" >nul 2>nul
-
- for /f "delims=" %%a in ('dir/ad/b/s "%userprofile%\local settings\application data\google\chrome\*cache*"') do (if exist "%%a" rd/q/s "%%a")>NUL 2>NUL
- for /f "delims=" %%b in ('dir/ad/b/s "%userprofile%\local settings\application data\google\chrome\*databases*"') do (if exist "%%b" rd/q/s "%%b")>NUL 2>NUL
- for /f "delims=" %%c in ('dir/ad/b/s "%userprofile%\local settings\application data\google\chrome\*Local Storage*"') do (if exist "%%c" rd/q/s "%%c")>NUL 2>NUL
- for /f "delims=" %%d in ('dir/ad/b/s "%userprofile%\local settings\application data\google\chrome\*Media Cache*"') do (if exist "%%d" rd/q/s "%%d")>NUL 2>NUL
- )
- pause
复制代码
我的问题是:为何在Windows环境可以正常清理垃圾的这个代码,放在开关机脚本中运行却没有效果呢?
作者: Demon 时间: 2012-11-9 17:05
关机脚本的%userofile%不一样
作者: crist 时间: 2012-11-9 17:30
回复 2# Demon
那么我将代码改成以下可以吗?- @echo off
- title %~n0
-
- for /f "delims=" %%i in ('dir/ad/b/s/o "%systemdrive%\Chrome"') do (
- if not exist "%%i\Application" if exist "%%i\User Data" (
- set chrometemp="%%i\User Data"
- del/f/q/s/a "%chrometemp%\*Archived*" >nul 2>nul
- del/f/q/s/a "%chrometemp%\*Cookies*" >nul 2>nul
- del/f/q/s/a "%chrometemp%\*History*" >nul 2>nul
- del/f/q/s/a "%chrometemp%\*Index*" >nul 2>nul
- del/f/q/s/a "%chrometemp%\*journal*" >nul 2>nul
- del/f/q/s/a "%chrometemp%\*Links*" >nul 2>nul
- del/f/q/s/a "%chrometemp%\*Session*" >nul 2>nul
- del/f/q/s/a "%chrometemp%\*Shortcuts*" >nul 2>nul
- del/f/q/s/a "%chrometemp%\*Sites*" >nul 2>nul
- del/f/q/s/a "%chrometemp%\*Tabs*" >nul 2>nul
- del/f/q/s/a "%chrometemp%\*.bak" >nul 2>nul
-
- for /f "delims=" %%a in ('dir/ad/b/s "%%i\*cache*"') do (if exist "%%a" rd/q/s "%%a")>NUL 2>NUL
- for /f "delims=" %%b in ('dir/ad/b/s "%%i\*databases*"') do (if exist "%%b" rd/q/s "%%b")>NUL 2>NUL
- for /f "delims=" %%c in ('dir/ad/b/s "%%i\*Local Storage*"') do (if exist "%%c" rd/q/s "%%c")>NUL 2>NUL
- for /f "delims=" %%d in ('dir/ad/b/s "%%i\*Media Cache*"') do (if exist "%%d" rd/q/s "%%d")>NUL 2>NUL
- )
- )
- pause
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |