더보기
@prompt $s
@color 1f
@title WinSxS 폴더 DISM 으로 정리하기
@mode con cols=170 lines=1000
@setlocal enabledelayedexpansion
@echo 관리자권한 확인용 >%windir%\admin.confirm || @(
echo Set UAC = CreateObject^("Shell.Application"^) > "%tmp%\admin.vbs"
echo UAC.ShellExecute "%~0", "", "", "runas", 1 >> "%tmp%\admin.vbs"
"%tmp%\admin.vbs" & del "%tmp%\admin.vbs" & exit)
@del %windir%\admin.confirm
@echo.
@echo.
@echo. ===============================================
@echo. WinSxS 폴더를 DISM 으로 정리합니다
@echo. ===============================================
@echo.
@pause
@set build=0
@for /f "tokens=3 delims=.]" %%a in ('ver') do @set build=%%a
@if %build% lss 9200 (
@echo.
@echo. ===============================================
@echo. Windows 8 부터 적용됩니다
@echo. ===============================================
@echo.
@pause
@exit
)
@echo.
@echo.-----------------------------------------------------------------------------------------------------
@echo.
@call :start_time
@echo.
@echo.-----------------------------------------------------------------------------------------------------
@echo.
@echo. ==========================================================================
@echo. [최적화 전] WinSxS 폴더 분석과 %Systemdrive% 의 남은 용량입니다
@echo. ==========================================================================
@echo.
Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore
dir %Systemdrive%\ | findstr /i "free 남음"
@echo.
@echo.-----------------------------------------------------------------------------------------------------
@echo.
@call :check_time
@echo.
@echo.-----------------------------------------------------------------------------------------------------
@echo.
@echo. ============================================
@echo. WinSxS 폴더를 최적화 합니다
@echo. ============================================
@echo.
Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
@echo.
@echo.-----------------------------------------------------------------------------------------------------
@echo.
@call :check_time
@echo.
@echo.-----------------------------------------------------------------------------------------------------
@echo.
@echo. ==========================================================================
@echo. [최적화 후] WinSxS 폴더 분석과 %Systemdrive% 의 남은 용량입니다
@echo. ==========================================================================
@echo.
Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore
dir %Systemdrive%\ | findstr /i "free 남음"
@echo.
@echo.-----------------------------------------------------------------------------------------------------
@echo.
@call :check_time
@echo.
@echo.-----------------------------------------------------------------------------------------------------
@echo.
@set msg=윈도 업데이트 후에 WinSxS 폴더를 최적화했습니다. 작업시간:%h%시%m%분%s%초
@echo.
@echo. ===============================================================================
@echo. %msg%
@echo. ===============================================================================
@echo.
@echo.
@call :msgbox
@echo.
@pause
@exit
:start_time
@for /f "tokens=1-3 delims=-/. " %%a in ('Date /T') do @set start_date=%%a-%%b-%%c
@echo.
@echo. ==================================
@echo. 시작날짜: %start_date%
@echo. ==================================
@for /f "tokens=1-3 delims=:." %%a in ("%time%") do @(
set h=%%a
set m=%%b
set s=%%c
set start_time=!h!시!m!분!s!초![24시]
if "!h:~0,1!" == "0" set h=!h:~-1!
if "!m:~0,1!" == "0" set m=!m:~-1!
if "!s:~0,1!" == "0" set s=!s:~-1!
set /a time1=!h!*3600+!m!*60+!s!
)
@echo. 시작시간:%start_time%
@echo. ==================================
@exit /b
:check_time
@echo. ==================================
@echo. 시작시간:%start_time%
@echo. ==================================
@for /f "tokens=1-3 delims=:." %%a in ("%time%") do @(
set h=%%a
set m=%%b
set s=%%c
set check_time=!h!시!m!분!s!초[24시]
if "!h:~0,1!" == "0" set h=!h:~-1!
if "!m:~0,1!" == "0" set m=!m:~-1!
if "!s:~0,1!" == "0" set s=!s:~-1!
set /a time2=!h!*3600+!m!*60+!s!
)
@echo. 확인시간:%check_time%
@echo. ==================================
@if %time2% GEQ %time1% set /a elapsed=%time2%-%time1%
@if not %time2% GEQ %time1% set /a elapsed=86400-(%time1%-%time2%)
@set /a h=elapsed/3600, rest=elapsed%%3600, m=rest/60, s=rest%%60
@set h=%h%시
@if "!h:~1,1!" == "시" (set h= !h:~0,1!) else (set h=!h:~0,2!)
@set m=%m%분
@if "!m:~1,1!" == "분" (set m= !m:~0,1!) else (set m=!m:~0,2!)
@set s=%s%초
@if "!s:~1,1!" == "초" (set s= !s:~0,1!) else (set s=!s:~0,2!)
@echo. 작업시간:%h%시%m%분%s%초
@echo. ==================================
@exit /b
:msgbox
@(
if exist %windir%\Temp\청소알림창.vbs del /f/a/q %windir%\Temp\청소알림창.vbs
>>%windir%\Temp\청소알림창.vbs echo.k=0
>>%windir%\Temp\청소알림창.vbs echo.call Main
>>%windir%\Temp\청소알림창.vbs echo.Sub Main
>>%windir%\Temp\청소알림창.vbs echo.msg = MsgBox^("%msg%", vbOkCancel+vbDefaultButton2+ vbSystemModal, "청소 알림창"^)
>>%windir%\Temp\청소알림창.vbs echo.If msg = vbYes Then
>>%windir%\Temp\청소알림창.vbs echo.WScript.Quit
>>%windir%\Temp\청소알림창.vbs echo.ElseIf msg = vbCancel Then
>>%windir%\Temp\청소알림창.vbs echo.k=k+1
>>%windir%\Temp\청소알림창.vbs echo.If k=3 Then
>>%windir%\Temp\청소알림창.vbs echo.WScript.Quit
>>%windir%\Temp\청소알림창.vbs echo.ElseIf k^<3 Then
>>%windir%\Temp\청소알림창.vbs echo.WScript.Sleep 1000
>>%windir%\Temp\청소알림창.vbs echo.call Main
>>%windir%\Temp\청소알림창.vbs echo.End If
>>%windir%\Temp\청소알림창.vbs echo.End If
>>%windir%\Temp\청소알림창.vbs echo.End Sub
wscript %windir%\Temp\청소알림창.vbs
)
@exit /b