Рейтинг темы:
  • 1 Голос(ов) - 1 в среднем
  • 1
  • 2
  • 3
  • 4
  • 5
Error 1719. The Windows Installer Service could not be accessed
#1
Error 1719. The Windows Installer Service could not be accessed. This can occur if you are running Windows in safe mode, or if the Windows installer is not correctly installed. Contact your support personnel for assistance.

Перевод: Установщику Wndows не удается получить доступ. Такое может случаться, если Windows запущен в безопасном режиме, или Установщик Windows неправильно установлен...

С чего все началось: Началось с того, что у меня диск С заполнился до предела. Мне это надоело и как выяснилось, такое большое пространство занимает папка WINSxS, которая была разработана специально на Windows 7, как говорят разработчики "для ускорения производительности" и что она будет постоянно расти.
Но я нашел какой-то *.bat скрипт, с помощью которого освободил 1,5гб на диске С. Тогда я уже понял, что-то нето с системой стало.
Сегодня попытался запустить фотошоп, на что он выбил мне ошибку ссылаясь на Visual C++ Redistributable Package
[Изображение: image.png]
Думаю, дай-ка я переустановлю этот vc++, после чего мне уже выбила ошибка 1719.

Что я побывал сделать:

1. Система загружена не в безопасном режиме
2. Пытался переустановить установщик Windows, но он ссылался либо на то, что эта пакет не подходит для этой версии винды, либо не хватает памяти. Хотя память и на С диске и на ОЗУ предостаточно.
3. Другие программы устанавливаются.

Ничего не помогло. Что можно еще сделать?
Ответ
#2
=) Чем меньше запускаешь какието бат скрипты, тем лучше.
Вообще для чистки системы есть ccleaner например.
Ответ
#3
NanoZet Написал:=) Чем меньше запускаешь какието бат скрипты, тем лучше.
Вообще для чистки системы есть ccleaner например.

Я ожидал это услышать, только у меня не было выбора :redlol: Перебивать систему, которую я недавно поставил тоже не вариант. Касательно ccleaner - он не чистит подобные вещи.
Ответ
#4
Значит и не надо чистить как ты говоришь такие вещи.
Ответ
#5
Забыл упомянуть про связь этого бат скрипта. Дело в том, что "нельзя просто так взять и удалить папку WinSxS". :redlol: А он там видать чего-то лишнего начистил. Хотя может быть дело кроется вовсе в другом.
Ответ
#6
На сколько я помню еще с Висты, подобные вещи (Оптимизаторы поиска, хранение бекапов и прочее), нужно выключать...Ибо системе со временем приедет найс полный Smile
Ответ
#7
KilRoy Написал:На сколько я помню еще с Висты, подобные вещи (Оптимизаторы поиска, хранение бекапов и прочее), нужно выключать...Ибо системе со временем приедет найс полный Smile

а у меня отключены точки восстановления и т. п. ересь, которая переполняет диск С :redlol:

Добавлено через 34 минуты
Новая ошибка.

При попытке удалить (говорит о том что теперь у меня вообще нету виндовс инсталлера):
[Изображение: image.png]

При попытке установить Windows Installer
[Изображение: image.png]
Ответ
#8
Проверь запущена ли служба "Windows Installer".
Да и проще посмотреть внутренность .bat файла чем гадать что он сделал.
Ответ
#9
ExLite Написал:Проверь запущена ли служба "Windows Installer".
Да и проще посмотреть внутренность .bat файла чем гадать что он сделал.

он не запускается.Вначале писал, что не вовремя приложение отвечает. теперь и вовсе исчез из служб.

Добавлено через 11 минут
Вот, то что я юзал http://rghost.ru/40832838

[SPOILER="батник"][HTML]@echo OFF
setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

set DIRCMD=
set home=%~dp0
path %home:~0,-1%;%PATH%

if "%1"=="ProgressWindow" (
set z=%2
title !z:_= !
set InFile=1
for /L %%a IN (1,0,2) DO for %%b IN ("%home%$Out!InFile!.txt") DO if EXIST %%b (
set /A InFile=3-InFile
del /F "%home%$Out!InFile!.txt" >NUL 2>&1
timeout /NOBREAK /T 1 >NUL
if %%~zb==0 (
timeout /NOBREAK /T 5 >NUL
exit
) ELSE if EXIST %%b type %%b
set z=%%~ab
if "!z:~2,1!"=="-" timeout /NOBREAK /T 2 >NUL
) ELSE timeout /NOBREAK /T 1 >NUL
)

title WinsxsLite v1.86

set WinsxsLite="%~f0"
set settings="%home%Config.txt"
set ToDo="%home%ToDo/.txt"
set Redo="%home%ToRedo.txt"
set ToSchedule="%home%ToSchedule.txt"
set important="%home%--IMPORTANT - SDs needed to restore security--.txt"
set unimportant="%home%--SDs that have been used to restore security--.txt"
set log="%home%Log.txt"
set DelMedia="%home%DelWinsxsSampleMedia.bat"
set P1Ext="%home%$Phase1Extensions.txt"
set ABuf="%home%$ABuf.txt"
set BBuf="%home%$BBuf.txt"
set buf="%home%$tmp.txt"

set root=%SYSTEMDRIVE%
set win=%SYSTEMROOT:~3%
set ProgFiles=%PROGRAMFILES:~3%

for /F "delims=." %%a IN ('ver') DO set z=%%a
set NoVista=
if %z:~-1% LSS 6 set NoVista=true
if "%1"=="AutoStart" (
set AutoStarted=true
echo.>>%log%
echo ## %DATE% %TIME%: WinsxsLite auto started on computer startup.>>%log%
) ELSE (
set AutoStarted=
if "%1"=="AutoReboot" (
call :SetStartup
shutdown /R /T 0
exit
)
call :ClearStartup
if "%1"=="ClearAutoStart" exit
)
set z=0
for /F %%a IN ('fsutil') DO set /A z+=1
if %z% LSS 5 (
echo WinsxsLite needs administrative privileges.
echo Right click, and select 'Run as administrator'.
echo.
pause
goto :EOF
)

call :Help NoShow
if NOT EXIST %settings% (
echo :CONFIG VERSION=1.80>%settings%
echo.>>%settings%
echo :ROOT=%root%>>%settings%
echo :WINDOWS DIR=%win%>>%settings%
echo TongueROGRAM FILES DIR=%ProgFiles%>>%settings%
set valid=
for /F "usebackq delims=" %%a IN (%WinsxsLite%) DO if DEFINED valid (
if "%%a"=="Big GrinEFAULTCONFIGEND" (
set valid=
) ELSE echo%%a>>%settings%
) ELSE if "%%a"=="Big GrinEFAULTCONFIGBEGIN" set valid=1
echo Config file missing.
if EXIST %settings% (
echo Example configuration written to %settings%.
) ELSE echo Couldn't write default config to %settings%.
echo.
)
set LangCodenone=000
set LangKeep000=1
set LangNr=999
set version=0
set exclude=
set reloc=
set RelocPaths=
set state=
for /F "usebackq delims== tokens=1*" %%a IN (%settings%) DO (
if /I "%%a"==":eof" goto SettingsDone
if /I "%%a"==":config version" set version=%%b
if /I "%%a"==":root" set root=%%~b
if /I "%%a"==":windows dir" set win=%%~b
if /I "%%a"==":program files dir" set ProgFiles=%%~b
if /I "%%a"=="Confusedearch for sample media in winsxs" set SearchSampleMedia=%%b
if /I "%%a"==":phase 2 language priorities" set state=lp
if /I "%%a"==":phase 1 excludes" set state=p1excl
if /I "%%a"==":relocate folders" (
set reloc=%%~b
set state=rf
)
set z=%%~a
if NOT "!z:~0,1!"==":" (
if "!state!"=="p1excl" set exclude=!exclude! "%%~a"
if "!state!"=="rf" set RelocPaths=!RelocPaths! "%%~a\"
if "!state!"=="lp" (
set LangCode%%a=!LangNr!
if /I "%%b"=="keep" (
set LangKeep!LangNr!=1
) ELSE set LangKeep!LangNr!=
set /A LangNr-=1
) ) )
:SettingsDone
if %version:.=% LSS 180 (
echo The config file is likely outdated.
echo Delete it, and restart WinsxsLite to generate a new default config.
echo.
)
set version=
set state=
set settings=
set LangNr=

