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


Tema destacado: Rompecabezas de Bitcoin, Medio millón USD en premios


  Mostrar Mensajes
Páginas: 1 ... 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 [731] 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 ... 1254
7301  Programación / .NET (C#, VB.NET, ASP) / Re: timer + webbrowser en vb.net en: 14 Abril 2014, 12:32 pm
Para esta y el resto de preguntas sencillas que se deberían aprender leyendo lo básico, MSDN.

· WebBrowser Class > WebBrowser Methods
· Timer Class > Timer Methods

Saludos!
7302  Programación / Scripting / [APORTE] [BATCH] WIM Resource Replacer en: 14 Abril 2014, 05:51 am
Este Script sirve para automatizar la tarea de montar una imagen WIM de Windows y reemplazar recursos de imágenes (bmp/ico) en las librerías de recursos de la instalación de Windows, así como también sirve para reemplazar archivos.

Ejemplo de los recursos a los que me refiero:



Se necesitan unos requisitos y dependencias para usar este Script:
· Saber de lo que estoy hablando.
· Conocer el nombre de los recursos que quieres reemplazar y disponer de tus imágenes ya modificados (obviamente).
· Dism e ImageX (WAIK/WADK).
· Anolis Resourcer > http://www.anol.is/resourcer/


Las instrucciones de uso y un extenso tutorial lo publiqué en este otro tema: http://foro.elhacker.net/windows/guia_de_personalizacion_de_imagenes_de_implementacion_de_windows_wim_parte_4-t412468.0.html así que lo haré de nuevo de manera resumida: solo tienen que escribir en un archivo de texto delimitando por puntoycomas los recursos que quieren reemplazar, el nombre del recurso y el índice, así como los archivos que quieran reemplazar, y configurar las variables documentadas del Script (La ubicación de la imagen, el directorio de montaje, etc...)

Nota: Ver el ejemplo del archivo delimitado dentro del enlace de abajo o en las instrucciones extendidas del enlace de arriba.

Todo lo necesario está incluido en este archivo comprimido:
http://www.mediafire.com/download/ktzms7i09qt4n2b/wim+resource+replacer+0.2.rar

Imágenes:


(Código corregido, el otro que subí estaba incompleto)
WIM Resource Replacer.cmd
Código
  1. @Echo OFF
  2.  
  3.  
  4.  
  5. REM =================
  6. REM Console Settings:
  7. REM =================
  8.  
  9. Title WIM Resource Replacer - 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 replaces image resources inside resource files
  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 whether the Windows Image should be cleaned-up at the end.
  51. REM True  = 'Dism' will try to CleanUp the 'WIM' image components.
  52. REM False = 'Dism' will keep the 'WIM' image as is.
  53. REM Set this value to 'FALSE' if you want to keep the image with normal size to make other changes,
  54. REM Otherwise, keep it as 'TRUE'.
  55. Set "CleanUp=True"
  56.  
  57. REM This value indicates the 'WIM' image to be mounted.
  58. Set "WindowsImage=%UserProfile%\Desktop\win 8 .1\win\sources\Boot.wim"
  59.  
  60. REM This value indicates the Image Index of the 'WIM' image.
  61. Set "ImageIndex=2"
  62.  
  63. REM This value indicates the directory where to mount the 'WIM' image.
  64. Set "MountDir=%HomeDrive%\WinBootMount"
  65.  
  66. REM This value indicates the ubication of Anolis Resourcer 'Anolis.exe' file.
  67. Set "Anolis=%CD%\Tools\Anolis.exe"
  68.  
  69. REM This value indicates the textfile that contains the Recource files to replace.
  70. Set "ResourceList=%CD%\Resources.txt"
  71.  
  72. REM This value indicates the ubication of 'ImageX.exe' file.
  73. Set "ImageX=%CD%\Tools\Dism\ImageX.exe"
  74.  
  75. REM This value indicates the ubication of a custom 'DISM.exe' file if needed.
  76. REM Default ubication: "%SystemRoot%\System32\Dism.exe"
  77. Set "Dism=%CD%\Tools\Dism\Dism.exe"
  78.  
  79. REM This value indicates the ubication of the logfile that will record 'DISM' errors.
  80. Set "DismLogfile=%CD%\%~n0 DISM.log"
  81.  
  82. REM This value indicates the logging-level of the 'DISM' process.
  83. REM 1 = Errors only
  84. REM 2 = Errors and warnings
  85. REM 3 = Errors, warnings, and informational
  86. REM 4 = All of the information listed previously, plus debug output
  87. Set /A "DismLogLevel=2"
  88.  
  89. REM This value indicates the ubication of the logfile that will record Main information.
  90. Set "Logfile=%CD%\%~n0.log"
  91.  
  92.  
  93.  
  94. REM =====
  95. REM Main:
  96. REM =====
  97.  
  98. :: Call Methods.
  99. Call :CheckErrors
  100. Call :CreateLogs
  101. Call :CreateMountDir
  102. Call :GetWIMSizeBefore
  103. Call :StartTimer
  104. Call :Mount
  105. CLS
  106. Call :ParseResources
  107. Call :Unmount
  108. Call :StopTimer
  109. Call :GetWIMSizeAfter
  110. Call :EndLog
  111. Pause&Exit
  112.  
  113.  
  114.  
  115. REM ========
  116. REM Methods:
  117. REM ========
  118.  
  119. :CreateLogs
  120. :: Create the 'DISM' logfile with 'ANSI' encoding,
  121. :: this is necessary to record a non-default 'DISM' loglevel such as '1' or '2'.
  122. Echo+ >"%Logfile%"
  123.  
  124. :: Create the Main Logfile and record starting info on it.
  125. (
  126. Echo    WIM Resource Replacer
  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] CleanUp Image?.: %CleanUp%
  133. Echo [i] Rebuild Image?.: %Rebuild%
  134. Echo [i] Windows Image..: %WindowsImage%
  135. Echo [i] Image Index....: %ImageIndex%
  136. Echo [i] Mount Directory: %MountDir%
  137. Echo [i] ImageX Path....: %ImageX%
  138. Echo [i] Dism Path......: %Dism%
  139. Echo [i] Dism Log File..: %DismLogfile%
  140. Echo [i] Dism Log Level.: %DismLogLevel%
  141. Echo [i] Anolis Path....: %Anolis%
  142. Echo [i] Resource List..: %ResourceList%
  143. Echo [i] Log File.......: %LogFile%
  144. Echo ===========================
  145. )>"%Logfile%"
  146.  
  147. :: Display starting log info.
  148. Type "%Logfile%"
  149.  
  150. :: Continue writting log.
  151. (
  152. Echo Resource conflicts:
  153. Echo ===================
  154. )>>"%LogFile%"
  155.  
  156. Goto:EOF
  157.  
  158.  
  159. :EndLog
  160. (
  161. Echo [i] Done!
  162. Echo [i] WIM Size Before....: %WIMSizeBefore%
  163. Echo [i] WIM Size After.....: %WIMSizeAfter%
  164. Echo [i] Resources Success..: %ResourceSuccessCount% files.
  165. Echo [i] Resources Failed...: %ResourceFailsCount% files.
  166. Echo [i] Resources Not Found: %ResourceNotFoundCount% files.
  167. Echo [i] Files Added........: %FilesAddedCount% files.
  168. Echo [i] Files Failed.......: %FilesFailsCount% files.
  169. Echo [i] Files Not Found....: %FilesNotFoundCount% files.
  170. Echo [i] Elapsed Time.......: %ElapsedTime%
  171. )>>"%LogFile%"
  172.  
  173. :: Display ending information.
  174. CLS
  175. Type "%LogFile%"
  176. Goto:EOF
  177.  
  178.  
  179. :CreateMountDir
  180. :: Create the mount directory.
  181. (
  182. If Not Exist "%MountDir%" If /I "%MountImage%" EQU "True" (
  183. MkDir "%MountDir%" 2>NUL
  184. )
  185. ) || (
  186. Echo [x] Error trying to create the directory "%MountDir%" to mount the Windows Image.
  187. Echo [i] Ensure that you have Admin rights to create the directory.
  188. Echo [i] Ensure that the directory name does not contains illegal characters.
  189. Pause&Exit
  190. )
  191. Goto:EOF
  192.  
  193.  
  194. :Mount
  195. :: Mount the Windows Image into the directory.
  196. Echo [+] Mounting WIM Image...
  197. If /I "%MountImage%" EQU "True" (
  198.  
  199. "%Dism%" /Mount-Image /ImageFile:"%WindowsImage%" /Index:"%ImageIndex%" /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" || (
  200. Echo [x] Error mounting the Image Index "%ImageIndex%" in "%MountDir%"
  201. Echo [i] Ensure that the Image Index exist.
  202. Echo [i] Ensure that you have Admin rights to write inside the directory.
  203. Echo [i] Ensure that the directory is not already mounted.
  204. Echo [i] Ensure that the directory is fully empty.
  205. REM Try to unmount the failed image and discard changes.
  206. If /I "%UnmountImage%" EQU "True" (
  207. Echo [+] Unmounting and discarding changes...
  208. "%Dism%" /Unmount-WIM /Discard /MountDir:"%MountDir%"
  209. )
  210. Pause&Exit
  211. )
  212.  
  213. )
  214. Goto:EOF
  215.  
  216.  
  217. :CleanUp
  218. Echo [+] CleaningUp WIM Image...
  219. "%Dism%" /CleanUp-Image /StartComponentCleanUp /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet
  220. Goto:EOF
  221.  
  222.  
  223. :Unmount
  224. :: Unmount the Windows Image commiting changes.
  225. Echo [+] Unmounting WIM Image...
  226. If /I "%UnmountImage%" EQU "True" (
  227. "%Dism%" /Unmount-WIM /Commit /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%"
  228. )
  229. Goto:EOF
  230.  
  231.  
  232. :Rebuild
  233. If /I "%Rebuild%" EQU "False" (Goto:EOF)
  234.  
  235. Echo [+] Rebuilding WIM image...
  236.  
  237. ("%ImageX%" /Compress Maximum /Export "%WindowsImage%" "*" "%TEMP%\Rebuilt Image.wim" /Check) && (
  238. Del /Q /F "%WindowsImage%" 1>NUL
  239. Move /Y "%TEMP%\Rebuilt Image.wim" "%WindowsImage%" 1>NUL
  240. ) || (
  241. Echo [x] Error rebuilding Image "%WindowsImage%" to "%TEMP%\Rebuilt Image.wim".
  242. )
  243.  
  244. Goto :EOF
  245.  
  246.  
  247. :StartTimer
  248. Set "StartingDate=%Date%"
  249. Set "StarttingTime=%Time:~0,-3%"
  250. Goto :EOF
  251.  
  252.  
  253. :StopTimer
  254. (
  255. Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
  256. Echo WScript.Echo Minutes ^& " Minutes"
  257. )>"%TEMP%\%~n0 MinuteDiff.vbs"
  258.  
  259. For /F "Tokens=*" %%# In (
  260. 'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
  261. ) Do (
  262. Set "ElapsedTime=%%#"
  263. )
  264.  
  265. Goto:EOF
  266.  
  267.  
  268. :WriteConvertBytesScript
  269. If Exist "%TEMP%\%~n0 Convert Bytes.vbs" (Goto:EOF)
  270. (
  271. Echo Suffix = Array^("Bytes", "KB", "MB", "GB", "TB"^)
  272. Echo Function Convert^(Bytes^)
  273. Echo Convert = convert0^(Bytes, 0^)
  274. Echo End Function
  275. Echo Function Convert0^(Bytes, Level^)
  276. Echo If Bytes ^>= 1024 Then
  277. Echo Bytes = Round^(Bytes / 1024, 2^)
  278. Echo Level = Level + 1
  279. Echo Convert0 = Convert0^(Bytes, Level^)
  280. Echo End If
  281. Echo Convert0 = Bytes ^& " " ^& Suffix^(Level^)
  282. Echo End Function
  283. Echo WScript.Echo Convert^(WScript.Arguments^(0^)^)
  284. )>"%TEMP%\%~n0 Convert Bytes.vbs"
  285. Goto:EOF
  286.  
  287.  
  288. :GetWIMSizeBefore
  289. Call :WriteConvertBytesScript
  290. For %%# in ("%WindowsImage%") Do (Set "WIMSizeBefore=%%~z#")
  291. For /F "Tokens=*" %%# In (
  292. 'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeBefore%"'
  293. ) Do (
  294. Set "WIMSizeBefore=%%#"
  295. )
  296. Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
  297. Goto:EOF
  298.  
  299.  
  300. :GetWIMSizeAfter
  301. Call :WriteConvertBytesScript
  302. For %%# in ("%WindowsImage%") Do (Set "WIMSizeAfter=%%~z#")
  303. For /F "Tokens=*" %%# In (
  304. 'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeAfter%"'
  305. ) Do (
  306. Set "WIMSizeAfter=%%#"
  307. )
  308. Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
  309. Goto:EOF
  310.  
  311.  
  312. :TakeOwn
  313. (
  314. Takeown.exe /F "%~f1"
  315. ICacls.exe "%~f1" /Grant "%UserName%":"F"
  316. Attrib.exe -R -A -S -H -I "%~f1"
  317. )>NUL || (Exit /B 1)
  318. Goto:EOF
  319.  
  320.  
  321. :ParseResources
  322. Set /A "ResourceSuccessCount=0"
  323. Set /A "ResourceFailsCount=0"
  324. Set /A "ResourceNotFoundCount=0"
  325. Set /A "FilesAddedCount=0"
  326. Set /A "FilesFailsCount=0"
  327. Set /A "FilesNotFoundCount=0"
  328.  
  329. For /F "UseBackQ Tokens=1,2,* Delims=;" %%a In ("%ResourceList%") Do (
  330.  
  331. If /I "%%~xa" EQU ".dll" (Call :ReplaceResource "%MountDir%\%%~a" "%%~b" "%%~c")
  332. If /I "%%~xa" NEQ ".dll" (Call :CopyFile        "%MountDir%\%%~a" "%%~b")
  333.  
  334. )
  335. Goto:EOF
  336.  
  337.  
  338. :CopyFile
  339. If Not Exist "%~2" (
  340. Echo Can't locate file to copy from: "%~2">>"%LogFile%"
  341. Set /A "FilesNotFoundCount+=1"
  342. Goto:EOF
  343. )
  344.  
  345. Call :TakeOwn "%~f1" || (
  346. Echo Unable to grant file permissions in file: "%~1">>"%Logfile%"
  347. Set /A "FilesFailsCount+=1"
  348. Goto:EOF
  349. )
  350.  
  351. Echo [o] Copying "%~2" to "%~1"
  352. Copy /Y "%~f2" "%~f1" 1>NUL || (
  353. Echo Unable to copy file "%~2">>"%Logfile%"
  354. Set /A "FilesFailsCount+=1"
  355. Goto:EOF
  356. )
  357. Set /A "FilesAddedCount+=1"
  358. Goto:EOF
  359.  
  360.  
  361. :ReplaceResource
  362. If Not Exist "%~f3" (
  363. Echo Can't locate the resource to copy from: "%~3">>"%LogFile%"
  364. Set /A "ResourceNotFoundCount+=1"
  365. Goto:EOF
  366. )
  367.  
  368. If Not Exist "%~f1" (
  369. Echo Can't locate the resource file to edit "%~1">>"%Logfile%"
  370. Set /A "ResourceNotFoundCount+=1"
  371. Goto:EOF
  372. )
  373.  
  374. Call :TakeOwn "%~f1" || (
  375. Echo Unable to grant file permissions in file: "%~1">>"%Logfile%"
  376. Set /A "ResourceFailsCount+=1"
  377. Goto:EOF
  378. )
  379.  
  380. Echo [o] Replacing resource with name "%~2" in resource file "%~f1", with "%~3".
  381.  
  382. If /I "%~x3" EQU ".bmp" (
  383. Start /W "Anolis" "%Anolis%" -op:upd -src:"%~f1" -type:Bitmap -name:"%~2" -lang:1033 -file:"%~f3")
  384. )
  385. If /I "%~x3" EQU ".ico" (
  386. Start /W "Anolis" "%Anolis%" -op:upd -src:"%~f1" -type:Icon -name:"%~2" -lang:1033 -file:"%~f3")
  387. )
  388. Set /A "ResourceSuccessCount+=1"
  389. Goto:EOF
  390.  
  391.  
  392.  
  393. REM ====================
  394. REM File Error Controls:
  395. REM ====================
  396.  
  397. :CheckErrors
  398. :: WIM File Error-Check.
  399. If /I "MountImage" EQU "True" If Not Exist "%WindowsImage%" (
  400. Echo [x] Windows Image not found at: "%WindowsImage%" | MORE
  401. Pause&Exit
  402. )
  403.  
  404. :: ResourceList File Error-Check.
  405. If Not Exist "%ResourceList%" (
  406. Echo [x] Resource-List file not found in: "%ResourceList%" | MORE
  407. Pause&Exit
  408. )
  409.  
  410. :: 'DISM.exe' File Error-Check.
  411. If Not Exist "%DISM%" (
  412. Echo [x] 'DISM' process not found at: "%DISM%" | MORE
  413. Pause&Exit
  414. )
  415.  
  416. :: 'ImageX.exe' File Error-Check.
  417. If Not Exist "%ImageX%" (
  418. Echo [x] 'ImageX' process not found at: "%ImageX%" | MORE
  419. Pause&Exit
  420. )
  421.  
  422. :: 'MountImage' Value check.
  423. If /I "%MountImage%" NEQ "True" If /I "%MountImage%" NEQ "False" (
  424. Echo [x] Error parsing parameter 'MountImage',
  425. Echo     value '%MountImage%' is not a Boolean value.
  426. Pause&Exit
  427. )
  428.  
  429. :: 'UnmountImage' Value check.
  430. If /I "%UnmountImage%" NEQ "True" If /I "%UnmountImage%" NEQ "False" (
  431. Echo [x] Error parsing parameter 'UnmountImage',
  432. Echo     value '%UnmountImage%' is not a Boolean value.
  433. Pause&Exit
  434. )
  435.  
  436. :: 'Rebuild' Value check.
  437. If /I "%Rebuild%" NEQ "True" If /I "%Rebuild%" NEQ "False" (
  438. Echo [x] Error parsing parameter 'Rebuild',
  439. Echo     value '%Rebuild%' is not a Boolean value.
  440. Pause&Exit
  441. )
  442.  
  443. :: 'CleanUp' Value check.
  444. If /I "%CleanUp%" NEQ "True" If /I "%CleanUp%" NEQ "False" (
  445. Echo [x] Error parsing parameter 'CleanUp',
  446. Echo     value '%CleanUp%' is not a Boolean value.
  447. Pause&Exit
  448. )
  449.  
  450. :: 'DismLogLevel' Value check.
  451. Echo "%DismLogLevel%"| Findstr.exe "^\"[^1-4]\"$" 1>NUL 2>&1 || (
  452. Echo [x] Error parsing parameter 'DismLogLevel',
  453. Echo     value '%DismLogLevel%' is not in range '1-4'.
  454. Pause&Exit
  455. )
  456.  
  457. :: Anolis Resourcer File Error-Check.
  458. If Not Exist "%Anolis%" (
  459. Echo [x] Anolis process not found in: "%Anolis%" | MORE
  460. Pause&Exit
  461. )
  462.  
  463. Goto:EOF
7303  Programación / Scripting / [APORTE] [BATCH] WIM Package Uninstaller en: 14 Abril 2014, 05:50 am
Este Script sirve para automatizar la tarea de montar una imagen WIM de Windows y eliminar paquetes de la instalación de Windows.

Se necesitan unos requisitos y dependencias para usar este Script:
· Saber de lo que estoy hablando.
· Conocer el nombre de los paquetes que quieres elimiar (obviamente).
· Dism e ImageX (WAIK/WADK).
· win6x_registry_tweak > http://www.msfn.org/board/topic/152688-win6x-registry-tweak/


Las instrucciones de uso y un extenso tutorial lo publiqué en este otro tema: http://foro.elhacker.net/windows/guia_de_personalizacion_de_imagenes_de_implementacion_de_windows_wim_parte_5-t412551.0.html así que lo haré de nuevo de manera resumida: solo tienen que escribir en un archivo de texto los paquetes que quieren eliminar, y configurar las variables documentadas del Script (La ubicación de la imagen, el directorio de montaje, etc...)


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

Imágenes:



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] WIMRegistryTool: %WIMRegistryTweakTool%
  140. Echo [i] Package List...: %PackageList%
  141. Echo [i] Log File.......: %Logfile%
  142. Echo ===========================
  143. )>"%Logfile%"
  144.  
  145. :: Display starting log info.
  146. Type "%Logfile%"
  147.  
  148. :: Continue writting log.
  149. (
  150. Echo Package conflicts:
  151. Echo ==================
  152. )>>"%LogFile%"
  153. Goto:EOF
  154.  
  155.  
  156. :EndLog
  157. (
  158. Echo [i] Done!
  159. Echo [i] WIM Image Size Before........: %WIMSizeBefore%
  160. Echo [i] WIM Image Size After.........: %WIMSizeAfter%
  161. Echo [i] Packages Successfully Removed: %PackagesRemovedCount% Packages.
  162. Echo [i] Packages Failed To Remove....: %PackagesFailedCount% Packages.
  163. Echo [i] Packages Not Found...........: %PackagesNotFoundCount% Packages.
  164. Echo [i] Elapsed Time.................: %ElapsedTime%
  165. )>>"%LogFile%"
  166.  
  167. :: Display ending information.
  168. CLS
  169. Type "%LogFile%"
  170. Goto:EOF
  171.  
  172.  
  173. :CreateMountDir
  174. :: Create the mount directory.
  175. (
  176. If Not Exist "%MountDir%" If /I "%MountImage%" EQU "True" (
  177. MkDir "%MountDir%" 2>NUL
  178. )
  179. ) || (
  180. Echo [x] Error trying to create the directory "%MountDir%" to mount the Windows Image.
  181. Echo [i] Ensure that you have Admin rights to create the directory.
  182. Echo [i] Ensure that the directory name does not contains illegal characters.
  183. Pause&Exit
  184. )
  185. Goto:EOF
  186.  
  187.  
  188. :Mount
  189. :: Mount the Windows Image into the directory.
  190. Echo [+] Mounting WIM Image...
  191. If /I "%MountImage%" EQU "True" (
  192.  
  193. "%Dism%" /Mount-Image /ImageFile:"%WindowsImage%" /Index:"%ImageIndex%" /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" || (
  194. Echo [x] Error mounting the Image Index "%ImageIndex%" in "%MountDir%"
  195. Echo [i] Ensure that the Image Index exist.
  196. Echo [i] Ensure that you have Admin rights to write inside the directory.
  197. Echo [i] Ensure that the directory is not already mounted.
  198. Echo [i] Ensure that the directory is fully empty.
  199. REM Try to unmount the failed image and discard changes.
  200. If /I "%UnmountImage%" EQU "True" (
  201. Echo [+] Unmounting and discarding changes...
  202. "%Dism%" /Unmount-WIM /Discard /MountDir:"%MountDir%"
  203. )
  204. Pause&Exit
  205. )
  206.  
  207. )
  208. Goto:EOF
  209.  
  210.  
  211. :CleanUp
  212. Echo [+] CleaningUp WIM Image...
  213. "%Dism%" /CleanUp-Image /StartComponentCleanUp /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet
  214. Goto:EOF
  215.  
  216.  
  217. :Unmount
  218. :: Unmount the Windows Image commiting changes.
  219. Echo [+] Unmounting WIM Image...
  220. If /I "%UnmountImage%" EQU "True" (
  221. "%Dism%" /Unmount-WIM /Commit /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%"
  222. )
  223. Goto:EOF
  224.  
  225.  
  226. :Rebuild
  227. If /I "%Rebuild%" EQU "False" (Goto:EOF)
  228.  
  229. Echo [+] Rebuilding WIM image...
  230.  
  231. ("%ImageX%" /Compress Maximum /Export "%WindowsImage%" "*" "%TEMP%\Rebuilt Image.wim" /Check) && (
  232. Del /Q /F "%WindowsImage%" 1>NUL
  233. Move /Y "%TEMP%\Rebuilt Image.wim" "%WindowsImage%" 1>NUL
  234. ) || (
  235. Echo [x] Error rebuilding Image "%WindowsImage%" to "%TEMP%\Rebuilt Image.wim".
  236. )
  237.  
  238. Goto :EOF
  239.  
  240.  
  241. :StartTimer
  242. Set "StartingDate=%Date%"
  243. Set "StarttingTime=%Time:~0,-3%"
  244. Goto :EOF
  245.  
  246.  
  247. :StopTimer
  248. (
  249. Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
  250. Echo WScript.Echo Minutes ^& " Minutes"
  251. )>"%TEMP%\%~n0 MinuteDiff.vbs"
  252.  
  253. For /F "Tokens=*" %%# In (
  254. 'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
  255. ) Do (
  256. Set "ElapsedTime=%%#"
  257. )
  258.  
  259. Goto:EOF
  260.  
  261.  
  262. :WriteConvertBytesScript
  263. If Exist "%TEMP%\%~n0 Convert Bytes.vbs" (Goto:EOF)
  264. (
  265. Echo Suffix = Array^("Bytes", "KB", "MB", "GB", "TB"^)
  266. Echo Function Convert^(Bytes^)
  267. Echo Convert = convert0^(Bytes, 0^)
  268. Echo End Function
  269. Echo Function Convert0^(Bytes, Level^)
  270. Echo If Bytes ^>= 1024 Then
  271. Echo Bytes = Round^(Bytes / 1024, 2^)
  272. Echo Level = Level + 1
  273. Echo Convert0 = Convert0^(Bytes, Level^)
  274. Echo End If
  275. Echo Convert0 = Bytes ^& " " ^& Suffix^(Level^)
  276. Echo End Function
  277. Echo WScript.Echo Convert^(WScript.Arguments^(0^)^)
  278. )>"%TEMP%\%~n0 Convert Bytes.vbs"
  279. Goto:EOF
  280.  
  281.  
  282. :GetWIMSizeBefore
  283. Call :WriteConvertBytesScript
  284. For %%# in ("%WindowsImage%") Do (Set "WIMSizeBefore=%%~z#")
  285. For /F "Tokens=*" %%# In (
  286. 'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeBefore%"'
  287. ) Do (
  288. Set "WIMSizeBefore=%%#"
  289. )
  290. Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
  291. Goto:EOF
  292.  
  293.  
  294. :GetWIMSizeAfter
  295. Call :WriteConvertBytesScript
  296. For %%# in ("%WindowsImage%") Do (Set "WIMSizeAfter=%%~z#")
  297. For /F "Tokens=*" %%# In (
  298. 'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeAfter%"'
  299. ) Do (
  300. Set "WIMSizeAfter=%%#"
  301. )
  302. Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
  303. Goto:EOF
  304.  
  305.  
  306. :ParsePackages
  307.  
  308. Set /A "PackagesRemovedCount=0"
  309. Set /A "PackagesFailedCount=0"
  310. Set /A "PackagesNotFoundCount=0"
  311.  
  312. :: Unhide packages and take registry ownership.
  313. "%WIMRegistryTweakTool%" /p "%MountDir%"
  314.  
  315. :: Remove Packages.
  316. For /F "UseBackQ Tokens=* Delims=" %%# In ("%PackageList%") Do (
  317.  
  318. Echo [+] Removing package: %%~#
  319.  
  320. "%Dism%" /Remove-Package /PackageName:"%%~#" /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet 1>NUL
  321.    Call Set /A "ExitCode=%%Errorlevel%%"
  322.  
  323.    (Call Echo "%%ExitCode%%"| Findstr.exe "^\"0\"$" 1>NUL 2>&1) && (
  324.     Call Set /A "PackagesRemovedCount+=1"
  325.    )
  326.  
  327. (Call Echo "%%ExitCode%%"| Findstr.exe "^\"5\"$" 1>NUL 2>&1) && (
  328. Call Set /A "PackagesFailedCount+=1"
  329. Echo Failed to remove package: %%~#>>"%LogFile%"
  330. )
  331.  
  332. (Call Echo "%%ExitCode%%"| Find.exe "-2146498555" 1>NUL 2>&1) && (
  333. Call Set /A "PackagesNotFoundCount+=1"
  334. Echo Package is not installed: %%~#>>"%LogFile%"
  335. )
  336.  
  337. )
  338. Goto:EOF
  339.  
  340.  
  341.  
  342. REM ===============
  343. REM Error Controls:
  344. REM ===============
  345.  
  346. :CheckErrors
  347. :: WIM File Error-Check.
  348. If /I "MountImage" EQU "True" If Not Exist "%WindowsImage%" (
  349. Echo [x] Windows Image not found at: "%WindowsImage%" | MORE
  350. Pause&Exit
  351. )
  352.  
  353. :: PackageList File Error-Check.
  354. If Not Exist "%PackageList%" (
  355. Echo [x] PackageList not found at: "%PackageList%" | MORE
  356. Pause&Exit
  357. )
  358.  
  359. :: 'DISM.exe' File Error-Check.
  360. If Not Exist "%DISM%" (
  361. Echo [x] 'DISM' process not found at: "%DISM%" | MORE
  362. Pause&Exit
  363. )
  364.  
  365. :: 'ImageX.exe' File Error-Check.
  366. If Not Exist "%ImageX%" (
  367. Echo [x] 'ImageX' process not found at: "%ImageX%" | MORE
  368. Pause&Exit
  369. )
  370.  
  371. :: 'WIM Registry Tweak Tool.exe' File Error-Check.
  372. If Not Exist "%WIMRegistryTweakTool%" (
  373. Echo [x] 'WIM Registry Tweak Tool' process not found at: "%WIMRegistryTweakTool%" | MORE
  374. Pause&Exit
  375. )
  376.  
  377. :: 'MountImage' Value check.
  378. If /I "%MountImage%" NEQ "True" If /I "%MountImage%" NEQ "False" (
  379. Echo [x] Error parsing parameter 'MountImage',
  380. Echo     value '%MountImage%' is not a Boolean value.
  381. Pause&Exit
  382. )
  383.  
  384. :: 'UnmountImage' Value check.
  385. If /I "%UnmountImage%" NEQ "True" If /I "%UnmountImage%" NEQ "False" (
  386. Echo [x] Error parsing parameter 'UnmountImage',
  387. Echo     value '%UnmountImage%' is not a Boolean value.
  388. Pause&Exit
  389. )
  390.  
  391. :: 'Rebuild' Value check.
  392. If /I "%Rebuild%" NEQ "True" If /I "%Rebuild%" NEQ "False" (
  393. Echo [x] Error parsing parameter 'Rebuild',
  394. Echo     value '%Rebuild%' is not a Boolean value.
  395. Pause&Exit
  396. )
  397.  
  398. :: 'DismLogLevel' Value check.
  399. Echo "%DismLogLevel%"| Findstr.exe "^\"[^1-4]\"$" 1>NUL 2>&1 || (
  400. Echo [x] Error parsing parameter 'DismLogLevel',
  401. Echo     value '%DismLogLevel%' is not in range '1-4'.
  402. Pause&Exit
  403. )
  404.  
  405. Goto:EOF
7304  Programación / Scripting / [APORTE] [BATCH] WIM Feature Uninstaller en: 14 Abril 2014, 05:49 am
Este Script sirve para automatizar la tarea de montar una imagen WIM de Windows y desactivar características de la instalación de Windows.

Se necesitan unos requisitos y dependencias para usar este Script:
· Saber de lo que estoy hablando.
· Conocer el nombre de las características que quieres elimiar (obviamente).
· Dism e ImageX (WAIK/WADK).


Las instrucciones de uso y un extenso tutorial lo publiqué en este otro tema: http://foro.elhacker.net/windows/guia_de_personalizacion_de_imagenes_de_implementacion_de_windows_wim_parte_5-t412551.0.html así que lo haré de nuevo de manera resumida: solo tienen que escribir en un archivo de texto el nombre de las características que quieren desactivar, y configurar las variables documentadas del Script (La ubicación de la imagen, el directorio de montaje, etc...)


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


Imágenes:



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] ImageX Path....: %ImageX%
  133. Echo [i] Dism Path......: %Dism%
  134. Echo [i] Dism Log File..: %DismLogfile%
  135. Echo [i] Dism Log Level.: %DismLogLevel%
  136. Echo [i] Feature List...: %FeatureList%
  137. Echo [i] Log File.......: %Logfile%
  138. Echo ===========================
  139. )>"%Logfile%"
  140.  
  141. :: Display starting log info.
  142. Type "%Logfile%"
  143.  
  144. :: Continue writting log.
  145. (
  146. Echo Feature conflicts:
  147. Echo ==================
  148. )>>"%LogFile%"
  149. Goto:EOF
  150.  
  151.  
  152. :EndLog
  153. (
  154. Echo [i] Done!
  155. Echo [i] WIM Image Size Before.........: %WIMSizeBefore%
  156. Echo [i] WIM Image Size After..........: %WIMSizeAfter%
  157. Echo [i] Features Successfully Disabled: %FeaturesRemovedCount% Packages.
  158. Echo [i] Features Failed To Disable....: %FeaturesFailedCount% Packages.
  159. Echo [i] Features Not Found............: %FeaturesNotFoundCount% Packages.
  160. Echo [i] Elapsed Time..................: %ElapsedTime%
  161. )>>"%LogFile%"
  162.  
  163. :: Display ending information.
  164. CLS
  165. Type "%LogFile%"
  166. Goto:EOF
  167.  
  168.  
  169. :CreateMountDir
  170. :: Create the mount directory.
  171. (
  172. If Not Exist "%MountDir%" If /I "%MountImage%" EQU "True" (
  173. MkDir "%MountDir%" 2>NUL
  174. )
  175. ) || (
  176. Echo [x] Error trying to create the directory "%MountDir%" to mount the Windows Image.
  177. Echo [i] Ensure that you have Admin rights to create the directory.
  178. Echo [i] Ensure that the directory name does not contains illegal characters.
  179. Pause&Exit
  180. )
  181. Goto:EOF
  182.  
  183.  
  184. :Mount
  185. :: Mount the Windows Image into the directory.
  186. Echo [+] Mounting WIM Image...
  187. If /I "%MountImage%" EQU "True" (
  188.  
  189. "%Dism%" /Mount-Image /ImageFile:"%WindowsImage%" /Index:"%ImageIndex%" /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" || (
  190. Echo [x] Error mounting the Image Index "%ImageIndex%" in "%MountDir%"
  191. Echo [i] Ensure that the Image Index exist.
  192. Echo [i] Ensure that you have Admin rights to write inside the directory.
  193. Echo [i] Ensure that the directory is not already mounted.
  194. Echo [i] Ensure that the directory is fully empty.
  195. REM Try to unmount the failed image and discard changes.
  196. If /I "%UnmountImage%" EQU "True" (
  197. Echo [+] Unmounting and discarding changes...
  198. "%Dism%" /Unmount-WIM /Discard /MountDir:"%MountDir%"
  199. )
  200. Pause&Exit
  201. )
  202.  
  203. )
  204. Goto:EOF
  205.  
  206.  
  207. :CleanUp
  208. Echo [+] CleaningUp WIM Image...
  209. "%Dism%" /CleanUp-Image /StartComponentCleanUp /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet
  210. Goto:EOF
  211.  
  212.  
  213. :Unmount
  214. :: Unmount the Windows Image commiting changes.
  215. Echo [+] Unmounting WIM Image...
  216. If /I "%UnmountImage%" EQU "True" (
  217. "%Dism%" /Unmount-WIM /Commit /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%"
  218. )
  219. Goto:EOF
  220.  
  221.  
  222. :Rebuild
  223. If /I "%Rebuild%" EQU "False" (Goto:EOF)
  224.  
  225. Echo [+] Rebuilding WIM image...
  226.  
  227. ("%ImageX%" /Compress Maximum /Export "%WindowsImage%" "*" "%TEMP%\Rebuilt Image.wim" /Check) && (
  228. Del /Q /F "%WindowsImage%" 1>NUL
  229. Move /Y "%TEMP%\Rebuilt Image.wim" "%WindowsImage%" 1>NUL
  230. ) || (
  231. Echo [x] Error rebuilding Image "%WindowsImage%" to "%TEMP%\Rebuilt Image.wim".
  232. )
  233.  
  234. Goto :EOF
  235.  
  236.  
  237. :StartTimer
  238. Set "StartingDate=%Date%"
  239. Set "StarttingTime=%Time:~0,-3%"
  240. Goto :EOF
  241.  
  242.  
  243. :StopTimer
  244. (
  245. Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
  246. Echo WScript.Echo Minutes ^& " Minutes"
  247. )>"%TEMP%\%~n0 MinuteDiff.vbs"
  248.  
  249. For /F "Tokens=*" %%# In (
  250. 'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
  251. ) Do (
  252. Set "ElapsedTime=%%#"
  253. )
  254.  
  255. Goto:EOF
  256.  
  257.  
  258. :WriteConvertBytesScript
  259. If Exist "%TEMP%\%~n0 Convert Bytes.vbs" (Goto:EOF)
  260. (
  261. Echo Suffix = Array^("Bytes", "KB", "MB", "GB", "TB"^)
  262. Echo Function Convert^(Bytes^)
  263. Echo Convert = convert0^(Bytes, 0^)
  264. Echo End Function
  265. Echo Function Convert0^(Bytes, Level^)
  266. Echo If Bytes ^>= 1024 Then
  267. Echo Bytes = Round^(Bytes / 1024, 2^)
  268. Echo Level = Level + 1
  269. Echo Convert0 = Convert0^(Bytes, Level^)
  270. Echo End If
  271. Echo Convert0 = Bytes ^& " " ^& Suffix^(Level^)
  272. Echo End Function
  273. Echo WScript.Echo Convert^(WScript.Arguments^(0^)^)
  274. )>"%TEMP%\%~n0 Convert Bytes.vbs"
  275. Goto:EOF
  276.  
  277.  
  278. :GetWIMSizeBefore
  279. Call :WriteConvertBytesScript
  280. For %%# in ("%WindowsImage%") Do (Set "WIMSizeBefore=%%~z#")
  281. For /F "Tokens=*" %%# In (
  282. 'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeBefore%"'
  283. ) Do (
  284. Set "WIMSizeBefore=%%#"
  285. )
  286. Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
  287. Goto:EOF
  288.  
  289.  
  290. :GetWIMSizeAfter
  291. Call :WriteConvertBytesScript
  292. For %%# in ("%WindowsImage%") Do (Set "WIMSizeAfter=%%~z#")
  293. For /F "Tokens=*" %%# In (
  294. 'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeAfter%"'
  295. ) Do (
  296. Set "WIMSizeAfter=%%#"
  297. )
  298. Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
  299. Goto:EOF
  300.  
  301.  
  302. :ParseFeatures
  303.  
  304. Set /A "FeaturesRemovedCount=0"
  305. Set /A "FeaturesFailedCount=0"
  306. Set /A "FeaturesNotFoundCount=0"
  307.  
  308. :: Disable Features.
  309. For /F "UseBackQ Tokens=* Delims=" %%# In ("%FeatureList%") Do (
  310.  
  311. Echo [+] Disabling Feature: %%~#
  312.  
  313. "%Dism%" /Disable-Feature /FeatureName:"%%~#" /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet 1>NUL
  314.    Call Set /A "ExitCode=%%Errorlevel%%"
  315.  
  316.    (Call Echo "%%ExitCode%%"| Findstr.exe "^\"0\"$" 1>NUL 2>&1) && (
  317.     Call Set /A "FeaturesRemovedCount+=1"
  318.    )
  319.  
  320. (Call Echo "%%ExitCode%%"| Findstr.exe "^\"5\"$" 1>NUL 2>&1) && (
  321. Call Set /A "FeaturesFailedCount+=1"
  322. Echo Failed to disable feature: %%~#>>"%LogFile%"
  323. )
  324.  
  325. (Call Echo "%%ExitCode%%"| Find.exe "-2146498548" 1>NUL 2>&1) && (
  326. Call Set /A "FeaturesNotFoundCount+=1"
  327. Echo Feature is not found.....: %%~#>>"%LogFile%"
  328. )
  329.  
  330. )
  331. Goto:EOF
  332.  
  333.  
  334.  
  335. REM ===============
  336. REM Error Controls:
  337. REM ===============
  338.  
  339. :CheckErrors
  340.  
  341. :: WIM File Error-Check.
  342. If /I "MountImage" EQU "True" If Not Exist "%WindowsImage%" (
  343. Echo [x] Windows Image not found at: "%WindowsImage%" | MORE
  344. Pause&Exit
  345. )
  346.  
  347. :: FeatureList File Error-Check.
  348. If Not Exist "%FeatureList%" (
  349. Echo [x] FeatureList not found at: "%FeatureList%" | MORE
  350. Pause&Exit
  351. )
  352.  
  353. :: 'DISM.exe' File Error-Check.
  354. If Not Exist "%DISM%" (
  355. Echo [x] 'DISM' process not found at: "%DISM%" | MORE
  356. Pause&Exit
  357. )
  358.  
  359. :: 'ImageX.exe' File Error-Check.
  360. If Not Exist "%ImageX%" (
  361. Echo [x] 'ImageX' process not found at: "%ImageX%" | MORE
  362. Pause&Exit
  363. )
  364.  
  365. :: 'MountImage' Value check.
  366. If /I "%MountImage%" NEQ "True" If /I "%MountImage%" NEQ "False" (
  367. Echo [x] Error parsing parameter 'MountImage',
  368. Echo     value '%MountImage%' is not a Boolean value.
  369. Pause&Exit
  370. )
  371.  
  372. :: 'UnmountImage' Value check.
  373. If /I "%UnmountImage%" NEQ "True" If /I "%UnmountImage%" NEQ "False" (
  374. Echo [x] Error parsing parameter 'UnmountImage',
  375. Echo     value '%UnmountImage%' is not a Boolean value.
  376. Pause&Exit
  377. )
  378.  
  379. :: 'Rebuild' Value check.
  380. If /I "%Rebuild%" NEQ "True" If /I "%Rebuild%" NEQ "False" (
  381. Echo [x] Error parsing parameter 'Rebuild',
  382. Echo     value '%Rebuild%' is not a Boolean value.
  383. Pause&Exit
  384. )
  385.  
  386. :: 'DismLogLevel' Value check.
  387. Echo "%DismLogLevel%"| Findstr.exe "^\"[^1-4]\"$" 1>NUL 2>&1 || (
  388. Echo [x] Error parsing parameter 'DismLogLevel',
  389. Echo     value '%DismLogLevel%' is not in range '1-4'.
  390. Pause&Exit
  391. )
  392.  
  393. Goto:EOF
7305  Programación / Scripting / [APORTE] [BATCH] Filesize Truncator en: 14 Abril 2014, 05:01 am
Filesize Truncator

Este Script trunca el tamaño de los archivos que estén en el directorio de trabajo actual y en sus subdirectorios.
Nota: El directorio y otras propiedades se pueden modificar en las variables documentadas del código.

En realidad lo que hace es eliminar permanentemente el archivo, y luego se crea un archivo de 0 bytes con el mismo nombre y en la misma ubicación que el que se borró.

Esto es util por ejemplo si necesitamos crear una estructura de carpetas y archivos pero estos pesan demasiado tamaño y solo necesitamos mantener los nombres de los archivos y sus ubicaciones...

El Script tiene 2 métodos de búsqueda de archivos, el modo normal y el modo que incluye archivos ocultos.

Imágenes:




Source:
Código
  1. @Echo OFF
  2.  
  3.  
  4.  
  5. REM =================
  6. REM Console Settings:
  7. REM =================
  8.  
  9. Title Filesize Truncator - 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 will truncate to Zero the size of the files inside the working directory and it's subdirectories
  21. Echo  ------------------------------------------------------------------------------------------------------------
  22. Echo  Take extreme caution, truncating the filesize has the same effect as deleting the file !!
  23. Echo  -----------------------------------------------------------------------------------------
  24.  
  25.  
  26.  
  27. REM ====================
  28. REM User defined values:
  29. REM ====================
  30.  
  31. REM This value indicates the directory where to list it's file structure.
  32. Set "WorkingDir=%CD%"
  33.  
  34. REM This value indicates the ubication of the logfile that will record info.
  35. Set "Logfile=%CD%\%~n0.log"
  36.  
  37. REM This value indicates the File-Extensions to exclude during the process.
  38. REM ( Use an ';' delimiter to separate multiple extensions )
  39. Set "ExcludeExts=.bat;.cmd"
  40.  
  41. REM This value indicates the filenames to exclude during the process.
  42. REM ( Use an ';' delimiter to separate multiple filenames )
  43. Set "ExcludeNames=%~nx0;Files.txt;Files2List.log"
  44.  
  45. REM This value indicates the files to exclude during the process.
  46. REM ( Use an ';' delimiter to separate multiple files )
  47. Set "ExcludeFiles=%Logfile%"
  48.  
  49. REM This value indicates how the hidden files are threated when listing the file structure.
  50. REM  True = List files and also files with the 'hidden' attribute.
  51. REM False = List only normal files without the 'hidden' attribute.
  52. Set "IncludeHiddenFiles=True"
  53.  
  54.  
  55.  
  56. REM =====
  57. REM Main:
  58. REM =====
  59.  
  60. :: Warning question.
  61. Call :CreateLog
  62. Choice /C "YN" /M "This will delete the files, you want to continue?"
  63. If %ErrorLevel% NEQ 1 (Exit)
  64.  
  65. :: Call Methods.
  66. Call :CheckErrors
  67. Call :StartTimer
  68. Call :TruncateFiles "%IncludeHiddenFiles%"
  69. Call :StopTimer
  70. Call :EndLog
  71. Pause&Exit
  72.  
  73.  
  74.  
  75. REM ========
  76. REM Methods:
  77. REM ========
  78.  
  79. :CreateLog
  80. :: Create the Script Logfile and record starting info on it.
  81. FSutil.exe File CreateNew "%LogFile%" "0" 1>NUL
  82. (
  83. Echo    Filesize Truncator
  84. Echo =========================
  85. Echo   %DATE% ^| %TIME:~0,-3%
  86. Echo /\/\/\/\/\/\/\/\/\/\/\/\/
  87. Echo [i] Working Directory...: %WorkingDir%
  88. Echo [i] Include Hidden Files: %IncludeHiddenFiles%
  89. Echo [i] Excluded Extensions.: %ExcludeExts%
  90. Echo [i] Excluded Filenames..: %ExcludeNames%
  91. Echo [i] Excluded Files......: %ExcludeFiles%
  92. Echo [i] Log file............: %LogFile%
  93. Echo =========================
  94. )>"%LogFile%"
  95.  
  96. :: Display starting log info.
  97. Type "%LogFile%" | MORE
  98.  
  99. :: Continue writting log.
  100. (
  101. Echo Excluded Files:
  102. Echo ===============
  103. )>>"%LogFile%"
  104.  
  105. Goto:EOF
  106.  
  107.  
  108. :EndLog
  109. (
  110. Echo [i] Done!
  111. Echo [i] Truncated Files: %TruncatedFileCount% files.
  112. Echo [i] Excluded Files.: %ExcludedFileCount% files.
  113. Echo [i] Elapsed Time...: %ElapsedTime%
  114. )>>"%LogFile%"
  115.  
  116. :: Display ending information.
  117. CLS
  118. Type "%LogFile%"
  119. Goto:EOF
  120.  
  121.  
  122. :StartTimer
  123. Set "StartingDate=%Date%"
  124. Set "StarttingTime=%Time:~0,-3%"
  125. Goto :EOF
  126.  
  127.  
  128. :StopTimer
  129. (
  130. Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
  131. Echo WScript.Echo Minutes ^& " Minutes"
  132. )>"%TEMP%\%~n0 MinuteDiff.vbs"
  133.  
  134. For /F "Tokens=*" %%# In (
  135. 'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
  136. ) Do (
  137. Set "ElapsedTime=%%#"
  138. )
  139.  
  140. Goto:EOF
  141.  
  142.  
  143. :TakeOwn
  144. (
  145. Takeown.exe /F "%~f1"
  146. ICacls.exe "%~f1" /Grant "%UserName%":"F"
  147. Attrib.exe -R -A -S -H -I "%~f1"
  148. )>NUL || (Exit /B 1)
  149. Goto:EOF
  150.  
  151.  
  152. :TruncateFiles
  153. Echo [+] Truncating files with size greater than Zero, this operation could take some minutes long, please wait...
  154. If /I "%~1" EQU "True"  (Call :TruncateHiddenFiles)
  155. If /I "%~1" EQU "False" (Call :TruncateNormalFiles)
  156. Goto:EOF
  157.  
  158.  
  159. :TruncateNormalFiles
  160. FOR /R "%WorkingDir%" %%# in ("*") DO (
  161.  
  162. If %%~z# NEQ 0 (
  163.  
  164. Set "Exclude="
  165.  
  166. If Defined ExcludeExts (
  167. (
  168. Echo "%ExcludeExts%" | Find.exe /I "%%~x#" 1>NUL 2>&1
  169. ) && (
  170. Call Set "Exclude=True"
  171. )
  172. )
  173.  
  174. If Defined ExcludeNames (
  175. (
  176. Echo "%ExcludeNames%" | Find.exe /I "%%~nx#" 1>NUL 2>&1
  177. ) && (
  178. Call Set "Exclude=True"
  179. )
  180. )
  181.  
  182. If Defined ExcludeFiles (
  183. (
  184. Echo "%ExcludeFiles%" | Find.exe /I "%%~f#" 1>NUL 2>&1
  185. ) && (
  186. Call Set "Exclude=True"
  187. )
  188. )
  189.  
  190. If Not Defined Exclude (
  191. Set "File=%%~f#"
  192. Call Echo [.] Truncating: %%File:%WorkingDir%=.%%
  193. Call :TakeOwn "%%~f#"
  194. Del /Q "%%~f#"
  195. FSUtil.exe File CreateNew "%%~f#" "0" 1>NUL
  196. Set /A "TruncatedFileCount+=1"
  197. ) Else (
  198. Set "File=%%~f#"
  199. Call Echo %%File:%WorkingDir%=.%%>>"%LogFile%"
  200. Set /A "ExcludedFileCount+=1"
  201. )
  202. )
  203. )
  204. Goto:EOF
  205.  
  206.  
  207. :TruncateHiddenFiles
  208. FOR /F "Tokens=* Delims=" %%# in ('Dir /B /S /A-D "%WorkingDir%\*"') DO (
  209.  
  210. If %%~z# NEQ 0 (
  211.  
  212. Set "Exclude="
  213.  
  214. If Defined ExcludeExts (
  215. (
  216. Echo "%ExcludeExts%" | Find.exe /I "%%~x#" 1>NUL 2>&1
  217. ) && (
  218. Call Set "Exclude=True"
  219. )
  220. )
  221.  
  222. If Defined ExcludeNames (
  223. (
  224. Echo "%ExcludeNames%" | Find.exe /I "%%~nx#" 1>NUL 2>&1
  225. ) && (
  226. Call Set "Exclude=True"
  227. )
  228. )
  229.  
  230. If Defined ExcludeFiles (
  231. (
  232. Echo "%ExcludeFiles%" | Find.exe /I "%%~f#" 1>NUL 2>&1
  233. ) && (
  234. Call Set "Exclude=True"
  235. )
  236. )
  237.  
  238. If Not Defined Exclude (
  239. Set "File=%%~f#"
  240. Call Echo [.] Truncating: %%File:%WorkingDir%=.%%
  241. Call :TakeOwn "%%~f#"
  242. Del /Q "%%~f#"
  243. FSUtil.exe File CreateNew "%%~f#" "0" 1>NUL
  244. Set /A "TruncatedFileCount+=1"
  245. ) Else (
  246. Set "File=%%~f#"
  247. Call Echo %%File:%WorkingDir%=.%%>>"%LogFile%"
  248. Set /A "ExcludedFileCount+=1"
  249. )
  250.  
  251. )
  252. )
  253. Goto:EOF
  254.  
  255.  
  256.  
  257. REM ===============
  258. REM Error Controls:
  259. REM ===============
  260.  
  261. :CheckErrors
  262. :: 'IncludeHiddenFiles' Value check.
  263. If /I "%IncludeHiddenFiles%" NEQ "True" If /I "%IncludeHiddenFiles%" NEQ "False" (
  264. Echo [x] Error parsing parameter 'IncludeHiddenFiles',
  265. Echo     value '%IncludeHiddenFiles%' is not a Boolean value.
  266. Pause&Exit
  267. )
  268.  
  269. Goto:EOF

Saludos
7306  Programación / Scripting / Re: [APORTE] [BATCH] Files2List en: 14 Abril 2014, 04:40 am
Gracias por el aporte!, a mi me servirá de mucho en mi trabajo, asi que gracias!!.

Gracias a ti por comentar.

PD: He actualizado el código en el post de arriba (son pequeños cambios insignificantes).

Saludos!
7307  Sistemas Operativos / Windows / Re: ¡¡¡NO ACTUALICES XP O CAERAS EN UNA TRAMPA DIFÍCIL DE SALIR!!! en: 13 Abril 2014, 04:10 am
Solo me he leido las respuestas de la página 2, porque creo que este tema es un cachondeo y un campo de guerra, tanto por parte de los moderadores/colaboradores como sobretodo (mucho más) por parte tuya y creo que ya se te ha dicho todo lo que se te puede decir y no es necesario que nadie siga ni te sigan en una discusión absurda.

¿seguro que hay que hacer caso a Microsoft?

Si tú prefieres seguir usando un sistema operativo del año 2001 que está a la vuelta de la esquina de denominarse "sistema obsoleto" (si, he dicho obsoleto, ES LO QUE ES, que algunos lo quieran explotar duranto 5 años más es otra cosa) pues será tu decisión y la de los demás, sigue usandolo, como ya te comentaron eres libre de hacerlo, realmente nadie te está poniendo una pistola en la cabeza para que cambies de SO, ¿que quieres que te digamos?...

Para mi es lo mismo que comprar un boligrafo y esperar que te dure toda la vida, pues no, cuando pasa el tiempo este hay que renovarlo por un producto nuevo, no se...¿es que esperas que Windows XP dure para siempre?, ya ha pasado una larga década con WinXP, creo que ya es hora de hacerse a la idea y dejarse de críticas absurdas en contra de la compañia que ha estado manteniendo dicho producto hasta dia de hoy, eso en la informatica y en la tecnología en general no se ve, cuando sale algo nuevo y mejor el producto anterior se reemplaza completamente en menos de 1 año (por decir algo), pero tú y miles de personas más tienen la falta de respeto de quejarse por el deber de tener que actualizar WinXP o de quedarse sin actualizaciones... pues las decisiones de Microsoft en mi opinión son lo más normal del mundo y estoy seguro de que habrían "capado" a WinXP mucho antes si no fuese porque una gran mayoria insiste en seguir usando ese SO y eso le da beneficios a Microsoft, pero dicha gente insiste con elaboradas respuestas tipo "consume muy pocos recursos", coño!. ¿no me digas?, claro que consume muy pocos recursos!, es lo que se espera de un SO de hace una decada, como que es un Windows sin el potencial de una version reciente y los requisitos que estos necesitan.

Saludos!
7308  Sistemas Operativos / Windows / Re: Panel de control no responde en widows 7 en: 13 Abril 2014, 03:54 am
¿Podrías explicar un poco más? Gracias.

IDEM.

Explica "No responde".
7309  Sistemas Operativos / Windows / Re: Guía de personalización de imágenes de implementación de Windows (WIM) (Parte 1) en: 12 Abril 2014, 23:58 pm
Me mataste con las imagenes xD, me gusta saber que estoy en tu Hall Of Fame sobretodo cerca de Carl Sagan, pero no me puedo comparar con ninguno de ellos ni me merezco estar ahi xD.

Con que 1 sola persona se tome la molesta de leer lo que yo me he tomado la molestia en escribir, eso para mi ya es más que suficiente.

¡ Mil gracias por tu forma de agradecer !

Saludos!
7310  Sistemas Operativos / Windows / 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
Páginas: 1 ... 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 [731] 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 ... 1254
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines