elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Entrar al Canal Oficial Telegram de elhacker.net


+  Foro de elhacker.net
|-+  Sistemas Operativos
| |-+  Windows (Moderador: Randomize)
| | |-+  Guía de personalización de imágenes de implementación de Windows (WIM) (Parte 5)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Guía de personalización de imágenes de implementación de Windows (WIM) (Parte 5)  (Leído 5,185 veces)
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.775



Ver Perfil
Guía de personalización de imágenes de implementación de Windows (WIM) (Parte 5)
« en: 12 Abril 2014, 23:20 pm »

5.0
· Introducción a las características/paquetes de Windows




Windows instala consigo muchas características, algunas son visibles y configurables para el usuario como Windows Media Player e Internet Explorer, pero otras son completamente ocultas por seguridad, como drivers, codecs, Telnet, Reconocimiento de voz, y muchas otras cosas más internas, estas características se distribuyen dentro de "paquetes" los cuales están catalogados y se pueden instalar y/o desinstalar dentro de una imagen WIM, paquetes y características se tratan por separado.


· ¿Que herramientas necesitaremos?
·DISM, para el montaje de la imagen y la eliminación de paquetes y características.
· WIM Registry Tweak Tool, para tomar privilegios necesarios en el Hive montado.





5.1
· Obtener información sobre los paquetes

Primero deben usar DISM para montar la imagen Install.wim del DVD de Windows en un directorio (recuerden montar el índice de imagen que quieren manipular), en el punto 3.2 del tutorial está explicado el procedimiento de montaje usando DISM.

En este ejemplo montaré el índice 1 de mi imagen WIM del DVD original de Windows 8.1, que hace referencia a la edición "Windows 8.1 (Core)", la sintaxis del comando es esta:
Código:
Dism.exe /Mount-Image /imageFile:".\Install.wim" /Index:"1" /MountDir:"C:\WinMount"



Seguídamente, para obtener los paquetes visibles y que están instalados en dicha edición/imagen usamos DISM de nuevo usando esta sintaxis:
Código:
Dism.exe /Get-Packages /Image:"Directorio de montaje"

El parámetro /Get-Packages indica que se trata de una operación de obtención de información.
En el parámetro /Image debemos indicar el directorio donde previamente hemos montado la imagen WIM.

Ejemplo:
Código:
Dism.exe /Get-Packages /Image:"C:\WinMount" /Format:Table



También podemos usar la utilidad WIM Registry Tweak Tool para desocultar los paquetes ocultos y obtener los paquetes, usaremos esta sintaxis:
Código:
"WIM Registry Tweak Tool.exe" /p "Directorio de montaje" /l

Ejemplo:
Código:
"WIM Registry Tweak Tool.exe" /p "C:\WinMount" /l



Esto nos creará un archivo "Packages.txt" en el directorio de trabajo del WIM Registry Tweak Tool con los nombres de los paquetes existentes:

Packages.txt
Código:
Adobe-Flash-For-Windows-Package~31bf3856ad364e35~amd64~~6.3.9600.16384
Microsoft-Windows-InternetExplorer-Optional-Package~31bf3856ad364e35~amd64~es-ES~11.0.9600.16384
Microsoft-Windows-InternetExplorer-Optional-Package~31bf3856ad364e35~amd64~~11.0.9600.16384
Microsoft-Windows-InternetExplorer-Package-shell~31bf3856ad364e35~amd64~es-ES~6.3.9600.16384
Microsoft-Windows-InternetExplorer-Package-shell~31bf3856ad364e35~amd64~~6.3.9600.16384
Microsoft-Windows-InternetExplorer-Package-ua~31bf3856ad364e35~amd64~es-ES~6.3.9600.16384
Microsoft-Windows-InternetExplorer-Package-ua~31bf3856ad364e35~amd64~~6.3.9600.16384
Microsoft-Windows-InternetExplorer-Package~31bf3856ad364e35~amd64~es-ES~11.0.9600.16384
Microsoft-Windows-InternetExplorer-Package~31bf3856ad364e35~amd64~~11.0.9600.16384
...


Nota: Los nombres de los paquetes también los pueden encontrar en el directorio montado: ...\Windows\Servicing\Packages





5.2
· Obtener información sobre las características

Nota: Lista de características de Windows 8.1: http://technet.microsoft.com/en-us/library/dn328991.aspx

Para obtener las carcterísticas que están habilitadas en la imagen de Windows usaremos DISM.

Sintaxis
Código:
Dism.exe /Get-Features /Image:"Directorio de montaje" /Format:Table

Ejemplo:
Código:
Dism.exe /Get-Features /Image:"C:\WinMount" /Format:Table







5.3
· Eliminar paquetes

Aqui deben tener MUCHO cuidado, ya que muchos paquetes son esenciales para el correcto funcionamiento de windows (Ej: Drivers, NET Framework, etc...), pero una gran mayoria son inutiles y muchos de nosotros no los querremos tener instalados, pudiendo así ahorrar espacio de instalación y consumo de RAM.

Nota: Los archivos asociados a los paquetes no se eliminan del directorio WinSXS, simplemente dejarán una señal de desinstalación pendiente para cuando vayamos a instalar Windows.

La complejidad para eliminar un paquete puede variar, si tienen más de un índice en una imagen Install.wim es muy probable que los paquetes dependan de otras ediciones (índices) y no se pueden eliminar, además DISM puede dar un error de acceso denegado al montar los Hives del registro, así que para asegurarnos de que todo sale bien, primero utilizaremos la utilidad WIM Registry Tweak Tool para montar el registro y tomar los privilegios necesarios de Admin:

Ejecutaremos WIM Registry Tweak Tool usando esta sintaxis:
Código:
"WIM Registry Tweak Tool.exe" /p "Directorio de montaje"

Ejemplo:
Código:
"WIM Registry Tweak Tool.exe" /p "C:\WinMount"



Ahora ya estamos listos para desinstalar los pquetes que queramos usando DISM (También pueden hacerlo con WIM Registry Tweak Tool, pero es más seguro DISM).

Ejecutaremos DISM con esta sintaxis:
Código:
Dism.exe /Remove-Package /PackageName:"Nombre de la característica" /Imaage:"Directorio de montaje"

Ejemplo:
Código:
Dism.exe /Remove-Package /PackageName:"microsoft-windows-internetexplorer-optional-package~31bf3856ad364e35~amd64~~119600.16384" /Image:"C:\WinMount"



Listo!





5.4
· Desactivar características

El procedimiento para desactivar características es casi identico al de eliminar paquetes pero sin las mayores dificultades que tiene este otro, y con la diferencia además de que no corren ningún riesgo grave en el funcionamiento del SO por desactivar una característica (siempre la pueden volver a habilitar).

Para desactivar una característica de Windows, ejecutamos DISM usando la siguiente sintaxis:
Código:
Dism.exe /Image:"Directorio de montaje" /Disable-Feature /FeatureName:"Nombre de característica"

Ejemplo:
Código:
Dism.exe /Image:"C:\WinMount" /Disable-Feature /FeatureName:"WindowsMediaPlayer"






5.5
· Finalizando la eliminación de paquetes y desactivación de características

El último paso que debemos tener en cuenta es desmontar la imagen y aplicar los cambios realizados,
esto lo haremos utilizando DISM con la siguiente sintaxis:
Código:
Dism.exe /Unmount-Wim /Commit /MountDir:"Directorio de montaje"

Ejemplo:
Código:
Dism.exe /Unmount-Wim /Commit /MountDir:"C:\WinMount"



Nota: Opcionalmente podemos usar la utilidad ImageX para reconstruir la imagen WIM, el manejo de esta operación está explicada en el punto 3.4 del tutorial.





5.6
· Automatizar la eliminación de paquetes

He desarrollado un modo mediante el cual solo necesitan escribir los nombres de los paquetes que quieren eliminar en un archivo de texto y usar un Script Batch, el cual se encargará de Montar, tomar privilegios, eliminar, desmontar y reconstruir, todo de forma automatizada.

Todo lo necesario está incluido en este archivo comprimido:
http://www.mediafire.com/download/mq7o7q7brq6h4ca/WIM_Package_Uninstaller.rar


Una imagen de muestra:



Instrucciones:
Deben crear un archivo llamado "Packages.txt" y añadir los nombres de los paquetes que desenan eliminar (1 nombre por linea).

Ejemplo:
Packages.txt
Código:
microsoft-windows-miracast-driver-package~31bf3856ad364e35~amd64~~6.3.9600.16384
microsoft-windows-mobilepc-client-basic-package~31bf3856ad364e35~amd64~es-es~6.3.9600.16384
microsoft-windows-vpnplugins-package~31bf3856ad364e35~amd64~~6.3.9600.16384
microsoft-windows-webcamexperience-package~31bf3856ad364e35~amd64~~6.3.9600.16384

Seguídamente utilizan este Script.

Nota: Deben configurar los valores de las variables que están documentadas en la cabecera del código.

WIM Package Uninstaller.cmd
Código
  1. @Echo OFF
  2.  
  3.  
  4.  
  5. REM =================
  6. REM Console Settings:
  7. REM =================
  8.  
  9. Title WIM Package Uninstaller - By Elektro
  10. Mode Con Cols=150 Lines=50
  11. CHCP 1252 1>NUL & REM Windows-1252, Spanish-Latin.
  12.  
  13.  
  14.  
  15. REM =====
  16. REM Info:
  17. REM =====
  18.  
  19. Echo  ----------------------------------------------------------------------------------
  20. Echo  This script mounts a Windows Image ^(WIM^) and then removes pre-installed packages
  21. Echo  ----------------------------------------------------------------------------------
  22.  
  23.  
  24.  
  25. REM ====================
  26. REM User defined values:
  27. REM ====================
  28.  
  29. REM This value indicates whether the Windows Image should be mounted.
  30. REM True  = 'DISM' will try to mount the 'WIM' image.
  31. REM False = 'DISM' will not try to mount the WIM image.
  32. REM Set this value to 'FALSE' if the 'WIM' image is already mounted in the specified mount directory,
  33. REM Otherwise, keep it as 'TRUE'.
  34. Set "MountImage=True"
  35.  
  36. REM This value indicates whether the Windows Image should be unmounted at the end.
  37. REM True  = 'DISM' will try to unmount the 'WIM' image.
  38. REM False = 'DISM' will not try to unmount the WIM image.
  39. REM Set this value to 'FALSE' if you want to keep the image mounted to make other changes,
  40. REM Otherwise, keep it as 'TRUE'.
  41. Set "UnmountImage=True"
  42.  
  43. REM This value indicates whether the Windows Image should be rebuilt at the end.
  44. REM True  = 'ImageX' will try to rebuild the 'WIM' image.
  45. REM False = 'ImageX' will keep the 'WIM' image as is.
  46. REM Set this value to 'FALSE' if you want to keep the image with normal size to make other changes,
  47. REM Otherwise, keep it as 'TRUE'.
  48. Set "Rebuild=True"
  49.  
  50. REM This value indicates the 'WIM' image to be mounted.
  51. Set "WindowsImage=%UserProfile%\Desktop\win 8 .1\win\sources\install.wim"
  52.  
  53. REM This value indicates the Image Index of the 'WIM' image.
  54. Set "ImageIndex=1"
  55.  
  56. REM This value indicates the directory where to mount the 'WIM' image.
  57. Set "MountDir=%HomeDrive%\WinMount"
  58.  
  59. REM This value indicates the textfile that contains the names of the packages to remove.
  60. Set "PackageList=%CD%\Packages.txt"
  61.  
  62. REM This value indicates the ubication of the 'WIM Registry Tweak Tool.exe' file.
  63. Set "WIMRegistryTweakTool=%CD%\Tools\WIM Registry Tweak Tool\WIM Registry Tweak Tool.exe"
  64.  
  65. REM This value indicates the ubication of 'ImageX.exe' file.
  66. Set "ImageX=%CD%\Tools\Dism\ImageX.exe"
  67.  
  68. REM This value indicates the ubication of a custom 'DISM.exe' file if needed.
  69. REM Default ubication: "%SystemRoot%\System32\Dism.exe"
  70. Set "Dism=%CD%\Tools\Dism\Dism.exe"
  71.  
  72. REM This value indicates the ubication of the logfile that will record 'DISM' errors.
  73. Set "DismLogfile=%CD%\%~n0 DISM.log"
  74.  
  75. REM This value indicates the logging-level of the 'DISM' process.
  76. REM 1 = Errors only
  77. REM 2 = Errors and warnings
  78. REM 3 = Errors, warnings, and informational
  79. REM 4 = All of the information listed previously, plus debug output
  80. Set /A "DismLogLevel=2"
  81.  
  82. REM This value indicates the ubication of the logfile that will record Main information.
  83. Set "Logfile=%CD%\%~n0.log"
  84.  
  85.  
  86.  
  87. REM =====
  88. REM Main:
  89. REM =====
  90.  
  91. :: Call Methods.
  92. Call :CheckErrors
  93. Call :CreateLogs
  94. Call :CreateMountDir
  95. Call :GetWIMSizeBefore
  96. Call :StartTimer
  97. Call :Mount
  98. CLS
  99. Call :ParsePackages
  100. CLS
  101. Call :CleanUp
  102. Call :Unmount
  103. Call :Rebuild
  104. Call :StopTimer
  105. Call :GetWIMSizeAfter
  106. Call :EndLog
  107. Pause&Exit
  108.  
  109.  
  110.  
  111. REM ========
  112. REM Methods:
  113. REM ========
  114.  
  115.  
  116. :CreateLogs
  117.  
  118. :: Create the 'DISM' logfile with 'ANSI' encoding,
  119. :: this is necessary to record a non-default 'DISM' loglevel such as '1' or '2'.
  120. Echo+ >"%DismLogfile%"
  121.  
  122.  
  123. :: Create the Main logfile and record starting info on it.
  124. Echo+ >"%Logfile%"
  125. (
  126. Echo   WIM Package Uninstaller
  127. Echo ===========================
  128. Echo   %DATE% ^| %TIME:~0,-3%
  129. Echo /\/\/\/\/\/\/\/\/\/\/\/\/\/
  130. Echo [i] Mount Image?...: %MountImage%
  131. Echo [i] Unmount Image?.: %UnmountImage%
  132. Echo [i] Windows Image..: %WindowsImage%
  133. Echo [i] Image Index....: %ImageIndex%
  134. Echo [i] Mount Directory: %MountDir%
  135. Echo [i] ImageX Path....: %ImageX%
  136. Echo [i] Dism Path......: %Dism%
  137. Echo [i] Dism Log File..: %DismLogfile%
  138. Echo [i] Dism Log Level.: %DismLogLevel%
  139. Echo [i] Package List...: %PackageList%
  140. Echo [i] Log File.......: %Logfile%
  141. Echo ===========================
  142. )>"%Logfile%"
  143.  
  144. :: Display starting log info.
  145. Type "%Logfile%"
  146.  
  147. :: Continue writting log.
  148. (
  149. Echo Package conflicts:
  150. Echo ==================
  151. )>>"%LogFile%"
  152. Goto:EOF
  153.  
  154.  
  155. :EndLog
  156. (
  157. Echo [i] Done!
  158. Echo [i] WIM Image Size Before........: %WIMSizeBefore%
  159. Echo [i] WIM Image Size After.........: %WIMSizeAfter%
  160. Echo [i] Packages Successfully Removed: %PackagesRemovedCount% Packages.
  161. Echo [i] Packages Failed To Remove....: %PackagesFailedCount% Packages.
  162. Echo [i] Packages Not Found...........: %PackagesNotFoundCount% Packages.
  163. Echo [i] Elapsed Time.................: %ElapsedTime%
  164. )>>"%LogFile%"
  165.  
  166. :: Display ending information.
  167. CLS
  168. Type "%LogFile%"
  169. Goto:EOF
  170.  
  171.  
  172. :CreateMountDir
  173. :: Create the mount directory.
  174. (
  175. If Not Exist "%MountDir%" If /I "%MountImage%" EQU "True" (
  176. MkDir "%MountDir%" 2>NUL
  177. )
  178. ) || (
  179. Echo [x] Error trying to create the directory "%MountDir%" to mount the Windows Image.
  180. Echo [i] Ensure that you have Admin rights to create the directory.
  181. Echo [i] Ensure that the directory name does not contains illegal characters.
  182. Pause&Exit
  183. )
  184. Goto:EOF
  185.  
  186.  
  187. :Mount
  188. :: Mount the Windows Image into the directory.
  189. Echo [+] Mounting WIM Image...
  190. If /I "%MountImage%" EQU "True" (
  191.  
  192. "%Dism%" /Mount-Image /ImageFile:"%WindowsImage%" /Index:"%ImageIndex%" /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" || (
  193. Echo [x] Error mounting the Image Index "%ImageIndex%" in "%MountDir%"
  194. Echo [i] Ensure that the Image Index exist.
  195. Echo [i] Ensure that you have Admin rights to write inside the directory.
  196. Echo [i] Ensure that the directory is not already mounted.
  197. Echo [i] Ensure that the directory is fully empty.
  198. REM Try to unmount the failed image and discard changes.
  199. If /I "%UnmountImage%" EQU "True" (
  200. Echo [+] Unmounting and discarding changes...
  201. "%Dism%" /Unmount-WIM /Discard /MountDir:"%MountDir%"
  202. )
  203. Pause&Exit
  204. )
  205.  
  206. )
  207. Goto:EOF
  208.  
  209.  
  210. :CleanUp
  211. Echo [+] CleaningUp WIM Image...
  212. "%Dism%" /CleanUp-Image /StartComponentCleanUp /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet
  213. Goto:EOF
  214.  
  215.  
  216. :Unmount
  217. :: Unmount the Windows Image commiting changes.
  218. Echo [+] Unmounting WIM Image...
  219. If /I "%UnmountImage%" EQU "True" (
  220. "%Dism%" /Unmount-WIM /Commit /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%"
  221. )
  222. Goto:EOF
  223.  
  224.  
  225. :Rebuild
  226. If /I "%Rebuild%" EQU "False" (Goto:EOF)
  227.  
  228. Echo [+] Rebuilding WIM image...
  229.  
  230. ("%ImageX%" /Compress Maximum /Export "%WindowsImage%" "*" "%TEMP%\Rebuilt Image.wim" /Check) && (
  231. Del /Q /F "%WindowsImage%" 1>NUL
  232. Move /Y "%TEMP%\Rebuilt Image.wim" "%WindowsImage%" 1>NUL
  233. ) || (
  234. Echo [x] Error rebuilding Image "%WindowsImage%" to "%TEMP%\Rebuilt Image.wim".
  235. )
  236.  
  237. Goto :EOF
  238.  
  239.  
  240. :StartTimer
  241. Set "StartingDate=%Date%"
  242. Set "StarttingTime=%Time:~0,-3%"
  243. Goto :EOF
  244.  
  245.  
  246. :StopTimer
  247. (
  248. Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
  249. Echo WScript.Echo Minutes ^& " Minutes"
  250. )>"%TEMP%\%~n0 MinuteDiff.vbs"
  251.  
  252. For /F "Tokens=*" %%# In (
  253. 'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
  254. ) Do (
  255. Set "ElapsedTime=%%#"
  256. )
  257.  
  258. Goto:EOF
  259.  
  260.  
  261. :WriteConvertBytesScript
  262. If Exist "%TEMP%\%~n0 Convert Bytes.vbs" (Goto:EOF)
  263. (
  264. Echo Suffix = Array^("Bytes", "KB", "MB", "GB", "TB"^)
  265. Echo Function Convert^(Bytes^)
  266. Echo Convert = convert0^(Bytes, 0^)
  267. Echo End Function
  268. Echo Function Convert0^(Bytes, Level^)
  269. Echo If Bytes ^>= 1024 Then
  270. Echo Bytes = Round^(Bytes / 1024, 2^)
  271. Echo Level = Level + 1
  272. Echo Convert0 = Convert0^(Bytes, Level^)
  273. Echo End If
  274. Echo Convert0 = Bytes ^& " " ^& Suffix^(Level^)
  275. Echo End Function
  276. Echo WScript.Echo Convert^(WScript.Arguments^(0^)^)
  277. )>"%TEMP%\%~n0 Convert Bytes.vbs"
  278. Goto:EOF
  279.  
  280.  
  281. :GetWIMSizeBefore
  282. Call :WriteConvertBytesScript
  283. For %%# in ("%WindowsImage%") Do (Set "WIMSizeBefore=%%~z#")
  284. For /F "Tokens=*" %%# In (
  285. 'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeBefore%"'
  286. ) Do (
  287. Set "WIMSizeBefore=%%#"
  288. )
  289. Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
  290. Goto:EOF
  291.  
  292.  
  293. :GetWIMSizeAfter
  294. Call :WriteConvertBytesScript
  295. For %%# in ("%WindowsImage%") Do (Set "WIMSizeAfter=%%~z#")
  296. For /F "Tokens=*" %%# In (
  297. 'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeAfter%"'
  298. ) Do (
  299. Set "WIMSizeAfter=%%#"
  300. )
  301. Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
  302. Goto:EOF
  303.  
  304.  
  305. :ParsePackages
  306.  
  307. Set /A "PackagesRemovedCount=0"
  308. Set /A "PackagesFailedCount=0"
  309. Set /A "PackagesNotFoundCount=0"
  310.  
  311. :: Unhide packages and take registry ownership.
  312. "%WIMRegistryTweakTool%" /p "%MountDir%"
  313.  
  314. :: Remove Packages.
  315. For /F "UseBackQ Tokens=* Delims=" %%# In ("%PackageList%") Do (
  316.  
  317. Echo [+] Removing package: %%~#
  318.  
  319. "%Dism%" /Remove-Package /PackageName:"%%~#" /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet 1>NUL
  320.    Call Set /A "ExitCode=%%Errorlevel%%"
  321.  
  322.    (Call Echo "%%ExitCode%%"| Findstr.exe "^\"0\"$" 1>NUL 2>&1) && (
  323.     Call Set /A "PackagesRemovedCount+=1"
  324.    )
  325.  
  326. (Call Echo "%%ExitCode%%"| Findstr.exe "^\"5\"$" 1>NUL 2>&1) && (
  327. Call Set /A "PackagesFailedCount+=1"
  328. Echo Failed to remove package: %%~#>>"%LogFile%"
  329. )
  330.  
  331. (Call Echo "%%ExitCode%%"| Find.exe "-2146498555" 1>NUL 2>&1) && (
  332. Call Set /A "PackagesNotFoundCount+=1"
  333. Echo Package is not installed: %%~#>>"%LogFile%"
  334. )
  335.  
  336. )
  337. Goto:EOF
  338.  
  339.  
  340.  
  341. REM ====================
  342. REM File Error Controls:
  343. REM ====================
  344.  
  345. :CheckErrors
  346. :: WIM File Error-Check.
  347. If /I "MountImage" EQU "True" If Not Exist "%WindowsImage%" (
  348. Echo [x] Windows Image not found at: "%WindowsImage%" | MORE
  349. Pause&Exit
  350. )
  351.  
  352. :: PackageList File Error-Check.
  353. If Not Exist "%PackageList%" (
  354. Echo [x] PackageList not found at: "%PackageList%" | MORE
  355. Pause&Exit
  356. )
  357.  
  358. :: 'DISM.exe' File Error-Check.
  359. If Not Exist "%DISM%" (
  360. Echo [x] 'DISM' process not found at: "%DISM%" | MORE
  361. Pause&Exit
  362. )
  363.  
  364. :: 'ImageX.exe' File Error-Check.
  365. If Not Exist "%ImageX%" (
  366. Echo [x] 'ImageX' process not found at: "%ImageX%" | MORE
  367. Pause&Exit
  368. )
  369.  
  370. :: 'WIM Registry Tweak Tool.exe' File Error-Check.
  371. If Not Exist "%WIMRegistryTweakTool%" (
  372. Echo [x] 'WIM Registry Tweak Tool' process not found at: "%WIMRegistryTweakTool%" | MORE
  373. Pause&Exit
  374. )
  375.  
  376.  
  377. Goto:EOF