for %%a IN ("%root%\") DO set root=%%~dpa
set root=%root:~0,-1%
set rootd=%root:~0,2%
if NOT EXIST %rootd% (
echo No drive %rootd%
echo.
pause
goto :EOF
)
if NOT EXIST %root% (
echo No folder "%root%".
echo.
pause
goto :EOF
)
set z=0
for /F %%a IN ('fsutil FSINFO NTFSINFO %rootd%') DO set /A z+=1
if %z% LSS 5 (
echo The filesystem on drive %rootd% isn't NTFS.
echo.
pause
goto :EOF
)
set offline=
if /I NOT %root%==%SYSTEMDRIVE% set offline=true

for %%a IN ("%root%\%win%\") DO set win=%%~dpa
set win=!win:%root%=!
set win=%win:~1,-1%
set ProgFiles86=
if DEFINED ProgFiles (
for %%a IN ("%root%\%ProgFiles%\") DO set ProgFiles=%%~fa
for %%a IN ("!ProgFiles:~0,-1! (x86)\") DO set ProgFiles86=%%~fa
set ProgFiles="!ProgFiles:~0,-1!"
set ProgFiles86="!ProgFiles86:~0,-1!"
if NOT EXIST !ProgFiles86! set ProgFiles86=
if NOT EXIST !ProgFiles! (
echo No folder "!ProgFiles!".
set ProgFiles=
) )
for %%a IN ("%root%\%win%\winsxs\") DO set winsxs=%%~fa
if NOT EXIST "%winsxs%" (
echo No folder "%winsxs:~0,-1%".
pause
goto :EOF
)
if NOT DEFINED reloc set reloc=%home:~0,3%
if %reloc::=%==%reloc% set reloc=%home:~0,3%%reloc%
for %%a IN ("%reloc%\") DO set z=%%~dpa
set reloc=%z:~0,-1%
set LinksDir=%rootd%\$\
set exclude=!exclude:$root$=%root%!
set exclude=!exclude:$win$=%root%\%win%!
set exclude=!exclude:$winsxs$=%winsxs:~0,-1%!
set exclude=!exclude:$system32$=%root%\%win%\System32!
set z=!RelocPaths:$root$=%root%!
set z=!z:$win$=%root%\%win%!
set z=!z:$winsxs$=%winsxs:~0,-1%!
set z=!z:$system32$=%root%\%win%\System32!
set RelocPaths=
for %%a IN (%z%) DO (
set z=%%~dpa
set RelocPaths=!RelocPaths! "!z:~0,-1!"
)

set ln=fail
if NOT DEFINED NoVista (
set hlink=mklink /H
ln.exe >NUL 2>&1
if !ERRORLEVEL!==-8 set ln=
) ELSE set hlink=fsutil HARDLINK CREATE
set ReParse=
for /F "tokens=4*" %%a IN ('"dir /ADL "%root%\%win%" 2>NUL"') DO if /I "%%a"=="winsxs" set ReParse=%%b

set subinacl=fail
subinacl.exe >NUL 2>&1
if %ERRORLEVEL%==1 set subinacl=
set movefile=fail
movefile.exe >NUL 2>&1
if %ERRORLEVEL%==67 set movefile=
set pendmoves=fail
pendmoves.exe >NUL 2>&1
if %ERRORLEVEL%==0 set pendmoves=
set fcmp=fail
fcmp.exe >NUL 2>&1
if %ERRORLEVEL%==-1 set fcmp=
set md5file=fail
md5file.exe 2>NUL
if %ERRORLEVEL%==0 set md5file=
set stringconverter=fail
stringconverter.exe >NUL 2>&1
if %ERRORLEVEL%==0 set stringconverter=

if /I "%SearchSampleMedia%"=="yes" (
echo Searching for sample media in winsxs...
echo @echo OFF>%DelMedia%
echo OFF >%buf%
dir /B /AD-L "%winsxs%" >%ABuf%
set size=
set count=
for /F "usebackq delims=" %%a IN (%ABuf%) DO (
set z=%%a
if NOT "!zConfusedamples_=!"=="!z!" (
for %%b IN (photo video music movie) DO set z=!z:_microsoft-windows-%%bsamples_=!
if NOT "!z!"=="%%a" (
cd /D %winsxs%%%a
for %%b IN (*.ini *.jpg *.wmv *.wma *.dvr-ms) DO (
set /A count+=1
set /A "size+=(%%~zb+4095)/4096"
echo del /F "%%~fb">>%DelMedia%
echo +fil %%~fb>>%buf%
echo /perm>>%buf%
echo /pace=s-1-1-0 Type=0x0 Flags=0x0 AccessMask=0x1f01ff>>%buf%
) ) ) )
if DEFINED count (
echo pause>>%DelMedia%
if NOT DEFINED subinacl subinacl.exe /nov /nos /pla %buf%
set /A "z=(size*25+32)/64"
set z= !z!
set z=!z:~0,-2!.!z:~-2!
set z=!z:. =.0!
set z=!z: .=0.!
echo !z: =! MB in !count! files found. Created %DelMedia%.
) ELSE (
echo No media files found.
del /F %DelMedia%
)
set size=
echo.
cd /D %home%
)
set SearchSampleMedia=
set DelMedia=

echo WinsxsLite v1.86 by Christian Bering Boegh.
if DEFINED offline goto Menu
set z=
for %%a IN (%RelocPaths%) DO (
if EXIST "%%~a.$RenameMe" set z=1
if EXIST %%a if EXIST "%%~a.$DeleteMe" set z=1
)
if NOT DEFINED z goto Menu
echo.
if DEFINED movefile (
echo Missing movefile.exe command.
pause
goto :EOF
)
if DEFINED pendmoves (
echo Missing pendmoves.exe command.
pause
goto :EOF
)
setlocal
echo.>>%log%
echo ## %DATE% %TIME%: Finalizing relocation of folders.>>%log%
call :ClearReg
set valid=1
for %%a IN (%RelocPaths%) DO (
set z=
if EXIST "%%~a.$RenameMe" set z=1
if EXIST %%a if EXIST "%%~a.$DeleteMe" set z=1
if DEFINED z (
echo.
echo Processing %%a.
echo Processing %%a.>>%log%
call :ActivateJunction %%a
) )
attrib +r +s %important% >NUL
echo ## %DATE% %TIME%: Done.>>%log%
if NOT DEFINED valid (
endlocal
echo.
echo Reboot to complete the folder relocation.
echo Run WinsxsLite again afterwards.
echo.
pause
goto :EOF
)
endlocal

:Menu
set choice=
if EXIST %important% (
for /F "delims=" %%a IN ('attrib %important%') DO set z=%%a
if NOT "!z:~3,1!!z:~5,1!"==" " (
echo.
if DEFINED offline (
echo Security needs to be restored in online mode.
echo.
pause
goto :EOF
)
attrib -r -s %important% >NUL
call :RestoreSDs Restoring security...
) )
echo.
if EXIST %important% if NOT EXIST "%LinksDir%" (
echo The program appears to have malfunctioned or been interrupted.
echo If this is the case, it's important that the security
echo descriptors are restored before continueing.
set /P choice=Restore security - [Y]es/[L]ater ?
if /I "!choice!"=="Y" (
if DEFINED subinacl (
echo Missing subinacl.exe command.
goto Menu
)
call :RestoreSDs Restoring security...
)
echo.
)
if EXIST %ToSchedule% (
set count=
for /F "usebackq delims=/" %%a IN (%ToSchedule%) DO (
if EXIST "%LinksDir%%%a" set /A count+=1
)
if DEFINED count (
echo !count! pending hardlinks in "%LinksDir:~0,-1%" - waiting for reboot.
echo.
if NOT DEFINED offline (
set /P choice=Re[S]chedule activation,[C]ancel ^& delete,[A]uto start,[W]insxs size, [H]elp or [Q]uit ?
for %%a IN (A W H Q) DO if /I "!choice!"=="%%a" goto Item%%a
set error=
if DEFINED movefile set error=movefile
if DEFINED pendmoves set error=pendmoves
if DEFINED error (
echo Missing !error!.exe command.
goto Menu
)
if /I "!choice!"=="C" (
call :ClearLinksDir
goto Menu
)
if /I "!choice!"=="S" (
if DEFINED ln set error=ln
if DEFINED fcmp set error=fcmp
if DEFINED subinacl set error=subinacl
if DEFINED stringconverter set error=stringconverter
if DEFINED error (
echo Missing !error!.exe command.
goto Menu
)
setlocal
echo Rethinking hardlink group creation from %ToSchedule%...
set z=0
for /F "usebackq delims=/" %%a IN (%ToSchedule%) DO if EXIST "%LinksDir%%%a" if %%a GTR !z! set z=%%a
set /A z+=1000000
cd /D %rootd%\
echo 0/:/::>>%ToSchedule%
echo OFF >%Redo%
set count=!z:~0,-6!000000
set sibling1=
set siblings=1
set z=0
for /F "usebackq delims=/ tokens=2,3" %%a IN (%ToSchedule%) DO (
if /I NOT "%%b"=="!sibling1!" (
set target=!sibling1!
for /L %%c IN (!z!,-1,!siblings!) DO if NOT "!sibling%%c:~-1!"=="/" set target=!sibling%%c!
for /L %%c IN (!z!,-1,!siblings!) DO if "!sibling%%c:\%win%\winsxs\=!"=="!sibling%%c:/=!" set target=!sibling%%c!
ln.exe -l "%rootd%!target!">%buf%
for /F "usebackq delims=\: tokens=1*" %%d IN (%buf%) DO for /L %%c IN (1,1,!z!) DO if /I "!sibling%%c!"=="\%%e" set sibling%%c=
for /L %%c IN (1,1,!z!) DO if DEFINED sibling%%c (
set /A count+=1
echo !count!/!sibling%%c!/!target!>>%Redo%
)
set z=0
if EXIST "%rootd%%%b" (
set sibling1=%%b
set z=1
ln.exe -l "%rootd%%%b">%buf%
for /F "usebackq delims=\: tokens=1*" %%d IN (%buf%) DO if NOT "%%d"=="ERROR" (
set source=%%d:\%%e
if /I NOT "\%%e"=="%%b" if "!source:%LinksDir%=!"=="!source!" (
set /A z+=1
set sibling!z!=\%%e
) ) )
set /A siblings=z+1
)
set /A z+=1
set sibling!z!=%%a/
if "%%~za"=="%%~zb" if EXIST "%rootd%%%a" (
fcmp.exe /S "%rootd%%%a" "%rootd%%%b"
if !ERRORLEVEL!==0 set sibling!z!=%%a
) )
cd /D %home%
echo OFF >%ABuf%
for /F "usebackq delims=/ tokens=2,3" %%a IN (%Redo%) DO (
echo %%~pa>>%ABuf%
echo %%~pb>>%ABuf%
)
echo.>%BBuf%
set z=
for /F "delims=" %%a IN ('sort /L ""C"" %ABuf%') DO if /I NOT "%%a"=="!z!" if NOT "%%a"=="\" (
echo +fil %rootd%%%a>>%BBuf%
echo /dis=dacl>>%BBuf%
set z=%%a
)
echo __cachefileonly__>%buf%
subinacl.exe /nov /nos /offl=%buf% /pla %BBuf% >%ABuf%
stringconverter.exe %ABuf% %ABuf% /ANSI /FORCEUNICODE
echo +File>>%ABuf%
echo.>%BBuf%
set valid=1
for /F "usebackq tokens=1*" %%a IN (%ABuf%) DO (
if "%%a"=="/pace" for /F "tokens=1,7 delims== " %%c IN ("%%b") DO if /I "%%c%%d"=="s-1-1-00x1f01ff" set valid=1
if "%%a"=="+File" (
if NOT DEFINED valid (
echo +fil !z!>>%BBuf%
echo /dis=sddl>>%BBuf%
echo /perm>>%BBuf%
echo /pace=s-1-1-0 Type=0x0 Flags=0x0 AccessMask=0x1f01ff>>%BBuf%
)
set valid=
set z=%%b
) )
subinacl.exe /nov /nos /pla %BBuf% >%ABuf%
stringconverter.exe %ABuf% %ABuf% /ANSI /FORCEUNICODE
type %ABuf% >>%important%
set /A count-=!count:~0,-6!000000
echo !count! lines written to %Redo%.
endlocal
call :ClearLinksDir
if DEFINED error goto Menu
call :CreateHardlinks %Redo% SkipSD
if DEFINED error goto Menu
call :ActivateHardlinks %ToSchedule%
)
) ELSE (
set /P choice=[W]insxs size,[H]elp or [Q]uit ?
for %%a IN (W H Q) DO if /I "!choice!"=="%%a" goto Item%%a
)
goto Menu
) )
if EXIST "%LinksDir%" (
set count=
for /R "%LinksDir%" %%a IN (*) DO (
del /F "%%a" >NUL 2>&1
if EXIST "%%a" (
set /A count+=1
for /F "delims=" %%b IN ('attrib "%%a" /L') DO set z=%%b
if "!z:~5,1!"=="R" (
set z= +!z:~3,1! +!z:~4,1!
set z=!z: + =!
attrib -r!z! "%%a" /L >NUL
)
if NOT DEFINED movefile movefile.exe "%%a" "" >NUL
) )
if DEFINED movefile if DEFINED count echo Missing movefile.exe command.
if NOT DEFINED count (
rd /S /Q "%LinksDir%" >NUL 2>&1
if EXIST %important% (
if DEFINED subinacl (
echo Missing subinacl.exe command.
pause
goto :EOF
)
if DEFINED offline (
echo Security needs to be restored in online mode.
echo.
pause
goto :EOF
)
call :RestoreSDs Restoring security using merged security descriptors...
)
goto Menu
)
echo A reboot is necessary to complete the cleanup.
echo Run WinsxsLite again afterwards.
set /P choice=[A]uto start,[W]insxs size,[H]elp or [Q]uit ?
for %%a IN (A W H Q) DO if /I "!choice!"=="%%a" goto Item%%a
goto Menu
)
set /P choice=Phase[1]/[2],[R]elocate folders,[A]uto start,[W]insxs size,[H]elp or [Q]uit ?
for %%a IN (1 2 R A W H Q) DO if /I "!choice!"=="%%a" goto Item%%a
goto Menu
:ItemQ
goto :EOF
:ItemH
echo.
call :Help
goto Menu
:ItemW
echo.
call :WinsxsSize
goto Menu
:Item2
:Item1
echo.
if DEFINED ReParse (
echo "%winsxs:~0,-1%" is a reparse point to !ReParse!
) ELSE call Tonguehase%choice% !ToDo:/=%choice%!
goto Menu
:ItemR
echo.
call :RelocFolders
goto Menu
:ItemA
if DEFINED NoVista (
echo This function needs Vista to run.
) ELSE call :SetStartup
goto Menu

:EchoWindow
if NOT DEFINED OutFile if "%2"=="FORCE" (
call :OpenWindow %3
) ELSE goto :EOF
set /A OutFile=3-OutFile
if NOT EXIST "%home%$Out%OutFile%.txt" (
set /A OutFile=3-OutFile
set BusyWindow="%home%$Out!OutFile!.txt"
)
set /A OutFile=3-OutFile
echo%~1>>"%home%$Out%OutFile%.txt"
if "%2"=="" attrib -a "%home%$Out%OutFile%.txt" >NUL
goto :EOF

:EchoError
if NOT %2==!ErrStr! (
if NOT !ErrStr!=="" (
if !entry1! LEQ 9999 (
set entrya= !entry1!
set entrya=!entrya:~-4!
) ELSE set entrya=!entry1!
if NOT !entry1!==!entry2! (
if !entry2! LEQ 9999 (
set entryb= !entry2!
set entryb= -!entryb:~-4!
) ELSE set entryb=-!entry2!
) ELSE set entryb=
call :EchoWindow " !entrya!!entryb!: !ErrStr:~1,-1!" FORCE ERRORS:
)
set entry1=%1
set ErrStr=%2
)
if NOT %3==!ErrStrLog! (
if NOT !ErrStrLog!=="" (
if !entry1Log! LEQ 9999 (
set entrya= !entry1Log!
set entrya=!entrya:~-4!
) ELSE set entrya=!entry1Log!
if NOT !entry1Log!==!entry2! (
if !entry2! LEQ 9999 (
set entryb= !entry2!
set entryb= -!entryb:~-4!
) ELSE set entryb=-!entry2!
) ELSE set entryb=
echo !entrya!!entryb!: !ErrStrLog:~1,-1!>>%log%
)
set entry1Log=%1
set ErrStrLog=%3
)
set entry2=%1
set Echoed=true
goto :EOF

:OpenWindow
if DEFINED NoVista goto :EOF
if DEFINED OutFile goto :EOF
del /F "%home%$Out1.txt" >NUL 2>&1
echo.>"%home%$Out2.txt"
start "" /HIGH "%COMSPEC%" /C %WinsxsLite% ProgressWindow %1
set OutFile=1
set BusyWindow="%home%$Out2.txt"
goto :EOF

:CloseWindow
if DEFINED NoVista goto :EOF
if NOT DEFINED OutFile goto :EOF
for %%Z IN (1 1 1 1) DO (
if NOT EXIST %BusyWindow% (
echo OFF >%BusyWindow%
set OutFile=
set BusyWindow=
goto :EOF
)
choice /N /T 1 /D Y>NUL
)
if "%1"=="ECHO" (
if EXIST %BusyWindow% type %BusyWindow%
if EXIST "%home%$Out%OutFile%.txt" type "%home%$Out%OutFile%.txt"
)
echo OFF >"%home%$Out1.txt"
echo OFF >"%home%$Out2.txt"
set OutFile=
set BusyWindow=
goto :EOF

:Apply
if EXIST %1 (
attrib -s -h -r %1 >NUL
for /F "delims=" %%a IN ('attrib %1') DO set z=%%a
if "!z:~0,1!"=="A" (
echo %1 is outdated...
) ELSE (
set count=
for /F "usebackq" %%a IN (%1) DO set /A count+=1
if DEFINED count (
echo Previous scan result of !count! lines in %1.
set /P choice=Re[S]can,[A]pply or [E]xit ?
if /I "!choice!"=="A" (
set choice=
if DEFINED subinacl (
echo Missing subinacl.exe command.
goto :EOF
)
if DEFINED stringconverter (
echo Missing stringconverter.exe command.
goto :EOF
)
if NOT DEFINED offline if DEFINED movefile (
echo Missing movefile.exe command.
goto :EOF
)
call :CreateHardlinks %1
if DEFINED error goto :EOF
if NOT DEFINED offline (
echo.
call :ActivateHardlinks %ToSchedule%
) )
goto :EOF
) ) )
set /P choice=[S]can or [E]xit ?
goto :EOF

:CreateHardlinks
set error=true
if NOT EXIST %1 (
echo %1 not found.
goto :EOF
)
if NOT DEFINED offline (
md "%LinksDir%" 2>NUL
echo OFF >%ToSchedule%
)
setlocal
call :OpenWindow Modifying_the_system_-_creating_hardlinks...
if "%2"=="SkipSD" goto CreateHL
echo Calculating new security descriptors...
for /F "delims==" %%a IN ('"set Mask 2>NUL"') DO set %%a=
set hex=
for %%a IN (0 1 2 3 4 5 6 7 8 9 a b c d e f) DO for %%b IN (0 1 2 3 4 5 6 7 8 9 a b c d e f) DO set hex=!hex!%%a%%b
echo //>>%1
attrib -s -h -r -a %1 >NUL
call :EchoWindow " Calculating new security descriptors..."
echo __cachefileonly__>%buf%
echo OFF >%important%
echo.>%BBuf%
set files=-2
set groups=-1
set old=
for /F "usebackq delims=/ tokens=2,3" %%a IN (%1) DO (
set /A files+=1
if /I NOT "%%b"=="!old!" (
set /A files+=1
set /A groups+=1
if NOT EXIST !BusyWindow! call :EchoWindow " Running total: !files! security descriptors merged into !groups!."
subinacl.exe /nov /nos /offl=%buf% /pla %BBuf% >%ABuf%
stringconverter.exe %ABuf% %ABuf% /ANSI /FORCEUNICODE
echo OFF >%BBuf%
set valid=
set own=
set owners=
set SIDs=
set SIDsID=
for /F "usebackq tokens=1*" %%c IN (%ABuf%) DO (
if NOT DEFINED valid (
if "%%c"=="+File" (
echo %%d>>%BBuf%
set valid=1
)
) ELSE if "%%c"=="/pace" (
set z=%%d
for /F "tokens=1,3,5,7 delims== " %%e IN ("!z:-=a!") DO if %%f==0x0 (
if %%g==0x10 (
if NOT DEFINED MaskID%%e set SIDsID=!SIDsID! %%e
set /A "MaskID%%e|=%%h"
) ELSE (
if NOT DEFINED Mask%%e set SIDs=!SIDs! %%e
set /A "Mask%%e|=%%h"
) )
) ELSE if "%%c"=="/owner" (
for /F "delims==" %%e IN ("%%d") DO if "!owners:%%e=!"=="!owners!" set owners=!owners! %%e
set valid=
) )
for %%c IN (s-1-1-0 s-1-5-18 s-1-5-19 s-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464 s-1-5-32-545 s-1-5-21- s-1-5-32-544) DO if NOT DEFINED own if NOT "!owners:%%c=!"=="!owners!" set own=%%c
if /I "!own!"=="s-1-5-21-" for /F %%c IN ("!owners:*s-1-5-21-=s-1-5-21-!") DO set own=%%c
if NOT DEFINED own for /F %%c IN ("!owners!") DO set own=%%c
set own=O:!own!DTongue
for %%c IN (!SIDs!) DO (
set /A "z=(Mask%%c^MaskID%%c)&MaskID%%c"
if !z!==0 set MaskID%%c=
set "own=!own!(A;;0x"
set /A "z=Mask%%c>>23&0x1FE"
if NOT !z!==0 for %%d IN (!z!) DO set own=!own!!hex:~%%d,2!
set /A "z=Mask%%c>>15&0x1FE"
for %%d IN (!z!) DO set own=!own!!hex:~%%d,2!
set /A "z=Mask%%c>>7&0x1FE"
for %%d IN (!z!) DO set own=!own!!hex:~%%d,2!
set /A "z=Mask%%c<<1&0x1FE"
set old=%%c
for %%d IN (!z!) DO set "own=!own!!hex:~%%d,2!;;;!old:a=-!)"
set Mask%%c=
)
for %%c IN (!SIDsID!) DO if DEFINED MaskID%%c (
set "own=!own!(A;ID;0x"
set /A "z=MaskID%%c>>23&0x1FE"
if NOT !z!==0 for %%d IN (!z!) DO set own=!own!!hex:~%%d,2!
set /A "z=MaskID%%c>>15&0x1FE"
for %%d IN (!z!) DO set own=!own!!hex:~%%d,2!
set /A "z=MaskID%%c>>7&0x1FE"
for %%d IN (!z!) DO set own=!own!!hex:~%%d,2!
set /A "z=MaskID%%c<<1&0x1FE"
set old=%%c
for %%d IN (!z!) DO set "own=!own!!hex:~%%d,2!;;;!old:a=-!)"
set MaskID%%c=
)
for /F "usebackq delims=" %%c IN (%BBuf%) DO (
echo +fil %%c>>%important%
echo /sddl=!own!>>%important%
)
echo +fil %rootd%%%b>%BBuf%
echo /dis=dacl>>%BBuf%
echo /dis=owner>>%BBuf%
set old=%%b
)
echo +fil %rootd%%%a>>%BBuf%
echo /dis=dacl>>%BBuf%
echo /dis=owner>>%BBuf%
)
call :EchoWindow " Total: !files! security descriptors merged into !groups!."
call :EchoWindow "."
call :EchoWindow " Removing filesystem security on !files! files in !groups! groups..."
call :EchoWindow "."
echo OFF >%BBuf%
for /F "usebackq delims=/ tokens=2,3" %%a IN (%1) DO (
echo %%~pa>>%BBuf%
echo %%~pb>>%BBuf%
)
echo OFF >%ABuf%
set z=
for /F "delims=" %%a IN ('sort /L ""C"" %BBuf%') DO if /I NOT "%%a"=="!z!" if NOT "%%a"=="\" (
echo +fil %rootd%%%a>>%ABuf%
echo /dis=sddl>>%ABuf%
echo /perm>>%ABuf%
echo /pace=s-1-1-0 Type=0x0 Flags=0x0 AccessMask=0x1f01ff>>%ABuf%
set z=%%a
)
set z=
for /F "usebackq delims=/ tokens=2,3" %%a IN (%1) DO (
echo +fil %rootd%%%a>>%ABuf%
echo /perm>>%ABuf%
echo /pace=s-1-1-0 Type=0x0 Flags=0x0 AccessMask=0x1f01ff>>%ABuf%
if /I NOT "%%b"=="!z!" (
echo +fil %rootd%%%b>>%ABuf%
echo /perm>>%ABuf%
echo /pace=s-1-1-0 Type=0x0 Flags=0x0 AccessMask=0x1f01ff>>%ABuf%
set z=%%b
) )
subinacl.exe /nov /nos /pla %ABuf% >%BBuf%
stringconverter.exe %BBuf% %BBuf% /ANSI /FORCEUNICODE
type %BBuf% >>%important%
echo Done.
:CreateHL
echo Generating replacement hardlinks...
call :EchoWindow " Generating replacement hardlinks..."
call :EchoWindow "."
echo.>>%log%
echo ## %DATE% %TIME%: Generating replacement hardlinks using %1.>>%log%
attrib -s -h -r +a %ToDo:/=1% >NUL
attrib -s -h -r +a %ToDo:/=2% >NUL
attrib -s -h -r -a %1 >NUL
set ErrStr=""
set ErrStrLog=""
set count=0
set scheduled=
set MissingTarget=
set FailedCreate=
set FailedCreateCritical=
set FailedDelete=
for /F "usebackq delims=/ tokens=1-3" %%a IN (%1) DO (
set Echoed=
set /A count+=1
if NOT EXIST !BusyWindow! (
set /A z=MissingTarget+FailedCreate+FailedCreateCritical+FailedDelete
set z=!z! failures.
if DEFINED scheduled set z=!scheduled! needs a reboot. !z!
call :EchoWindow " !count! hardlinks created. !z!"
)
if NOT EXIST "%rootd%%%c" (
set /A MissingTarget+=1
call :EchoError %%a "Couldn't find link target." "Couldn't find link target '%rootd%%%c'."
) ELSE (
del /F "%rootd%%%b" >NUL 2>&1
if NOT DEFINED offline (
if EXIST "%rootd%%%b" (
%hlink% "%LinksDir%%%a" "%rootd%%%c" >NUL 2>&1
if NOT EXIST "%LinksDir%%%a" (
set /A FailedCreate+=1
call :EchoError %%a "Failed to create to-be scheduled replacement hardlink." "Failed to create to-be scheduled replacement for '%rootd%%%b' - link to '%rootd%%%c'."
) ELSE (
echo %%a/%%b/%%c>>%ToSchedule%
set /A scheduled+=1
)
) ELSE (
%hlink% "%rootd%%%b" "%rootd%%%c" >NUL 2>&1
if NOT EXIST "%rootd%%%b" (
%hlink% "%LinksDir%%%a" "%rootd%%%c" >NUL 2>&1
if NOT EXIST "%LinksDir%%%a" (
set /A FailedCreateCritical+=1
call :EchoError %%a "Failed to create immediate replacement hardlink." "Failed to create immediate replacement for '%rootd%%%b' - link to '%rootd%%%c'."
) ELSE (
echo %%a/%%b/%%c>>%ToSchedule%
set /A scheduled+=1
) ) )
) ELSE (
if EXIST "%rootd%%%b" (
attrib -s -h "%rootd%%%b" >NUL
del /F "%rootd%%%b" >NUL 2>&1
if EXIST "%rootd%%%b" (
set /A FailedDelete+=1
call :EchoError %%a "Failed to delete file for immediate replacement." "Failed to delete '%rootd%%%b'."
) )
if NOT EXIST "%rootd%%%b" (
%hlink% "%rootd%%%b" "%rootd%%%c" >NUL 2>&1
if NOT EXIST "%rootd%%%b" (
set /A FailedCreateCritical+=1
call :EchoError %%a "Failed to create immediate replacement hardlink." "Failed to create immediate replacement for '%rootd%%%b' - link to '%rootd%%%c'."
) ) ) )
if NOT DEFINED Echoed call :EchoError 0 "" ""
)
call :EchoError 0 "" ""
attrib -s -h -r +a %1 >NUL
set /A error=MissingTarget+FailedCreate+FailedCreateCritical+FailedDelete
set z=%error% failures.
if DEFINED scheduled set z=%scheduled% needs a reboot. %z%
call :EchoWindow " %count% hardlinks created. %z%"
if %error% GTR 0 call :CloseWindow ECHO
echo Completed processing %count% lines in %1.>%ABuf%
set /A count-=MissingTarget+FailedCreate+FailedCreateCritical+FailedDelete
echo %count% hardlinks were successfully created.>>%ABuf%
if DEFINED scheduled echo %scheduled% of them needs to be scheduled for activation on reboot.>>%ABuf%
if DEFINED MissingTarget echo %MissingTarget% link targets not found.>>%ABuf%
if DEFINED FailedCreate echo %FailedCreate% to-be scheduled hardlinks couldn't be created.>>%ABuf%
if DEFINED FailedDelete echo %FailedDelete% files couldn't be deleted for immediate hardlink replacement.>>%ABuf%
if DEFINED FailedCreateCritical (
echo %FailedCreateCritical% immediate replacement hardlinks couldn't be created.>>%ABuf%
echo These files are now missing from the system, and has to be linked manually.>>%ABuf%
)
set /A count=MissingTarget+FailedCreate+FailedCreateCritical+FailedDelete
if NOT %count%==0 echo %count% hardlink generation failures in total.>>%ABuf%
type %ABuf%
type %ABuf% >>%log%
echo ## %DATE% %TIME%: Done.>>%log%
call :CloseWindow
endlocal
set error=
if DEFINED offline call :RestoreSDs Applying merged security descriptors...
goto :EOF

:ActivateHardlinks
if NOT EXIST %1 (
echo %1 not found.
goto :EOF
)
if %~z1==0 goto :EOF
setlocal
echo Scheduling activation of replacement hardlinks...
echo.>>%log%
echo ## %DATE% %TIME%: Scheduling activation of replacement hardlinks using %1.>>%log%
set ErrStr=""
set ErrStrLog=""
set count=0
set MissingFile=
set FailedDelete=
set FailedRename=
set FailedCreateCritical=
movefile.exe "%LinksDir%$Mark" "%LinksDir%$Mark" >NUL
for /F "usebackq delims=/ tokens=1,2" %%a IN (%1) DO (
set Echoed=
set /A count+=1
if NOT EXIST "%LinksDir%%%a" (
set /A MissingFile+=1
call :EchoError %%a "" "Replacement hardlink not found in '!LinksDir:~0,-1!'."
) ELSE (
set error=
if EXIST "%rootd%%%b" (
for /F "delims=" %%d IN ('attrib "%rootd%%%b"') DO set z=%%d
if "!z:~5,1!"=="R" attrib -r -s -h "%rootd%%%b" >NUL
movefile.exe "%rootd%%%b" "" >NUL
if NOT !ERRORLEVEL!==30 (
set error=true
set /A FailedDelete+=1
call :EchoError %%a "Failed to schedule deletion." "Failed to schedule deletion of '%rootd%%%b'."
) )
if NOT DEFINED error (
for /F "delims=" %%d IN ('attrib "%LinksDir%%%a"') DO set z=%%d
if "!z:~5,1!"=="R" attrib -r -s -h "%LinksDir%%%a" >NUL
movefile.exe "%LinksDir%%%a" "%rootd%%%b" >NUL
if NOT !ERRORLEVEL!==30 (
set /A FailedRename+=1
call :EchoError %%a "Failed to schedule rename." "Failed to schedule rename of '%LinksDir%%%a' to '%rootd%%%b'."
) ) )
if NOT DEFINED Echoed call :EchoError 0 "" ""
)
call :EchoError 0 "" ""
movefile.exe "%LinksDir%$Mark" "%LinksDir%$Mark" >NUL
echo Completed processing %count% lines in %1.>%ABuf%
set /A count-=MissingFile+FailedDelete+FailedRename
echo %count% files were successfully scheduled for replacement.>>%ABuf%
if DEFINED MissingFile echo %MissingFile% replacement hardlinks not found.>>%ABuf%
if DEFINED FailedDelete echo %FailedDelete% files couldn't be scheduled for deletion.>>%ABuf%
if DEFINED FailedRename (
echo %FailedRename% replacement hardlinks couldn't be scheduled for activation.>>%ABuf%
echo Either they have to be moved and renamed manually after reboot,>>%ABuf%
echo or all scheduled operations has to be cancelled before reboot.>>%ABuf%
)
set /A count=MissingFile+FailedDelete+FailedRename
if NOT %count%==0 echo %count% scheduling failures in total.>>%ABuf%
type %ABuf%
type %ABuf% >>%log%
echo ## %DATE% %TIME%: Done.>>%log%
echo.
echo IMPORTANT - After reboot, run WinsxsLite
echo to restore security descriptors.
call :CloseWindow ECHO
endlocal
goto :EOF

Tonguehase1
call :Apply %1
if /I NOT "%choice%"=="S" goto :EOF
set choice=
if DEFINED NoVista (
echo This function needs Vista to run.
goto :EOF
)
if DEFINED ln (
echo Missing ln.exe command.
goto :EOF
)
if DEFINED fcmp (
echo Missing fcmp.exe command.
goto :EOF
)
if DEFINED md5file (
echo Missing md5file.exe command.
goto :EOF
)
setlocal
echo Phase 1: Scanning...
echo.>>%log%
echo ## %DATE% %TIME%: Started phase 1 scan.>>%log%
call :OpenWindow Phase_1:_Scanning...
set excludes=
for %%a IN (%exclude%) DO (
set z=%%~a
if "!z:~-1!"=="\" set excludes=!excludes! %%a
)
echo OFF >%ABuf%
set count=0
for %%a IN ("%root%\%win%" %ProgFiles86% %ProgFiles%) DO (
set z=%%~a
echo !z:\=!>>%ABuf%
dir /AD-L /B /S %%a >%buf%
find /V "=" %buf% >%BBuf%
if %%a=="%root%\%win%" call :EchoWindow "."
for /F "usebackq skip=2 delims=" %%b IN (%BBuf%) DO (
set z=%%b\
set valid=1
for %%c IN (%excludes%) DO if NOT "!z:%%~c=!"=="!z!" set valid=
if DEFINED valid (
set /A count+=1
if NOT EXIST !BusyWindow! call :EchoWindow " !count! folders enumerated [%%~a]."
set z=%%b
echo !z:\=!>>%ABuf%
) )
call :EchoWindow " !count! folders enumerated [%%~a]."
)
call :EchoWindow "."
call :EchoWindow " Filtering..."
set excludes=
echo OFF >%BBuf%
set old=%root%\
for /F "delims=" %%a IN ('sort /L ""C"" %ABuf%') DO (
set z=%%a
for %%b IN ("!z:=\!") DO if NOT "!old:%%~dpb=!"=="!old!" (
set old=%%~b\
echo -/%%~b>>%BBuf%
dir /A-D-L /B %%b 2>NUL >>%BBuf%
) )
set old=
for %%a IN (%exclude%) DO (
set z=%%~a
if NOT "!z:~-1!"=="\" set excludes=!excludes! %%a
)
find /V "=" %BBuf% >%ABuf%
call :EchoWindow "."
echo OFF >%BBuf%
set count=0
for /F "usebackq skip=2 delims=/ tokens=1*" %%a IN (%ABuf%) DO if "%%b"=="" (
for %%c IN ("!dir!\%%a") DO if %%~zc GTR 0 (
set z=%%~c/
set valid=1
for %%d IN (%excludes%) DO if NOT "!z:%%~d=!"=="!z!" set valid=
if DEFINED valid (
set /A count+=1
if NOT EXIST !BusyWindow! call :EchoWindow " !count! files enumerated."
echo %%~zc/%%~pnxc>>%BBuf%
) )
) ELSE set dir=%%b
call :EchoWindow " %count% files enumerated."
call :EchoWindow "."
call :EchoWindow " Filtering..."
set excludes=
set dir=
find "/%root:~2%\%win%\winsxs\" %BBuf% >%ABuf%
for /F "usebackq skip=2 delims=/" %%a IN (%ABuf%) DO echo %%a/>>%BBuf%
sort /L ""C"" %BBuf% /O %BBuf%
echo OFF >%ABuf%
set score=0
set z=/
for /F "usebackq delims=/ tokens=1,2" %%a IN (%BBuf%) DO if NOT "%%b"=="" (
if %%a==!z! (
set /A score+=1
echo %%a/%%b>>%ABuf%
)
) ELSE set z=%%a
call :EchoWindow "."
call :EchoWindow " A total of %score% files left for main processing."
sort /L ""C"" /R %ABuf% /O %ABuf%
echo 0/>>%ABuf%
set done 2>NUL >%buf%
set hash 2>NUL >>%buf%
set \ 2>NUL >>%buf%
for /F "usebackq delims==" %%a IN (%buf%) DO set %%a=
call :EchoWindow "."
echo OFF >%1
set freed=0
set count=No
set files=0
set groups=0
set size=/
for /F "usebackq delims=/ tokens=1,2" %%a IN (%ABuf%) DO (
set /A files+=1
if NOT EXIST !BusyWindow! (
set /A z=files*1000/%score%
if !z! GEQ 30 (
for /F "delims=:., tokens=1-3,5-7" %%c IN ("!TIME::0=:!:%TIME::0=:%") DO set /A valid=%%c*3600+%%d*60+%%e-%%f*3600-%%g*60-%%h
if !valid! LSS 0 set /A valid+=86400
set /A valid=%score%*1000/files*valid/1000-valid
set /A target=valid/3600
set /A valid-=target*3600
set /A score=valid/60
set /A valid-=score*60
set target= !target!
set score=0!score!
set valid=0!valid!
set valid= Est. time remaining: !target:~-2!:!score:~-2!:!valid:~-2!
) ELSE set valid=
set z= !z:~0,-1!.!z:~-1!
set z=!z: .=0.!
set files= !files!
call :EchoWindow " !z:~-5!%%%%, !files:~-7! files processed.!valid!"
set /A "z=(freed*25+32)/64"
set z= !z!
set z=!z:~0,-2!.!z:~-2!
set z=!z:. 0=0 !
set z=!z:. =.0!
set z=!z: .=0.!
set z= !z!
set count= !count!
call :EchoWindow " !count:~-7! hardlinks to create. Will free!z:~-8! MB."
)
if NOT %%a==!size! (
if NOT !groups!==0 (
for %%f IN ("!file!") DO if "!%%~f!"=="" (
set /A groups+=1
ln.exe -l "%rootd%!file!">%buf%
for %%c IN (!groups!) DO (
set group%%c=
for /F "usebackq delims=\: tokens=1*" %%d IN (%buf%) DO if NOT "%%d"=="ERROR" (
set /A group%%c+=1
set group%%cf!group%%c!=\%%e
set \%%e=%%c
)
if NOT DEFINED group%%c set /A groups-=1
) )
if !groups! GEQ 2 (
verify >NUL
set %winsxs:~2% 2>NUL >%buf%
if NOT ERRORLEVEL 1 (
set valid=1
set ListWinsxs=
for /F "usebackq delims== tokens=2" %%c IN (%buf%) DO set ListWinsxs=!ListWinsxs!%%c
set %root:~2%\%win%\System32\ 2>NUL >%buf%
set ListSystem32=
for /F "usebackq delims== tokens=2" %%c IN (%buf%) DO set ListSystem32=!ListSystem32!%%c
) ELSE set valid=
)
for /L %%c IN (1,1,!groups!) DO for /L %%d IN (1,1,!group%%c!) DO set !group%%cf%%d!=
if !groups! GEQ 2 if DEFINED valid (
set hashes=
set HashGroups=
for /L %%c IN (!groups!,-1,1) DO (
md5file.exe "%rootd%!group%%cf1!">%buf%
for /F "usebackq delims=" %%d IN (%buf%) DO (
set z=%%d
for %%e IN (!z:~-8!) DO if DEFINED hash%%e (
if "!hash%%e:~-1!"==" " set HashGroups=!HashGroups! %%e
set hash%%e=!hash%%e! %%c
) ELSE (
set hashes=!hashes! %%e
set hash%%e=%%c
) ) )
for %%c IN (!HashGroups!) DO for %%d IN (!hash%%c!) DO (
if NOT DEFINED done%%d (
set valid=
for %%e IN (!hash%%c!) DO if %%e LSS %%d if NOT DEFINED done%%e (
fcmp.exe /S "%rootd%!group%%df1!" "%rootd%!group%%ef1!"
if !ERRORLEVEL!==0 (
set valid=!valid!%%e
set done%%e=1
) )
if DEFINED valid (
set valid= !valid!%%d
set z=
for %%e IN (!valid!) DO if NOT "!ListWinsxs!"=="!ListWinsxs: %%e =!" set z=1
if DEFINED z (
set score=0
for %%e IN (!valid!) DO (
set z=
if NOT "!ListSystem32!"=="!ListSystem32: %%e =!" set z=10000
set /A z+=group%%e
if !z! GTR !score! (
set score=!z!
set target=%%e
) )
for %%e IN (!target!) DO (
set valid=!valid: %%e = !
set target=!group%%ef1!
)
for %%e IN (!valid!) DO (
set /A "freed+=(size+4095)/4096"
for /L %%f IN (1,1,!group%%e!) DO (
set /A count+=1
echo !count!/!group%%ef%%f!/!target!>>%1
) ) ) ) )
set done%%d=
)
for %%c IN (!hashes!) DO set hash%%c=
)
for /L %%c IN (1,1,!groups!) DO (
for /L %%d IN (1,1,!group%%c!) DO set group%%cf%%d=
set group%%c=
)
set groups=0
)
set size=%%a
) ELSE for %%f IN ("!file!") DO if "!%%~f!"=="" (
set /A groups+=1
ln.exe -l "%rootd%!file!">%buf%
for %%c IN (!groups!) DO (
set group%%c=
for /F "usebackq delims=\: tokens=1*" %%d IN (%buf%) DO if NOT "%%d"=="ERROR" (
set /A group%%c+=1
set group%%cf!group%%c!=\%%e
set \%%e=%%c
)
if NOT DEFINED group%%c set /A groups-=1
) )
set file=%%b
)
attrib -a %1
set files= %files%
call :EchoWindow " 100.0%%%%, %files:~-7% files processed."
set /A "z=(freed*25+32)/64"
set z= %z%
set z=%z:~0,-2%.%z:~-2%
set z=%z:. 0=0 %
set z=%z:. =.0%
set z=%z: .=0.%
set z= %z%
set count= %count%
call :EchoWindow " %count:~-7% hardlinks to create. Will free%z:~-8% MB."
call :CloseWindow
echo OFF >%ABuf%
for /F "usebackq delims=/ tokens=2,3" %%a IN (%1) DO echo %%~xa # %%a # %%b>>%ABuf%
sort /L ""C"" %ABuf% /O %P1Ext%
echo %count% lines written to %1.
echo %count% lines written to %1.>>%log%
if NOT %freed%==0 (
set z=Applying this scan will free %z: =% MB.
echo !z!
echo !z!>>%log%
)
echo ## %DATE% %TIME%: Done.>>%log%
endlocal
goto :EOF

Tonguehase2
call :Apply %1
if /I NOT "%choice%"=="S" goto :EOF
set choice=
if DEFINED NoVista (
echo This function needs Vista to run.
goto :EOF
)
if DEFINED ln (
echo Missing ln.exe command.
goto :EOF
)
setlocal
echo Phase 2: Scanning...
echo.>>%log%
echo ## %DATE% %TIME%: Started phase 2 scan.>>%log%
call :OpenWindow Phase_2:_Scanning...
cd /D %winsxs%
dir /B /AD-L >%buf%
call :EchoWindow "."
echo OFF >%ABuf%
set LangNr=499
set score=0
for /F "usebackq delims=" %%a IN (%buf%) DO (
set name=
set z=%%a
for /L %%b IN (1,1,10) DO if DEFINED z for /F "delims=_ tokens=1-5*" %%c IN ("!z!") DO (
if "%%h"=="" (
if NOT "%%g"=="" (
for /F "delims=. tokens=1-3*" %%i IN ("%%e") DO (
set sibling1=00%%i
set sibling2=000000%%j
set sibling3=000000%%k
set sibling4=000000%%l
)
if NOT DEFINED LangCode%%f (
set LangCode%%f=!LangNr!
set /A LangNr-=1
)
set /A score+=1
if NOT EXIST !BusyWindow! call :EchoWindow " !score! winsxs folders parsed."
echo !name!%%c/!LangCode%%f!/!sibling1:~-2!!sibling2:~-6!!sibling3:~-6!!sibling4:~-6!/%%a>>%ABuf%
)
set z=
) ELSE (
set name=!name!%%c_
set z=%%d_%%e_%%f_%%g_%%h
) ) )
call :EchoWindow " !score! winsxs folders parsed."
call :EchoWindow "."
echo OFF >%buf%
for /F "delims== tokens=1,2" %%a IN ('"set LangCode 2>NUL"') DO echo %%b/%%a>>%buf%
call :EchoWindow " Language codes found:"
echo OFF >"%home%$LanguageStrings.txt"
set language=
for /F "delims=/ tokens=1,2" %%a IN ('sort /L ""C"" /R %buf%') DO (
set z= %%a
set z= !z: 0=!
set /A z=!z: 0=!
if !z! LEQ 499 (
set z=%%b
) ELSE set z=%%b=BASE
set z=!z:LangCode=!
if DEFINED LangKeep%%a set z=!z!=KEEP
echo !z!>>"%home%$LanguageStrings.txt"
set z=!z!
set language=!language!!z:~0,19!
if NOT "!language:~57,1!"=="" (
call :EchoWindow " !language!"
set language=
) )
if DEFINED language call :EchoWindow " %language%"
sort /L ""C"" /R %ABuf% /O %ABuf%
call :EchoWindow "."
echo OFF >%BBuf%
set freed=0
set files=0
set count=0
set HighID=
for /F "usebackq delims=/ tokens=1,2,4" %%a IN (%ABuf%) DO (
set /A files+=1
if NOT EXIST !BusyWindow! (
set /A z=files*1000/%score%
if !z! GEQ 30 (
for /F "delims=:., tokens=1-3,5-7" %%c IN ("!TIME::0=:!:%TIME::0=:%") DO set /A valid=%%c*3600+%%d*60+%%e-%%f*3600-%%g*60-%%h
if !valid! LSS 0 set /A valid+=86400
set /A valid=%score%*1000/files*valid/1000-valid
set /A target=valid/3600
set /A valid-=target*3600
set /A score=valid/60
set /A valid-=score*60
set target= !target!
set score=0!score!
set valid=0!valid!
set valid= Est. time remaining: !target:~-2!:!score:~-2!:!valid:~-2!
) ELSE set valid=
set z= !z:~0,-1!.!z:~-1!
set z=!z: .=0.!
set files= !files!
call :EchoWindow " !z:~-5!%%%%, !files:~-7! files processed.!valid!"
set /A "z=(freed*25+32)/64"
set z= !z!
set z=!z:~0,-2!.!z:~-2!
set z=!z:. 0=0 !
set z=!z:. =.0!
set z=!z: .=0.!
set z= !z!
set count= !count!
call :EchoWindow " !count:~-7! hardlinks to create. Will free!z:~-8! MB."
)
if /I "!HighID!"=="%%a" (
if NOT !PrevLang!==%%b (
if !PrevLang! GEQ 500 set BasePathList=!BasePathList!!PrevLang!
set LangPath%%b=
set HighPathList=
) ELSE set HighPathList=%%b
if NOT DEFINED LangKeep%%b set HighPathList=!BasePathList!!HighPathList!
if DEFINED HighPathList (
dir /B /S /A-D-L "%%c" 2>NUL >%ABuf%
for /F "usebackq delims=" %%d IN (%ABuf%) DO (
set HighFile=
set z=%%d
for %%h IN (!HighPathList!) DO if NOT DEFINED HighFile (
set HighPath=!LangPath%%h!
for /F "delims=\ tokens=1*" %%i IN ("!z:%winsxs%=!") DO set HighFile=%%~$HighPath:j
if DEFINED HighFile (
set valid=
set z=0
ln.exe -l "%%d">%buf%
for /F "usebackq delims=\: tokens=1*" %%f IN (%buf%) DO if DEFINED z if NOT "%%f"=="ERROR" if /I NOT "%%f:\%%g"=="!HighFile!" (
set /A z+=1
set sibling!z!=%%f:\%%g
if NOT DEFINED valid if /I NOT "%%f:\%%g"=="%%d" (
set target=%%f:\%%g
if NOT "!target:%winsxs%=!"=="%%f:\%%g" for /F "delims=\" %%i IN ("!target:%winsxs%=!") DO (
set target=%%i
if NOT "!target:_=!"=="%%i" set valid=0
)
) ELSE set valid=1
) ELSE set z=
if DEFINED z (
for /L %%i IN (1,1,!z!) DO echo !HighFile!/!sibling%%i!>>%BBuf%
if "!valid!"=="1" (
set /A count+=z
set /A "freed+=(%%~zd+4095)/4096"
) ) ) ) ) )
) ELSE (
set HighID=%%a
set BasePathList=
set LangPath%%b=
)
set LangPath%%b=!LangPath%%b!%%c;
set PrevLang=%%b
)
cd /D %home%
set files= %files%
call :EchoWindow " 100.0%%%%, %files:~-7% files processed."
set /A "z=(freed*25+32)/64"
set z= %z%
set z=%z:~0,-2%.%z:~-2%
set z=%z:. 0=0 %
set z=%z:. =.0%
set z=%z: .=0.%
set z= %z%
set count= %count%
call :EchoWindow " %count:~-7% hardlinks to create. Will free%z:~-8% MB."
set score=%z: =%
call :EchoWindow "."
call :EchoWindow " Making adjustments..."
call :EchoWindow "."
echo OFF >%ABuf%
set old=
for /F "delims=/ tokens=1,2" %%a IN ('sort /L ""C"" %BBuf%') DO (
set z=%%a
for /F "delims=\" %%c IN ("!z:%winsxs%=!") DO if /I NOT "%%c"=="!old!" (
set z=%%c
for /L %%d IN (1,1,10) DO if DEFINED z for /F "delims=_ tokens=1-5*" %%e IN ("!z!") DO (
if "%%j"=="" (
for /F "delims=. tokens=1-3*" %%k IN ("%%g") DO (
set sibling1=00%%k
set sibling2=000000%%l
set sibling3=000000%%m
set sibling4=000000%%n
)
set version=!sibling1:~-2!!sibling2:~-6!!sibling3:~-6!!sibling4:~-6!
set z=
) ELSE set z=%%f_%%g_%%h_%%i_%%j
)
set old=%%c
)
echo %%b/!version!/%%a>>%ABuf%
)
echo OFF >%BBuf%
set z=
for /F "delims=/ tokens=1,3" %%a IN ('sort /L ""C"" /R %ABuf%') DO if /I NOT "%%a"=="!z!" (
set z=%%a
echo %%a/1/1/%%b>>%BBuf%
echo %%b/2/1/%%a>>%BBuf%
)
echo OFF >%ABuf%
set valid=2
Big GrineChain
sort /L ""C"" %BBuf% /O %buf%
echo OFF >%BBuf%
set z=
for /F "usebackq delims=/ tokens=1-4" %%a IN (%buf%) DO if %%b==1 (
set z=%%a
set target=%%d
set old=%%c
echo %%a/1/%%c/%%d>>%BBuf%
) ELSE if /I NOT "%%a"=="!z!" (
echo %%a/%%d>>%ABuf%
set valid=2
) ELSE if !valid! GTR 0 (
if /I NOT "%%d"=="!target!" (
if !old!==2 (
echo !target!/%%d>>%ABuf%
echo %%d/1/2/!target!>>%BBuf%
set valid=2
) ELSE echo !target!/2/1/%%d>>%BBuf%
) ELSE if NOT !old!==2 echo %%a/2/1/%%d>>%BBuf%
) ELSE (
echo %%a/%%d>>%ABuf%
echo %%d/1/2/%%a>>%BBuf%
echo %%a/1/2/%%a>>%BBuf%
set valid=2
)
if !valid! GTR 0 (
set /A valid-=1
goto DeChain
)
echo OFF >%1
set count=No
for /F "delims=/ tokens=1,2" %%a IN ('sort /L ""C"" %ABuf%') DO (
set /A count+=1
echo !count!/%%~pnxb/%%~pnxa>>%1
)
attrib -a %1
call :EchoWindow " %count% hardlinks to create. Will free %score% MB."
call :CloseWindow
echo %count% lines written to %1.
echo %count% lines written to %1.>>%log%
if NOT %freed%==0 (
set z=Applying this scan will free %score% MB.
echo !z!
echo !z!>>%log%
)
echo ## %DATE% %TIME%: Done.>>%log%
endlocal
goto :EOF

:RelocFolders
if DEFINED NoVista (
echo This function needs Vista to run.
goto :EOF
)
set error=
if DEFINED movefile set error=movefile
if DEFINED pendmoves set error=pendmoves
if DEFINED ln set error=ln
if DEFINED subinacl set error=subinacl
if DEFINED error (
echo Missing %error%.exe command.
goto :EOF
)
if NOT EXIST "%reloc:~0,2%" (
echo Can't relocate folders to "%reloc%" - drive not found.
goto :EOF
)
set z=0
for /F %%a IN ('fsutil FSINFO NTFSINFO %reloc:~0,2%') DO set /A z+=1
if %z% LSS 5 (
echo Target drive %reloc:~0,2% needs to be NTFS.
goto :EOF
)
set z=
for %%a IN (%RelocPaths%) DO (
set valid=
for /F "delims=" %%b IN ('"dir /AD-L /B "%%~dpa" 2>NUL"') DO if /I "%%b"=="%%~nxa" (
set z=!z! %%a
set valid=1
)
if NOT DEFINED valid for /F "delims=> tokens=2" %%b IN ('"dir /AD-L /X "%%~dpa" 2>NUL"') DO (
set valid=%%b
for /F %%c IN ("!valid:~10,13!") DO if /I "%%c"=="%%~nxa" set z=!z! %%a
) )
if NOT DEFINED z (
echo Nothing to relocate.
goto :EOF
)
echo Going to perform the following folder relocations:
echo.
for %%a IN (%z%) DO (
echo %%a
echo ==^> "%reloc%%%~pnxa"
echo.
)
set /P choice=Proceed - [Y]es/[N]o ?
if /I NOT "%choice%"=="Y" goto :EOF
setlocal
echo.>>%log%
echo ## %DATE% %TIME%: Relocating folders.>>%log%
set RelocPaths=%z%
echo OFF >%important%
for %%a IN (%RelocPaths%) DO (
cd /D %%~da\
set z=%%~dpa
subinacl.exe /nov /nos /fil "!z:~0,-1!" /dis=sddl >>%important%
subinacl.exe /nov /nos /fil %%a /dis=sddl >>%important%
)
echo.>%ABuf%
echo OFF >%BBuf%
echo OFF >%ToSchedule%
set typeJUNCTION=/J
set typeSYMLINKD=/D
set typeSYMLINK=
set old=
for %%a IN (%RelocPaths%) DO (
echo.
echo Copying %%a
echo to "%reloc%%%~pnxa"...
echo Copying %%a to "%reloc%%%~pnxa"...>>%log%
if EXIST "%reloc%%%~pnxa" (
set z=The target folder already exists - aborting relocation.
echo !z!
echo !z!>>%log%
set RelocPaths=!RelocPaths:%%a=!
) ELSE (
md "%reloc%%%~pnxa"
if NOT EXIST "%reloc%%%~pnxa" (
set z=Failed to create destination folder - aborting relocation.
echo !z!
echo !z!>>%log%
set RelocPaths=!RelocPaths:%%a=!
) ELSE (
call Big GrinirSetWD "%reloc%%%~pnxa"
set valid=1
robocopy %%a "%reloc%%%~pnxa" /E /B /COPYBig GrinAT /DCOPY:T /SL /XJ /R:0 /NS /NC /NFL /NDL /NP /NJH /NJS >%buf%
if ERRORLEVEL 4 (
set /P choice=Errors encountered during copy - [A]bort/[C]omplete on reboot ?
if /I "!choice!"=="C" (
echo %%~a/%reloc%%%~pnxa>>%ToSchedule%
) ELSE set valid=
)
for %%b IN (%buf%) DO if %%~zb GTR 4 type %buf% >>%log%
if NOT DEFINED valid (
set z=Relocation aborted.
echo !z!
echo !z!>>%log%
rd /S /Q "%reloc%%%~pnxa" >NUL 2>&1
set RelocPaths=!RelocPaths:%%a=!
) ELSE (
set z=Scanning for, and copying, junctions and symbolic links...
echo !z!
echo !z!>>%log%
echo OFF >%buf%
for /F "delims=" %%b IN ('"dir /ADL /B /S %%a 2>NUL"') DO echo %%b\>>%buf%
dir /AL /B /S %%a 2>NUL >>%buf%
set dir=/
for /F "delims=" %%b IN ('sort /L ""C"" %buf%') DO for %%i IN ("!dir!") DO (
set z=%%b
if "!z:%%~i=!"=="!z!" if NOT "!z:~-1!"=="\" (
dir /AL "!z:~0,-1!?" 2>NUL >%buf%
for /F "usebackq delims=<> tokens=2,3" %%c IN (%buf%) DO (
set z=%%c%%d
for /F "delims=: tokens=1*" %%e IN ("!z:~13,-1!") DO if NOT "%%f"=="" (
set valid=%%e
set z=!valid:~-1!:%%f
set valid=!valid:~0,-3!
) ELSE for /F "delims=[ tokens=1*" %%g IN ("%%e") DO (
set valid=%%g
set z=%%h
set valid=!valid:~0,-1!
)
if /I "!valid!"=="%%~nxb" (
mklink !type%%c! "%reloc%%%~pnxb" "!z!" >NUL 2>&1
attrib "%%b" /L >%buf%
for /F "usebackq delims=" %%e IN (%buf%) DO set z=%%e
if /I "!z:~13!"=="%%b" (
set z= +!z:~0,1! +!z:~3,1! +!z:~4,1! +!z:~5,1! +!z:~8,1!
set z=!z: + =!
attrib -a -i "%reloc%%%~pnxb" /L >NUL
attrib !z! "%reloc%%%~pnxb" /L >NUL
) ) )
) ELSE set dir=%%b
)
for /F "delims=\ tokens=1,2" %%b IN ("%%~a\") DO if "!old:"%%b\%%c"=!"=="!old!" set old=!old! "%%b\%%c"
set z=Scanning for preservable hardlinks...
echo !z!
echo !z!>>%log%
echo OFF >%buf%
for /F "delims=" %%b IN ('"dir /ADL /B /S %%a 2>NUL"') DO echo %%b\>>%buf%
dir /A-D /B /S %%a 2>NUL >>%buf%
set dir=/
for /F "delims=" %%b IN ('sort /L ""C"" %buf%') DO for %%f IN ("!dir!") DO (
set z=%%b
if "!z:%%~f=!"=="!z!" if NOT "!z:~-1!"=="\" (
ln.exe -l "%%b">%buf%
set valid=
set done=
for /F "usebackq delims=\: tokens=1*" %%c IN (%buf%) DO if NOT "!valid!"=="0" (
set z=%%c:\%%d
for %%e IN (%RelocPaths%) DO if DEFINED z if NOT "!z:%%~e\=!"=="!z!" set z=
if NOT DEFINED z (
if DEFINED valid (
echo %reloc%\%%d/%reloc%%%~pnxb>>%BBuf%
) ELSE if /I "%%c:\%%d"=="%%b" (
set valid=1
) ELSE set valid=0
) ELSE if NOT DEFINED done set done=%%c:\%%d
)
if DEFINED done if "!valid!"=="1" (
echo +fil !done!>>%ABuf%
echo /dis=sddl>>%ABuf%
)
) ELSE set dir=%%b
)
for /F "usebackq delims=/ tokens=1,2" %%b IN (%BBuf%) DO if EXIST "%%c" (
del /F "%%b" >NUL 2>&1
if EXIST "%%b" (
attrib -s -h -r "%%b" /L >NUL
del /F "%%b" >NUL 2>&1
) ) ) ) ) )
if "%RelocPaths: =%"=="" (
del /F %important% >NUL
cd /D %home%
echo ## %DATE% %TIME%: Done.>>%log%
endlocal
goto :EOF
)
echo.
set z=Restoring hardlinks where possible...
echo %z%
echo %z%>>%log%
for /F "usebackq delims=/ tokens=1,2" %%a IN (%BBuf%) DO %hlink% "%%a" "%%b" >NUL 2>&1
echo Done.
echo Done.>>%log%
echo Copying security...
echo Copying security...>>%log%
subinacl.exe /nov /nos /pla %ABuf% >>%important%
attrib +r +s %important% >NUL
for %%a IN (%old%) DO (
subinacl.exe /nov /nos /sub "%reloc%%%~pnxa\*" /pathc=%%a >NUL
subinacl.exe /nov /nos /fil "%reloc%%%~pnxa" /objectc=%%a >NUL
)
echo Done.
echo Done.>>%log%
set valid=1
for %%a IN (%RelocPaths%) DO (
set z=Activating "%reloc%%%~pnxa"...
echo !z!
echo !z!>>%log%
cd /D %%~da\
set z=%%~dpa
subinacl.exe /nov /nos /fil "!z:~0,-1!" /grant=s-1-1-0=F >NUL
subinacl.exe /nov /nos /fil %%a /grant=s-1-1-0=F >NUL
subinacl.exe /nov /nos /sub "%%~a\*" /grant=s-1-1-0=F >NUL
mklink /J "%%~a.$RenameMe" "%reloc%%%~pnxa" >NUL 2>&1
if ERRORLEVEL 1 (
set z=Failed to create temporary junction "%%~a.$RenameMe"
echo !z!
echo !z!>>%log%
) ELSE (
subinacl.exe /nov /nos /fil "%%~a.$RenameMe" /grant=s-1-1-0=F >NUL
call :ActivateJunction %%a
)
echo.
)
cd /D %home%
echo ## %DATE% %TIME%: Done.>>%log%
if NOT DEFINED valid (
echo Reboot to complete the folder relocation.
for %%a IN (%ToSchedule%) DO if %%~za GTR 0 call :SetStartup
echo.
endlocal
pause
exit
)
attrib -r -s %important% >NUL
call :RestoreSDs Restoring security...
endlocal
goto :EOF

:ActivateJunction
if EXIST "%~1.$RenameMe" (
attrib -s -h -r %1 /L >NUL
ren %1 "%~nx1.$DeleteMe" 2>NUL
if NOT EXIST %1 ren "%~1.$RenameMe" "%~nx1" 2>NUL
if EXIST "%~1.$RenameMe" ren "%~1.$DeleteMe" "%~nx1" 2>NUL
)
if EXIST "%~1.$RenameMe" (
movefile.exe "%LinksDir%$Mark" "%LinksDir%$Mark" >NUL
movefile.exe %1 "%~1.$DeleteMe" >NUL
movefile.exe "%~1.$RenameMe" %1 >NUL
movefile.exe "%LinksDir%$Mark" "%LinksDir%$Mark" >NUL
set z=Scheduled for activation on reboot.
echo !z!
echo !z!>>%log%
set valid=
)
if EXIST %1 if EXIST "%~1.$DeleteMe" (
robocopy "%reloc%%~pnx1" %1 /B /COPY:AT /DCOPY:T /CREATE /SL /XJ /R:0 /NS /NC /NFL /NDL /NP /NJH /NJS >NUL
robocopy "%reloc%%~pnx1" "%~1.$DeleteMe" /B /COPY:AT /DCOPY:T /CREATE /SL /XJ /R:0 /NS /NC /NFL /NDL /NP /NJH /NJS >NUL
if EXIST %ToSchedule% for /F "usebackq delims=/" %%A IN (%ToSchedule%) DO if "%%A"==%1 (
echo Copying %1
echo to "%reloc%%~pnx1"...
echo Copying %1 to "%reloc%%~pnx1"...>>%log%
robocopy "%~1.$DeleteMe" "%reloc%%~pnx1" /E /B /COPYBig GrinAT /SL /XJ /XC /XN /XO /R:0 /NS /NC /NFL /NDL /NP /NJH /NJS >%buf%
for %%B IN (%buf%) DO if %%~zB GTR 4 type %buf% >>%log%
)
set z=Removing deactivated %1...
echo !z!
echo !z!>>%log%
call :EraseDir "%~1.$DeleteMe"
)
goto :EOF

:EraseDir
rd /S /Q %1 >NUL 2>&1
if NOT EXIST %1 goto :EOF
set valid=
attrib -r -s -h %1 /L >NUL
echo OFF >%buf%
for /F "delims=" %%A IN ('"dir /ADL /B /S %1 2>NUL"') DO echo %%A\>>%buf%
dir /AR /B /S %1 2>NUL >>%buf%
set dir=/
for /F "delims=" %%A IN ('sort /L ""C"" %buf%') DO for %%B IN ("!dir!") DO (
set z=%%A
if "!z:%%~B=!"=="!z!" if NOT "!z:~-1!"=="\" (
attrib "%%A" /L >%buf%
for /F "usebackq delims=" %%C IN (%buf%) DO set z=%%C
if /I "!z:~13,3!"=="%%~dA\" (
set z= +!z:~3,1! +!z:~4,1!
set z=!z: + =!
attrib -r!z! "%%A" /L >NUL
)
) ELSE set dir=%%A
)
movefile.exe "%LinksDir%$Mark" "%LinksDir%$Mark" >NUL
echo OFF >%buf%
for /F "delims=" %%A IN ('"dir /ADL /B /S %1 2>NUL"') DO echo %%A\>>%buf%
dir /A-D /B /S %1 2>NUL >>%buf%
set dir=/
for /F "delims=" %%A IN ('sort /L ""C"" %buf%') DO for %%B IN ("!dir!") DO (
set z=%%A
if "!z:%%~B=!"=="!z!" if NOT "!z:~-1!"=="\" (
movefile.exe "%%A" "" >NUL
) ELSE set dir=%%A
)
echo OFF >%buf%
for /F "delims=" %%A IN ('"dir /ADL /B /S %1 2>NUL"') DO echo %%A\>>%buf%
dir /AD /B /S %1 2>NUL >>%buf%
echo >>%buf%
set dir=/
for /F "delims=" %%A IN ('sort /L ""C"" %buf%') DO if NOT "%%A"=="" for %%B IN ("!dir!") DO (
set z=%%A
if "!z:%%~B=!"=="!z!" if NOT "!z:~-1!"=="\" (
echo %%A>>%buf%
) ELSE set dir=%%A
) ELSE echo OFF >%buf%
sort /L ""C"" /R %buf% /O %buf%
for /F "usebackq delims=" %%A IN (%buf%) DO movefile.exe "%%A" "" >NUL
movefile.exe %1 "" >NUL
movefile.exe "%LinksDir%$Mark" "%LinksDir%$Mark" >NUL
set z=Remainder scheduled for removal on reboot.
echo %z%
echo %z%>>%log%
goto :EOF

:RestoreSDs
echo %*
subinacl.exe /nov /nos /pla %important% >NUL
move /Y %important% %unimportant% >NUL
echo Done.
goto :EOF

Big GrinirSetWD
subinacl.exe /nov /nos /fil %1 /sddl=DTongueARAI(A;OICI;FA;;;WD) >NUL
goto :EOF

:WinsxsSize
set choice=
if DEFINED ReParse (
echo "%winsxs:~0,-1%" is a reparse point to !ReParse!
goto :EOF
)
if DEFINED NoVista (
echo This function needs Vista to run.
goto :EOF
)
if DEFINED ln (
echo Missing ln.exe command.
goto :EOF
)
setlocal
echo.>>%log%
echo ## %DATE% %TIME%: Calculating folder sizes.>>%log%
set z=
for /F "delims=: tokens=2" %%a IN ('fsutil VOLUME DISKFREE %rootd%') DO set z=!z!%%a
for /F "tokens=2,3" %%a IN ("%z%") DO (
set total=%%a0
set unique=%%b0
)
set z= %total:~-4%
set z=%z: 0= %
set z=%z: 0= %
set z=%z: 0= %
set total=%total:~0,-4%
set /A "total=((2500*(total&0x3FFFF)+(%z%+1)/4+0x1FFFF)>>18)+2500*(total>>18)"
set z= %unique:~-4%
set z=%z: 0= %
set z=%z: 0= %
set z=%z: 0= %
set unique=%unique:~0,-4%
set /A "unique=((2500*(unique&0x3FFFF)+(%z%+1)/4+0x1FFFF)>>18)+2500*(unique>>18)"
set /A z=total-unique
set z= %z:~0,-1%.%z:~-1%
set z=%z: .=0.%
set unique= %unique:~0,-1%.%unique:~-1%
set unique=%unique: .=0.%
set z= %z: =% MB used, %unique: =% MB free space on drive %rootd%
echo %z%
echo.
echo %z%>>%log%
set SizePaths="%winsxs%Temp" "%winsxs%InstallTemp" "%winsxs%ManifestCache" "%winsxs%FileMaps" "%winsxs%Catalogs" "%winsxs%Manifests" "%winsxs%Backup" "%winsxs:~0,-1%"
set SizePaths=!SizePaths:%rootd%\=!
dir /AD-L /B /S "%winsxs%" >%ABuf%
find /V "=" %ABuf% >%BBuf%
set z=%winsxs:~0,-1%
echo %z:\=%>%ABuf%
for /F "usebackq skip=2 delims=" %%a IN (%BBuf%) DO (
set z=%%a
echo !z:\=!>>%ABuf%
)
set z= Unique Shared Folder
echo %z%
echo %z%>>%log%
echo OFF >%BBuf%
set old=%root%\%win%\
for /F "delims=" %%a IN ('sort /L ""C"" %ABuf%') DO (
set z=%%a
for %%b IN ("!z:=\!") DO if NOT "!old:%%~dpb=!"=="!old!" (
set old=%%~b\
echo -/%%~b>>%BBuf%
dir /A-D-L /B %%b 2>NUL >>%BBuf%
) )
find /V "=" %BBuf% >%ABuf%
set z=-----------------------------------------------------------------
echo %z%
echo %z%>>%log%
echo OFF >%BBuf%
for /F "usebackq skip=2 delims=/ tokens=1*" %%a IN (%ABuf%) DO if "%%b"=="" (
for %%c IN ("!z!\%%a") DO if NOT "%%~zc"=="" echo %%~zc%%~pnxc>>%BBuf%
) ELSE set z=%%b
sort /L ""C"" %BBuf% /O %ABuf%
set total=0
for %%a IN (%SizePaths%) DO (
set unique=0
set shared=0
if %%a=="%winsxs:~3,-1%" (
sort /L ""C"" %ABuf% /O %ABuf%
echo ->>%ABuf%
echo ->%BBuf%
echo ->>%BBuf%
set valid=
set z=
for /F "usebackq delims=" %%b IN (%ABuf%) DO if /I NOT "%%b"=="!z!" (
if DEFINED valid (
echo !z!>>%BBuf%
) ELSE set valid=1
set z=%%b
) ELSE set valid=
) ELSE find "\%%~a\" %ABuf% >%BBuf%
for /F "usebackq skip=2 delims=\ tokens=1*" %%b IN (%BBuf%) DO if "!\%%c!"=="" (
set valid=1
ln.exe -l "%rootd%\%%c">%buf%
for /F "usebackq delims=\: tokens=1*" %%d IN (%buf%) DO if /I NOT "%%e"=="%%c" (
set z=\%%e
if NOT "!z:\%%~a\=!"=="!z!" (
set \%%e=1
) ELSE set valid=
)
if DEFINED valid (
if NOT %%a=="%winsxs:~3,-1%" for /F "usebackq delims=\: tokens=1*" %%d IN (%buf%) DO echo %%b\%%e>>%ABuf%
set /A "unique+=(%%b+4095)/4096"
) ELSE set /A "shared+=(%%b+4095)/4096"
) ELSE set \%%c=
set /A total+=unique
if %%a=="%winsxs:~3,-1%" set unique=!total!
set /A "z=(shared*25+32)/64"
set z= !z!
set z=!z:~0,-2!.!z:~-2!
set z=!z:. =.0!
set shared=!z: .=0.!
set /A "z=(unique*25+32)/64"
set z= !z!
set z=!z:~0,-2!.!z:~-2!
set z=!z:. =.0!
set unique=!z: .=0.!
set z=!unique:~-10! MB !shared:~-10! MB "%rootd%\%%~a"
echo !z!
echo !z!>>%log%
)
set z=-----------------------------------------------------------------
echo %z%
echo %z%>>%log%
echo ## %DATE% %TIME%: Done.>>%log%
endlocal
goto :EOF

:ClearLinksDir
call :ClearReg
if DEFINED error goto :EOF
setlocal
echo Deleting hardlinks from "%LinksDir:~0,-1%"...
set scheduled=
set count=No
set MissingFile=
movefile.exe "%LinksDir%$Mark" "%LinksDir%$Mark" >NUL
for /F "usebackq delims=/ tokens=1,2" %%a IN (%ToSchedule%) DO if EXIST "%LinksDir%%%a" if EXIST "%rootd%%%b" (
set /A count+=1
del /F "%LinksDir%%%a" >NUL 2>&1
if EXIST "%LinksDir%%%a" (
for /F "delims=" %%d IN ('attrib "%LinksDir%%%a"') DO set z=%%d
if "!z:~5,1!"=="R" attrib -r -s -h "%LinksDir%%%a" >NUL
set /A scheduled+=1
movefile.exe "%LinksDir%%%a" "" >NUL
)
) ELSE (
move /Y "%LinksDir%%%a" "%rootd%%%b" >NUL 2>&1
if NOT EXIST "%rootd%%%b" set /A MissingFile+=1
)
movefile.exe "%LinksDir%$Mark" "%LinksDir%$Mark" >NUL
if DEFINED scheduled (
set /A z=count-scheduled
echo !z! hardlinks out of !count! were deleted.
echo The remaining !scheduled! hardlinks were scheduled for deletion on reboot.
) ELSE echo !count! hardlinks were deleted.
if DEFINED MissingFile (
echo !MissingFile! hardlinks weren't deleted, because the files they're meant to replace,
echo don't exist anymore, and for some reason they couldn't be moved to solve this.
echo It's important that these hardlinks are activated.
)
endlocal
goto :EOF

:ClearReg
set error=true
setlocal
echo Clearing pending WinsxsLite file operations from registry...
set valid=true
set z=
for /F "delims=: tokens=1,2*" %%A IN ('"pendmoves.exe 2>NUL"') DO (
if NOT DEFINED z (
reg DELETE "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /V "PendingFileRenameOperations" /F >NUL 2>&1
reg QUERY "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /V "PendingFileRenameOperations" >NUL 2>&1
if NOT ERRORLEVEL 1 (
echo Unable to clear pending file delete and rename operations in registry.
endlocal
goto :EOF
)
set z=/
)
if "%%A"=="Source" (
set z=%%B
set source="!z:~1!:%%C"
) ELSE (
set target=
if "%%A"=="Target" (
set z=%%B
set target="!z:~1!:%%C"
) ELSE if "%%B"==" Target" (
set z=%%C
set target="!z:~1!"
)
if DEFINED target (
if DEFINED valid (
if /I NOT !source!=="%LinksDir%$Mark" (
if !target!=="DELETE" set target=""
movefile.exe !source! !target! >NUL
) ELSE set valid=
) ELSE if /I !source!=="%LinksDir%$Mark" set valid=true
) ) )
endlocal
set error=
echo Done.
goto :EOF

:SetStartup
if DEFINED NoVista goto :EOF
setlocal
echo WinsxsLite has been scheduled to run on reboot.
set z=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup\0
if DEFINED AutoStarted (
for /F "delims=\ tokens=12" %%A IN ('"reg QUERY "%z%" /F "ClearAutoStart" /S /D 2>NUL"') DO (
reg ADD "%z%\%%A" /F /V "Parameters" /D "AutoReboot" >NUL 2>&1
reg ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Startup\0\%%A" /F /V "Parameters" /D "AutoReboot" >NUL 2>&1
)
endlocal
goto :EOF
)
call :ClearStartup
set valid=-1
for /F "delims=\ tokens=12" %%A IN ('"reg QUERY "%z%" /F "*" /K 2>NUL"') DO if %%A GTR !valid! set valid=%%A
set /A valid+=1
set AutoStart=0
set /A ClearAutoStart=valid+1
for /L %%A IN (1,1,2) DO (
set count=!valid!
for /L %%B IN (!valid!,-1,1) DO (
set /A count-=1
reg COPY "!z!\!count!" "!z!\%%B" /S /F >NUL 2>&1
reg DELETE "!z!\!count!" /F >NUL 2>&1
)
reg ADD "!z!" /F /V "GPO-ID" /D "LocalGPO" >NUL 2>&1
reg ADD "!z!" /F /V "SOM-ID" /D "Local" >NUL 2>&1
reg ADD "!z!" /F /V "FileSysPath" /D "%root%\%win%\System32\GroupPolicy\Machine" >NUL 2>&1
reg ADD "!z!" /F /V "DisplayName" /D "Local Group Policy" >NUL 2>&1
reg ADD "!z!" /F /V "GPOName" /D "Local Group Policy" >NUL 2>&1
for %%B IN (AutoStart ClearAutoStart) DO (
reg ADD "!z!\!%%B!" /F /V "Script" /D %WinsxsLite% >NUL 2>&1
reg ADD "!z!\!%%B!" /F /V "Parameters" /D "%%B" >NUL 2>&1
reg ADD "!z!\!%%B!" /F /V "ExecTime" /T REG_BINARY /D 00000000000000000000000000000000 >NUL 2>&1
)
set z=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Startup\0
)
set z=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
reg ADD "%z%" /F /V "MaxGPOScriptWait" /T REG_DWORD /D 0 >NUL 2>&1
reg ADD "%z%" /F /V "HideStartupScripts" /T REG_DWORD /D 0 >NUL 2>&1
reg ADD "%z%" /F /V "RunStartupScriptSync" /T REG_DWORD /D 1 >NUL 2>&1
endlocal
goto :EOF

:ClearStartup
if DEFINED NoVista goto :EOF
setlocal
set z=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup\0
for /F "delims=\ tokens=12" %%A IN ('"reg QUERY "%z%" /F %WinsxsLite% /S /D 2>NUL"') DO (
reg DELETE "%z%\%%A" /F >NUL 2>&1
reg DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy...
Ответ
#10
Скачай снова сайта MS - она там отдельной утилкой есть.
Ответ


Возможно похожие темы ...
Тема Автор Ответы Просмотры Последний пост
  Windows 10 Ashe 180 48,189 06-28-2021, 08:58 AM
Последний пост: xlBASlx
  Ищу Milestone-билды Windows 8 Zeratyl 0 2,685 06-23-2019, 01:19 AM
Последний пост: Zeratyl
  windows 10 LTSB Deazer 17 7,409 07-04-2018, 03:42 PM
Последний пост: PowerVPS
  Минимальные роли Windows 2003 Server TiJester 0 2,955 08-29-2016, 10:29 AM
Последний пост: TiJester
  Обновление до Windows 10 Ro_0TT 49 13,918 03-02-2016, 03:52 PM
Последний пост: Emperor
  Windows Server 2003 Как отключить синхронизацию времени? itcry 1 3,943 05-18-2015, 03:41 PM
Последний пост: xolseg
  Windows 8 - аудиодрайверы для старых компов OneThunder 5 1,959 09-22-2014, 04:30 PM
Последний пост: OneThunder
  windows phone 8 и Bluetooth Dementor 21 4,559 01-31-2014, 08:25 PM
Последний пост: Dementor
  windows server 2008 desktop devillord 6 2,608 01-11-2014, 10:50 PM
Последний пост: devillord
  Windows\Linux и Razer устройства. (Зависание оборудования) L2CCCP 8 3,575 08-03-2013, 07:44 PM
Последний пост: Trinity

Перейти к форуму:


Пользователи, просматривающие эту тему: 1 Гость(ей)