Que lo disfruten! ...e intenten no joder Windows eliminando paquetes esenciales para el SO!





5.7
· Automatizar la desactivación de características

Todo lo necesario está incluido en este archivo comprimido:
http://www.mediafire.com/download/lq4sc56ri59klod/WIM_Feature_Uninstaller.rar


Una imagen de muestra:



Instrucciones:
Deben crear un archivo de texto con el nombre "Features.txt" y añadir los nombres de las características que que quieren deshabilitar, 1 nombre por cada linea.

Ejemplo:
Features.txt
Código:
DirectPlay
FaxServicesClientPackage
Internet-Explorer-Optional-amd64
Microsoft-Windows-MobilePC-LocationProvider-INF
MicrosoftWindowsPowerShellV2
MicrosoftWindowsPowerShellV2Root
Printing-Foundation-InternetPrinting-Client
Printing-XPSServices-Features
WindowsMediaPlayer
Xps-Foundation-Xps-Viewer


Seguídamente deben usar este Script que he desarrollado el cual se encarga de hacer todas las tareas necesarias.

Nota: Deben configurar los valores de las variables que están documentadas en la cabecera del código.

WIM Feature Uninstaller.cmd
Código
  1. @Echo OFF
  2.  
  3.  
  4.  
  5. REM =================
  6. REM Console Settings:
  7. REM =================
  8.  
  9. Title WIM Feature Uninstaller - By Elektro
  10. Mode Con Cols=150 Lines=50
  11. CHCP 1252 1>NUL & REM Windows-1252, Spanish-Latin.
  12.  
  13.  
  14.  
  15. REM =====
  16. REM Info:
  17. REM =====
  18.  
  19. Echo  -----------------------------------------------------------------------------
  20. Echo  This script mounts a Windows Image ^(WIM^) and then disables Windows features
  21. Echo  -----------------------------------------------------------------------------
  22.  
  23.  
  24.  
  25. REM ====================
  26. REM User defined values:
  27. REM ====================
  28.  
  29. REM This value indicates whether the Windows Image should be mounted.
  30. REM True  = 'DISM' will try to mount the 'WIM' image.
  31. REM False = 'DISM' will not try to mount the WIM image.
  32. REM Set this value to 'FALSE' if the 'WIM' image is already mounted in the specified mount directory,
  33. REM Otherwise, keep it as 'TRUE'.
  34. Set "MountImage=True"
  35.  
  36. REM This value indicates whether the Windows Image should be unmounted at the end.
  37. REM True  = 'DISM' will try to unmount the 'WIM' image.
  38. REM False = 'DISM' will not try to unmount the WIM image.
  39. REM Set this value to 'FALSE' if you want to keep the image mounted to make other changes,
  40. REM Otherwise, keep it as 'TRUE'.
  41. Set "UnmountImage=True"
  42.  
  43. REM This value indicates whether the Windows Image should be rebuilt at the end.
  44. REM True  = 'ImageX' will try to rebuild the 'WIM' image.
  45. REM False = 'ImageX' will keep the 'WIM' image as is.
  46. REM Set this value to 'FALSE' if you want to keep the image with normal size to make other changes,
  47. REM Otherwise, keep it as 'TRUE'.
  48. Set "Rebuild=True"
  49.  
  50. REM This value indicates the 'WIM' image to be mounted.
  51. Set "WindowsImage=%UserProfile%\Desktop\win 8 .1\win\sources\install.wim"
  52.  
  53. REM This value indicates the Image Index of the 'WIM' image.
  54. Set "ImageIndex=1"
  55.  
  56. REM This value indicates the directory where to mount the 'WIM' image.
  57. Set "MountDir=%HomeDrive%\WinMount"
  58.  
  59. REM This value indicates the textfile that contains the names of the features to disable.
  60. Set "FeatureList=%CD%\Features.txt"
  61.  
  62. REM This value indicates the ubication of 'ImageX.exe' file.
  63. Set "ImageX=%CD%\Tools\Dism\ImageX.exe"
  64.  
  65. REM This value indicates the ubication of a custom 'DISM.exe' file if needed.
  66. REM Default ubication: "%SystemRoot%\System32\Dism.exe"
  67. Set "Dism=%CD%\Tools\Dism\Dism.exe"
  68.  
  69. REM This value indicates the ubication of the logfile that will record 'DISM' errors.
  70. Set "DismLogfile=%CD%\%~n0 DISM.log"
  71.  
  72. REM This value indicates the logging-level of the 'DISM' process.
  73. REM 1 = Errors only
  74. REM 2 = Errors and warnings
  75. REM 3 = Errors, warnings, and informational
  76. REM 4 = All of the information listed previously, plus debug output
  77. Set /A "DismLogLevel=2"
  78.  
  79. REM This value indicates the ubication of the logfile that will record Main information.
  80. Set "Logfile=%CD%\%~n0.log"
  81.  
  82.  
  83.  
  84. REM =====
  85. REM Main:
  86. REM =====
  87.  
  88. :: Call Methods.
  89. Call :CheckErrors
  90. Call :CreateLogs
  91. Call :CreateMountDir
  92. Call :GetWIMSizeBefore
  93. Call :StartTimer
  94. Call :Mount
  95. CLS
  96. Call :ParseFeatures
  97. CLS
  98. Call :CleanUp
  99. Call :Unmount
  100. Call :Rebuild
  101. Call :StopTimer
  102. Call :GetWIMSizeAfter
  103. Call :EndLog
  104. Pause&Exit
  105.  
  106.  
  107.  
  108. REM ========
  109. REM Methods:
  110. REM ========
  111.  
  112.  
  113. :CreateLogs
  114.  
  115. :: Create the 'DISM' logfile with 'ANSI' encoding,
  116. :: this is necessary to record a non-default 'DISM' loglevel such as '1' or '2'.
  117. Echo+ >"%DismLogfile%"
  118.  
  119.  
  120. :: Create the Main logfile and record starting info on it.
  121. Echo+ >"%Logfile%"
  122. (
  123. Echo   WIM Feature Uninstaller
  124. Echo ===========================
  125. Echo   %DATE% ^| %TIME:~0,-3%
  126. Echo /\/\/\/\/\/\/\/\/\/\/\/\/\/
  127. Echo [i] Mount Image?...: %MountImage%
  128. Echo [i] Unmount Image?.: %UnmountImage%
  129. Echo [i] Windows Image..: %WindowsImage%
  130. Echo [i] Image Index....: %ImageIndex%
  131. Echo [i] Mount Directory: %MountDir%
  132. Echo [i] Dism Path......: %Dism%
  133. Echo [i] Dism Log File..: %DismLogfile%
  134. Echo [i] Dism Log Level.: %DismLogLevel%
  135. Echo [i] Feature List...: %FeatureList%
  136. Echo [i] Log File.......: %Logfile%
  137. Echo ===========================
  138. )>"%Logfile%"
  139.  
  140. :: Display starting log info.
  141. Type "%Logfile%"
  142.  
  143. :: Continue writting log.
  144. (
  145. Echo Feature conflicts:
  146. Echo ==================
  147. )>>"%LogFile%"
  148. Goto:EOF
  149.  
  150.  
  151. :EndLog
  152. (
  153. Echo [i] Done!
  154. Echo [i] WIM Image Size Before.........: %WIMSizeBefore%
  155. Echo [i] WIM Image Size After..........: %WIMSizeAfter%
  156. Echo [i] Features Successfully Disabled: %FeaturesRemovedCount% Packages.
  157. Echo [i] Features Failed To Disable....: %FeaturesFailedCount% Packages.
  158. Echo [i] Features Not Found............: %FeaturesNotFoundCount% Packages.
  159. Echo [i] Elapsed Time..................: %ElapsedTime%
  160. )>>"%LogFile%"
  161.  
  162. :: Display ending information.
  163. CLS
  164. Type "%LogFile%"
  165. Goto:EOF
  166.  
  167.  
  168. :CreateMountDir
  169. :: Create the mount directory.
  170. (
  171. If Not Exist "%MountDir%" If /I "%MountImage%" EQU "True" (
  172. MkDir "%MountDir%" 2>NUL
  173. )
  174. ) || (
  175. Echo [x] Error trying to create the directory "%MountDir%" to mount the Windows Image.
  176. Echo [i] Ensure that you have Admin rights to create the directory.
  177. Echo [i] Ensure that the directory name does not contains illegal characters.
  178. Pause&Exit
  179. )
  180. Goto:EOF
  181.  
  182.  
  183. :Mount
  184. :: Mount the Windows Image into the directory.
  185. Echo [+] Mounting WIM Image...
  186. If /I "%MountImage%" EQU "True" (
  187.  
  188. "%Dism%" /Mount-Image /ImageFile:"%WindowsImage%" /Index:"%ImageIndex%" /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" || (
  189. Echo [x] Error mounting the Image Index "%ImageIndex%" in "%MountDir%"
  190. Echo [i] Ensure that the Image Index exist.
  191. Echo [i] Ensure that you have Admin rights to write inside the directory.
  192. Echo [i] Ensure that the directory is not already mounted.
  193. Echo [i] Ensure that the directory is fully empty.
  194. REM Try to unmount the failed image and discard changes.
  195. If /I "%UnmountImage%" EQU "True" (
  196. Echo [+] Unmounting and discarding changes...
  197. "%Dism%" /Unmount-WIM /Discard /MountDir:"%MountDir%"
  198. )
  199. Pause&Exit
  200. )
  201.  
  202. )
  203. Goto:EOF
  204.  
  205.  
  206. :CleanUp
  207. Echo [+] CleaningUp WIM Image...
  208. "%Dism%" /CleanUp-Image /StartComponentCleanUp /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet
  209. Goto:EOF
  210.  
  211.  
  212. :Unmount
  213. :: Unmount the Windows Image commiting changes.
  214. Echo [+] Unmounting WIM Image...
  215. If /I "%UnmountImage%" EQU "True" (
  216. "%Dism%" /Unmount-WIM /Commit /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%"
  217. )
  218. Goto:EOF
  219.  
  220.  
  221. :Rebuild
  222. If /I "%Rebuild%" EQU "False" (Goto:EOF)
  223.  
  224. Echo [+] Rebuilding WIM image...
  225.  
  226. ("%ImageX%" /Compress Maximum /Export "%WindowsImage%" "*" "%TEMP%\Rebuilt Image.wim" /Check) && (
  227. Del /Q /F "%WindowsImage%" 1>NUL
  228. Move /Y "%TEMP%\Rebuilt Image.wim" "%WindowsImage%" 1>NUL
  229. ) || (
  230. Echo [x] Error rebuilding Image "%WindowsImage%" to "%TEMP%\Rebuilt Image.wim".
  231. )
  232.  
  233. Goto :EOF
  234.  
  235.  
  236. :StartTimer
  237. Set "StartingDate=%Date%"
  238. Set "StarttingTime=%Time:~0,-3%"
  239. Goto :EOF
  240.  
  241.  
  242. :StopTimer
  243. (
  244. Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
  245. Echo WScript.Echo Minutes ^& " Minutes"
  246. )>"%TEMP%\%~n0 MinuteDiff.vbs"
  247.  
  248. For /F "Tokens=*" %%# In (
  249. 'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
  250. ) Do (
  251. Set "ElapsedTime=%%#"
  252. )
  253.  
  254. Goto:EOF
  255.  
  256.  
  257. :WriteConvertBytesScript
  258. If Exist "%TEMP%\%~n0 Convert Bytes.vbs" (Goto:EOF)
  259. (
  260. Echo Suffix = Array^("Bytes", "KB", "MB", "GB", "TB"^)
  261. Echo Function Convert^(Bytes^)
  262. Echo Convert = convert0^(Bytes, 0^)
  263. Echo End Function
  264. Echo Function Convert0^(Bytes, Level^)
  265. Echo If Bytes ^>= 1024 Then
  266. Echo Bytes = Round^(Bytes / 1024, 2^)
  267. Echo Level = Level + 1
  268. Echo Convert0 = Convert0^(Bytes, Level^)
  269. Echo End If
  270. Echo Convert0 = Bytes ^& " " ^& Suffix^(Level^)
  271. Echo End Function
  272. Echo WScript.Echo Convert^(WScript.Arguments^(0^)^)
  273. )>"%TEMP%\%~n0 Convert Bytes.vbs"
  274. Goto:EOF
  275.  
  276.  
  277. :GetWIMSizeBefore
  278. Call :WriteConvertBytesScript
  279. For %%# in ("%WindowsImage%") Do (Set "WIMSizeBefore=%%~z#")
  280. For /F "Tokens=*" %%# In (
  281. 'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeBefore%"'
  282. ) Do (
  283. Set "WIMSizeBefore=%%#"
  284. )
  285. Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
  286. Goto:EOF
  287.  
  288.  
  289. :GetWIMSizeAfter
  290. Call :WriteConvertBytesScript
  291. For %%# in ("%WindowsImage%") Do (Set "WIMSizeAfter=%%~z#")
  292. For /F "Tokens=*" %%# In (
  293. 'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeAfter%"'
  294. ) Do (
  295. Set "WIMSizeAfter=%%#"
  296. )
  297. Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
  298. Goto:EOF
  299.  
  300.  
  301. :ParseFeatures
  302.  
  303. Set /A "FeaturesRemovedCount=0"
  304. Set /A "FeaturesFailedCount=0"
  305. Set /A "FeaturesNotFoundCount=0"
  306.  
  307. :: Disable Features.
  308. For /F "UseBackQ Tokens=* Delims=" %%# In ("%FeatureList%") Do (
  309.  
  310. Echo [+] Disabling Feature: %%~#
  311.  
  312. "%Dism%" /Disable-Feature /FeatureName:"%%~#" /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet 1>NUL
  313.    Call Set /A "ExitCode=%%Errorlevel%%"
  314.  
  315.    (Call Echo "%%ExitCode%%"| Findstr.exe "^\"0\"$" 1>NUL 2>&1) && (
  316.     Call Set /A "FeaturesRemovedCount+=1"
  317.    )
  318.  
  319. (Call Echo "%%ExitCode%%"| Findstr.exe "^\"5\"$" 1>NUL 2>&1) && (
  320. Call Set /A "FeaturesFailedCount+=1"
  321. Echo Failed to disable feature: %%~#>>"%LogFile%"
  322. )
  323.  
  324. (Call Echo "%%ExitCode%%"| Find.exe "-2146498548" 1>NUL 2>&1) && (
  325. Call Set /A "FeaturesNotFoundCount+=1"
  326. Echo Feature is not found.....: %%~#>>"%LogFile%"
  327. )
  328.  
  329. )
  330. Goto:EOF
  331.  
  332.  
  333.  
  334. REM ====================
  335. REM File Error Controls:
  336. REM ====================
  337.  
  338. :CheckErrors
  339.  
  340. :: WIM File Error-Check.
  341. If /I "MountImage" EQU "True" If Not Exist "%WindowsImage%" (
  342. Echo [x] Windows Image not found at: "%WindowsImage%" | MORE
  343. Pause&Exit
  344. )
  345.  
  346. :: FeatureList File Error-Check.
  347. If Not Exist "%FeatureList%" (
  348. Echo [x] FeatureList not found at: "%FeatureList%" | MORE
  349. Pause&Exit
  350. )
  351.  
  352. :: 'DISM.exe' File Error-Check.
  353. If Not Exist "%DISM%" (
  354. Echo [x] 'DISM' process not found at: "%DISM%" | MORE
  355. Pause&Exit
  356. )
  357.  
  358. :: 'ImageX.exe' File Error-Check.
  359. If Not Exist "%ImageX%" (
  360. Echo [x] 'ImageX' process not found at: "%ImageX%" | MORE
  361. Pause&Exit
  362. )
  363.  
  364. Goto:EOF


« Última modificación: 12 Abril 2014, 23:22 pm por Eleкtro » En línea


dato000


Desconectado Desconectado

Mensajes: 3.034



Ver Perfil
Re: Guía de personalización de imágenes de implementación de Windows (WIM) (Parte 5)
« Respuesta #1 en: 25 Mayo 2014, 03:29 am »

Caramba!! Sensacionales los dos scripts, fucking A!!!

Sin embargo aún no conozco a fondo los registros y caracteristicas de windows así que realmente no se cuales deberia quitar/remover/eliminar/borrar/desactivar/deshabiltar

Supongo que me tomare mi tiempo analizando lo bueno y lo malo, sin embargo, necesito hacer doble tarea, pues ya va siendo hora de actualizar un equipo, creo que le pondre windows 8.1, a lo que viene mi duda, no hay diferencia entre todas estas tareas para windows 8 y windows 8.1?? parece que tanto para windows 7-8-8.1 todo trabaja de una manera similar, pero siempre existen ligeras diferencias.

Ya esto leyendo el enlace, aunque es para windows 8 http://technet.microsoft.com/en-us/library/dn328991.aspx, el de windows 7 es: http://technet.microsoft.com/en-us/library/ff716257.aspx

Editado: Pues ummm mirando las caracteristicas, honestamente no se que deshabilitar, y mucho menos eliminar, además por el hecho de que este tipo de cosas pueden activarse/desactivarse a medida que se vayan necesitando, aunque yo veo muy necesario el uso de IIS, supongo que no es totalmente imperativo para todas las personas, pero aún así activar todos lo servicios relacionados con IIS es algo exagerado, por lo que debo continuar con el analisis, y otra cosa que queria decir es que me sorprende mucho el hecho de que en windows 7 venga solo el framwork .NET 3.0, pensaba que al menos traia el 3.5, pero veo que no es así, fue una gran sorpresa para mi por el hecho de que realmente es muy importante tener un pc actualizado para el uso de las herramientas estandar en un software de windows, esta es una de las causas, bueno, tal vez para muchos no sea la gran cosa, pero para mi fue toda una revelación.

Aguante Elektro, genial este tuto también!!!!


« Última modificación: 27 Mayo 2014, 02:56 am por dato000 » En línea


Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines