Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - Eleкtro

#6991
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 (dos) [Seleccionar]
@Echo OFF



REM =================
REM Console Settings:
REM =================

Title WIM Package Uninstaller - By Elektro
Mode Con Cols=150 Lines=50
CHCP 1252 1>NUL & REM Windows-1252, Spanish-Latin.



REM =====
REM Info:
REM =====

Echo+
Echo  ----------------------------------------------------------------------------------
Echo  This script mounts a Windows Image ^(WIM^) and then removes pre-installed packages
Echo  ----------------------------------------------------------------------------------
Echo+



REM ====================
REM User defined values:
REM ====================

REM This value indicates whether the Windows Image should be mounted.
REM True  = 'DISM' will try to mount the 'WIM' image.
REM False = 'DISM' will not try to mount the WIM image.
REM Set this value to 'FALSE' if the 'WIM' image is already mounted in the specified mount directory,
REM Otherwise, keep it as 'TRUE'.
Set "MountImage=True"

REM This value indicates whether the Windows Image should be unmounted at the end.
REM True  = 'DISM' will try to unmount the 'WIM' image.
REM False = 'DISM' will not try to unmount the WIM image.
REM Set this value to 'FALSE' if you want to keep the image mounted to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "UnmountImage=True"

REM This value indicates whether the Windows Image should be rebuilt at the end.
REM True  = 'ImageX' will try to rebuild the 'WIM' image.
REM False = 'ImageX' will keep the 'WIM' image as is.
REM Set this value to 'FALSE' if you want to keep the image with normal size to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "Rebuild=True"

REM This value indicates the 'WIM' image to be mounted.
Set "WindowsImage=%UserProfile%\Desktop\win 8 .1\win\sources\install.wim"

REM This value indicates the Image Index of the 'WIM' image.
Set "ImageIndex=1"

REM This value indicates the directory where to mount the 'WIM' image.
Set "MountDir=%HomeDrive%\WinMount"

REM This value indicates the textfile that contains the names of the packages to remove.
Set "PackageList=%CD%\Packages.txt"

REM This value indicates the ubication of the 'WIM Registry Tweak Tool.exe' file.
Set "WIMRegistryTweakTool=%CD%\Tools\WIM Registry Tweak Tool\WIM Registry Tweak Tool.exe"

REM This value indicates the ubication of 'ImageX.exe' file.
Set "ImageX=%CD%\Tools\Dism\ImageX.exe"

REM This value indicates the ubication of a custom 'DISM.exe' file if needed.
REM Default ubication: "%SystemRoot%\System32\Dism.exe"
Set "Dism=%CD%\Tools\Dism\Dism.exe"

REM This value indicates the ubication of the logfile that will record 'DISM' errors.
Set "DismLogfile=%CD%\%~n0 DISM.log"

REM This value indicates the logging-level of the 'DISM' process.
REM 1 = Errors only
REM 2 = Errors and warnings
REM 3 = Errors, warnings, and informational
REM 4 = All of the information listed previously, plus debug output
Set /A "DismLogLevel=2"

REM This value indicates the ubication of the logfile that will record Main information.
Set "Logfile=%CD%\%~n0.log"



REM =====
REM Main:
REM =====

:: Call Methods.
Call :CheckErrors
Call :CreateLogs
Call :CreateMountDir
Call :GetWIMSizeBefore
Call :StartTimer
Call :Mount
CLS
Call :ParsePackages
CLS
Call :CleanUp
Call :Unmount
Call :Rebuild
Call :StopTimer
Call :GetWIMSizeAfter
Call :EndLog
Pause&Exit



REM ========
REM Methods:
REM ========


:CreateLogs

:: Create the 'DISM' logfile with 'ANSI' encoding,
:: this is necessary to record a non-default 'DISM' loglevel such as '1' or '2'.
Echo+ >"%DismLogfile%"


:: Create the Main logfile and record starting info on it.
Echo+ >"%Logfile%"
(
Echo+
Echo   WIM Package Uninstaller
Echo ===========================
Echo   %DATE% ^| %TIME:~0,-3%
Echo /\/\/\/\/\/\/\/\/\/\/\/\/\/
Echo+
Echo [i] Mount Image?...: %MountImage%
Echo [i] Unmount Image?.: %UnmountImage%
Echo+
Echo [i] Windows Image..: %WindowsImage%
Echo [i] Image Index....: %ImageIndex%
Echo [i] Mount Directory: %MountDir%
Echo+
Echo [i] ImageX Path....: %ImageX%
Echo [i] Dism Path......: %Dism%
Echo [i] Dism Log File..: %DismLogfile%
Echo [i] Dism Log Level.: %DismLogLevel%
Echo+
Echo [i] WIMRegistryTool: %WIMRegistryTweakTool%
Echo [i] Package List...: %PackageList%
Echo [i] Log File.......: %Logfile%
Echo+
Echo ===========================
)>"%Logfile%"

:: Display starting log info.
Type "%Logfile%"

:: Continue writting log.
(
Echo+
Echo Package conflicts:
Echo ==================
Echo+
)>>"%LogFile%"
Goto:EOF


:EndLog
(
Echo+
Echo [i] Done!
Echo [i] WIM Image Size Before........: %WIMSizeBefore%
Echo [i] WIM Image Size After.........: %WIMSizeAfter%
Echo [i] Packages Successfully Removed: %PackagesRemovedCount% Packages.
Echo [i] Packages Failed To Remove....: %PackagesFailedCount% Packages.
Echo [i] Packages Not Found...........: %PackagesNotFoundCount% Packages.
Echo [i] Elapsed Time.................: %ElapsedTime%
Echo+
)>>"%LogFile%"

:: Display ending information.
CLS
Type "%LogFile%"
Goto:EOF


:CreateMountDir
:: Create the mount directory.
(
If Not Exist "%MountDir%" If /I "%MountImage%" EQU "True" (
MkDir "%MountDir%" 2>NUL
)
) || (
Echo+
Echo [x] Error trying to create the directory "%MountDir%" to mount the Windows Image.
Echo [i] Ensure that you have Admin rights to create the directory.
Echo [i] Ensure that the directory name does not contains illegal characters.
Echo+
Pause&Exit
)
Goto:EOF


:Mount
:: Mount the Windows Image into the directory.
Echo+
Echo [+] Mounting WIM Image...
If /I "%MountImage%" EQU "True" (

"%Dism%" /Mount-Image /ImageFile:"%WindowsImage%" /Index:"%ImageIndex%" /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" || (
Echo+
Echo [x] Error mounting the Image Index "%ImageIndex%" in "%MountDir%"
Echo [i] Ensure that the Image Index exist.
Echo [i] Ensure that you have Admin rights to write inside the directory.
Echo [i] Ensure that the directory is not already mounted.
Echo [i] Ensure that the directory is fully empty.
Echo+
REM Try to unmount the failed image and discard changes.
If /I "%UnmountImage%" EQU "True" (
Echo [+] Unmounting and discarding changes...
"%Dism%" /Unmount-WIM /Discard /MountDir:"%MountDir%"
)
Pause&Exit
)

)
Goto:EOF


:CleanUp
Echo [+] CleaningUp WIM Image...
"%Dism%" /CleanUp-Image /StartComponentCleanUp /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet
Echo+
Goto:EOF


:Unmount
:: Unmount the Windows Image commiting changes.
Echo [+] Unmounting WIM Image...
If /I "%UnmountImage%" EQU "True" (
"%Dism%" /Unmount-WIM /Commit /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%"
)
Goto:EOF


:Rebuild
If /I "%Rebuild%" EQU "False" (Goto:EOF)

Echo+
Echo [+] Rebuilding WIM image...

("%ImageX%" /Compress Maximum /Export "%WindowsImage%" "*" "%TEMP%\Rebuilt Image.wim" /Check) && (
Del /Q /F "%WindowsImage%" 1>NUL
Move /Y "%TEMP%\Rebuilt Image.wim" "%WindowsImage%" 1>NUL
) || (
Echo [x] Error rebuilding Image "%WindowsImage%" to "%TEMP%\Rebuilt Image.wim".
)

Goto :EOF


:StartTimer
Set "StartingDate=%Date%"
Set "StarttingTime=%Time:~0,-3%"
Goto :EOF


:StopTimer
(
Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
Echo WScript.Echo Minutes ^& " Minutes"
)>"%TEMP%\%~n0 MinuteDiff.vbs"

For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
) Do (
Set "ElapsedTime=%%#"
)

Goto:EOF


:WriteConvertBytesScript
If Exist "%TEMP%\%~n0 Convert Bytes.vbs" (Goto:EOF)
(
Echo Suffix = Array^("Bytes", "KB", "MB", "GB", "TB"^)
Echo+
Echo Function Convert^(Bytes^)
Echo Convert = convert0^(Bytes, 0^)
Echo End Function
Echo+
Echo Function Convert0^(Bytes, Level^)
Echo If Bytes ^>= 1024 Then
Echo Bytes = Round^(Bytes / 1024, 2^)
Echo Level = Level + 1
Echo Convert0 = Convert0^(Bytes, Level^)
Echo End If
Echo Convert0 = Bytes ^& " " ^& Suffix^(Level^)
Echo End Function
Echo+
Echo WScript.Echo Convert^(WScript.Arguments^(0^)^)
)>"%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF


:GetWIMSizeBefore
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeBefore=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeBefore%"'
) Do (
Set "WIMSizeBefore=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF


:GetWIMSizeAfter
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeAfter=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeAfter%"'
) Do (
Set "WIMSizeAfter=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF


:ParsePackages

Set /A "PackagesRemovedCount=0"
Set /A "PackagesFailedCount=0"
Set /A "PackagesNotFoundCount=0"

:: Unhide packages and take registry ownership.
"%WIMRegistryTweakTool%" /p "%MountDir%"
Echo+

:: Remove Packages.
For /F "UseBackQ Tokens=* Delims=" %%# In ("%PackageList%") Do (

Echo [+] Removing package: %%~#

"%Dism%" /Remove-Package /PackageName:"%%~#" /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet 1>NUL
    Call Set /A "ExitCode=%%Errorlevel%%"

    (Call Echo "%%ExitCode%%"| Findstr.exe "^\"0\"$" 1>NUL 2>&1) && (
    Call Set /A "PackagesRemovedCount+=1"
    )

(Call Echo "%%ExitCode%%"| Findstr.exe "^\"5\"$" 1>NUL 2>&1) && (
Call Set /A "PackagesFailedCount+=1"
Echo Failed to remove package: %%~#>>"%LogFile%"
)

(Call Echo "%%ExitCode%%"| Find.exe "-2146498555" 1>NUL 2>&1) && (
Call Set /A "PackagesNotFoundCount+=1"
Echo Package is not installed: %%~#>>"%LogFile%"
)

)
Goto:EOF



REM ===============
REM Error Controls:
REM ===============

:CheckErrors
:: WIM File Error-Check.
If /I "MountImage" EQU "True" If Not Exist "%WindowsImage%" (
Echo [x] Windows Image not found at: "%WindowsImage%" | MORE
Pause&Exit
)

:: PackageList File Error-Check.
If Not Exist "%PackageList%" (
Echo [x] PackageList not found at: "%PackageList%" | MORE
Pause&Exit
)

:: 'DISM.exe' File Error-Check.
If Not Exist "%DISM%" (
Echo [x] 'DISM' process not found at: "%DISM%" | MORE
Pause&Exit
)

:: 'ImageX.exe' File Error-Check.
If Not Exist "%ImageX%" (
Echo [x] 'ImageX' process not found at: "%ImageX%" | MORE
Pause&Exit
)

:: 'WIM Registry Tweak Tool.exe' File Error-Check.
If Not Exist "%WIMRegistryTweakTool%" (
Echo [x] 'WIM Registry Tweak Tool' process not found at: "%WIMRegistryTweakTool%" | MORE
Pause&Exit
)

:: 'MountImage' Value check.
If /I "%MountImage%" NEQ "True" If /I "%MountImage%" NEQ "False" (
Echo [x] Error parsing parameter 'MountImage',
Echo     value '%MountImage%' is not a Boolean value.
Pause&Exit
)

:: 'UnmountImage' Value check.
If /I "%UnmountImage%" NEQ "True" If /I "%UnmountImage%" NEQ "False" (
Echo [x] Error parsing parameter 'UnmountImage',
Echo     value '%UnmountImage%' is not a Boolean value.
Pause&Exit
)

:: 'Rebuild' Value check.
If /I "%Rebuild%" NEQ "True" If /I "%Rebuild%" NEQ "False" (
Echo [x] Error parsing parameter 'Rebuild',
Echo     value '%Rebuild%' is not a Boolean value.
Pause&Exit
)

:: 'DismLogLevel' Value check.
Echo "%DismLogLevel%"| Findstr.exe "^\"[^1-4]\"$" 1>NUL 2>&1 || (
Echo [x] Error parsing parameter 'DismLogLevel',
Echo     value '%DismLogLevel%' is not in range '1-4'.
Pause&Exit
)

Goto:EOF

#6992
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 (dos) [Seleccionar]
@Echo OFF



REM =================
REM Console Settings:
REM =================

Title WIM Feature Uninstaller - By Elektro
Mode Con Cols=150 Lines=50
CHCP 1252 1>NUL & REM Windows-1252, Spanish-Latin.



REM =====
REM Info:
REM =====

Echo+
Echo  -----------------------------------------------------------------------------
Echo  This script mounts a Windows Image ^(WIM^) and then disables Windows features
Echo  -----------------------------------------------------------------------------
Echo+



REM ====================
REM User defined values:
REM ====================

REM This value indicates whether the Windows Image should be mounted.
REM True  = 'DISM' will try to mount the 'WIM' image.
REM False = 'DISM' will not try to mount the WIM image.
REM Set this value to 'FALSE' if the 'WIM' image is already mounted in the specified mount directory,
REM Otherwise, keep it as 'TRUE'.
Set "MountImage=True"

REM This value indicates whether the Windows Image should be unmounted at the end.
REM True  = 'DISM' will try to unmount the 'WIM' image.
REM False = 'DISM' will not try to unmount the WIM image.
REM Set this value to 'FALSE' if you want to keep the image mounted to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "UnmountImage=True"

REM This value indicates whether the Windows Image should be rebuilt at the end.
REM True  = 'ImageX' will try to rebuild the 'WIM' image.
REM False = 'ImageX' will keep the 'WIM' image as is.
REM Set this value to 'FALSE' if you want to keep the image with normal size to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "Rebuild=True"

REM This value indicates the 'WIM' image to be mounted.
Set "WindowsImage=%UserProfile%\Desktop\win 8 .1\win\sources\install.wim"

REM This value indicates the Image Index of the 'WIM' image.
Set "ImageIndex=1"

REM This value indicates the directory where to mount the 'WIM' image.
Set "MountDir=%HomeDrive%\WinMount"

REM This value indicates the textfile that contains the names of the features to disable.
Set "FeatureList=%CD%\Features.txt"

REM This value indicates the ubication of 'ImageX.exe' file.
Set "ImageX=%CD%\Tools\Dism\ImageX.exe"

REM This value indicates the ubication of a custom 'DISM.exe' file if needed.
REM Default ubication: "%SystemRoot%\System32\Dism.exe"
Set "Dism=%CD%\Tools\Dism\Dism.exe"

REM This value indicates the ubication of the logfile that will record 'DISM' errors.
Set "DismLogfile=%CD%\%~n0 DISM.log"

REM This value indicates the logging-level of the 'DISM' process.
REM 1 = Errors only
REM 2 = Errors and warnings
REM 3 = Errors, warnings, and informational
REM 4 = All of the information listed previously, plus debug output
Set /A "DismLogLevel=2"

REM This value indicates the ubication of the logfile that will record Main information.
Set "Logfile=%CD%\%~n0.log"



REM =====
REM Main:
REM =====

:: Call Methods.
Call :CheckErrors
Call :CreateLogs
Call :CreateMountDir
Call :GetWIMSizeBefore
Call :StartTimer
Call :Mount
CLS
Call :ParseFeatures
CLS
Call :CleanUp
Call :Unmount
Call :Rebuild
Call :StopTimer
Call :GetWIMSizeAfter
Call :EndLog
Pause&Exit



REM ========
REM Methods:
REM ========


:CreateLogs

:: Create the 'DISM' logfile with 'ANSI' encoding,
:: this is necessary to record a non-default 'DISM' loglevel such as '1' or '2'.
Echo+ >"%DismLogfile%"


:: Create the Main logfile and record starting info on it.
Echo+ >"%Logfile%"
(
Echo+
Echo   WIM Feature Uninstaller
Echo ===========================
Echo   %DATE% ^| %TIME:~0,-3%
Echo /\/\/\/\/\/\/\/\/\/\/\/\/\/
Echo+
Echo [i] Mount Image?...: %MountImage%
Echo [i] Unmount Image?.: %UnmountImage%
Echo+
Echo [i] Windows Image..: %WindowsImage%
Echo [i] Image Index....: %ImageIndex%
Echo [i] Mount Directory: %MountDir%
Echo+
Echo [i] ImageX Path....: %ImageX%
Echo [i] Dism Path......: %Dism%
Echo [i] Dism Log File..: %DismLogfile%
Echo [i] Dism Log Level.: %DismLogLevel%
Echo+
Echo [i] Feature List...: %FeatureList%
Echo [i] Log File.......: %Logfile%
Echo+
Echo ===========================
)>"%Logfile%"

:: Display starting log info.
Type "%Logfile%"

:: Continue writting log.
(
Echo+
Echo Feature conflicts:
Echo ==================
Echo+
)>>"%LogFile%"
Goto:EOF


:EndLog
(
Echo+
Echo [i] Done!
Echo [i] WIM Image Size Before.........: %WIMSizeBefore%
Echo [i] WIM Image Size After..........: %WIMSizeAfter%
Echo [i] Features Successfully Disabled: %FeaturesRemovedCount% Packages.
Echo [i] Features Failed To Disable....: %FeaturesFailedCount% Packages.
Echo [i] Features Not Found............: %FeaturesNotFoundCount% Packages.
Echo [i] Elapsed Time..................: %ElapsedTime%
Echo+
)>>"%LogFile%"

:: Display ending information.
CLS
Type "%LogFile%"
Goto:EOF


:CreateMountDir
:: Create the mount directory.
(
If Not Exist "%MountDir%" If /I "%MountImage%" EQU "True" (
MkDir "%MountDir%" 2>NUL
)
) || (
Echo+
Echo [x] Error trying to create the directory "%MountDir%" to mount the Windows Image.
Echo [i] Ensure that you have Admin rights to create the directory.
Echo [i] Ensure that the directory name does not contains illegal characters.
Echo+
Pause&Exit
)
Goto:EOF


:Mount
:: Mount the Windows Image into the directory.
Echo+
Echo [+] Mounting WIM Image...
If /I "%MountImage%" EQU "True" (

"%Dism%" /Mount-Image /ImageFile:"%WindowsImage%" /Index:"%ImageIndex%" /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" || (
Echo+
Echo [x] Error mounting the Image Index "%ImageIndex%" in "%MountDir%"
Echo [i] Ensure that the Image Index exist.
Echo [i] Ensure that you have Admin rights to write inside the directory.
Echo [i] Ensure that the directory is not already mounted.
Echo [i] Ensure that the directory is fully empty.
Echo+
REM Try to unmount the failed image and discard changes.
If /I "%UnmountImage%" EQU "True" (
Echo [+] Unmounting and discarding changes...
"%Dism%" /Unmount-WIM /Discard /MountDir:"%MountDir%"
)
Pause&Exit
)

)
Goto:EOF


:CleanUp
Echo [+] CleaningUp WIM Image...
"%Dism%" /CleanUp-Image /StartComponentCleanUp /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet
Echo+
Goto:EOF


:Unmount
:: Unmount the Windows Image commiting changes.
Echo [+] Unmounting WIM Image...
If /I "%UnmountImage%" EQU "True" (
"%Dism%" /Unmount-WIM /Commit /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%"
)
Goto:EOF


:Rebuild
If /I "%Rebuild%" EQU "False" (Goto:EOF)

Echo+
Echo [+] Rebuilding WIM image...

("%ImageX%" /Compress Maximum /Export "%WindowsImage%" "*" "%TEMP%\Rebuilt Image.wim" /Check) && (
Del /Q /F "%WindowsImage%" 1>NUL
Move /Y "%TEMP%\Rebuilt Image.wim" "%WindowsImage%" 1>NUL
) || (
Echo [x] Error rebuilding Image "%WindowsImage%" to "%TEMP%\Rebuilt Image.wim".
)

Goto :EOF


:StartTimer
Set "StartingDate=%Date%"
Set "StarttingTime=%Time:~0,-3%"
Goto :EOF


:StopTimer
(
Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
Echo WScript.Echo Minutes ^& " Minutes"
)>"%TEMP%\%~n0 MinuteDiff.vbs"

For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
) Do (
Set "ElapsedTime=%%#"
)

Goto:EOF


:WriteConvertBytesScript
If Exist "%TEMP%\%~n0 Convert Bytes.vbs" (Goto:EOF)
(
Echo Suffix = Array^("Bytes", "KB", "MB", "GB", "TB"^)
Echo+
Echo Function Convert^(Bytes^)
Echo Convert = convert0^(Bytes, 0^)
Echo End Function
Echo+
Echo Function Convert0^(Bytes, Level^)
Echo If Bytes ^>= 1024 Then
Echo Bytes = Round^(Bytes / 1024, 2^)
Echo Level = Level + 1
Echo Convert0 = Convert0^(Bytes, Level^)
Echo End If
Echo Convert0 = Bytes ^& " " ^& Suffix^(Level^)
Echo End Function
Echo+
Echo WScript.Echo Convert^(WScript.Arguments^(0^)^)
)>"%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF


:GetWIMSizeBefore
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeBefore=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeBefore%"'
) Do (
Set "WIMSizeBefore=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF


:GetWIMSizeAfter
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeAfter=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeAfter%"'
) Do (
Set "WIMSizeAfter=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF


:ParseFeatures

Set /A "FeaturesRemovedCount=0"
Set /A "FeaturesFailedCount=0"
Set /A "FeaturesNotFoundCount=0"

:: Disable Features.
For /F "UseBackQ Tokens=* Delims=" %%# In ("%FeatureList%") Do (

Echo [+] Disabling Feature: %%~#

"%Dism%" /Disable-Feature /FeatureName:"%%~#" /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet 1>NUL
   Call Set /A "ExitCode=%%Errorlevel%%"

   (Call Echo "%%ExitCode%%"| Findstr.exe "^\"0\"$" 1>NUL 2>&1) && (
    Call Set /A "FeaturesRemovedCount+=1"
   )

(Call Echo "%%ExitCode%%"| Findstr.exe "^\"5\"$" 1>NUL 2>&1) && (
Call Set /A "FeaturesFailedCount+=1"
Echo Failed to disable feature: %%~#>>"%LogFile%"
)

(Call Echo "%%ExitCode%%"| Find.exe "-2146498548" 1>NUL 2>&1) && (
Call Set /A "FeaturesNotFoundCount+=1"
Echo Feature is not found.....: %%~#>>"%LogFile%"
)

)
Goto:EOF



REM ===============
REM Error Controls:
REM ===============

:CheckErrors

:: WIM File Error-Check.
If /I "MountImage" EQU "True" If Not Exist "%WindowsImage%" (
Echo [x] Windows Image not found at: "%WindowsImage%" | MORE
Pause&Exit
)

:: FeatureList File Error-Check.
If Not Exist "%FeatureList%" (
Echo [x] FeatureList not found at: "%FeatureList%" | MORE
Pause&Exit
)

:: 'DISM.exe' File Error-Check.
If Not Exist "%DISM%" (
Echo [x] 'DISM' process not found at: "%DISM%" | MORE
Pause&Exit
)

:: 'ImageX.exe' File Error-Check.
If Not Exist "%ImageX%" (
Echo [x] 'ImageX' process not found at: "%ImageX%" | MORE
Pause&Exit
)

:: 'MountImage' Value check.
If /I "%MountImage%" NEQ "True" If /I "%MountImage%" NEQ "False" (
Echo [x] Error parsing parameter 'MountImage',
Echo     value '%MountImage%' is not a Boolean value.
Pause&Exit
)

:: 'UnmountImage' Value check.
If /I "%UnmountImage%" NEQ "True" If /I "%UnmountImage%" NEQ "False" (
Echo [x] Error parsing parameter 'UnmountImage',
Echo     value '%UnmountImage%' is not a Boolean value.
Pause&Exit
)

:: 'Rebuild' Value check.
If /I "%Rebuild%" NEQ "True" If /I "%Rebuild%" NEQ "False" (
Echo [x] Error parsing parameter 'Rebuild',
Echo     value '%Rebuild%' is not a Boolean value.
Pause&Exit
)

:: 'DismLogLevel' Value check.
Echo "%DismLogLevel%"| Findstr.exe "^\"[^1-4]\"$" 1>NUL 2>&1 || (
Echo [x] Error parsing parameter 'DismLogLevel',
Echo     value '%DismLogLevel%' is not in range '1-4'.
Pause&Exit
)

Goto:EOF

#6993
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 (dos) [Seleccionar]
@Echo OFF



REM =================
REM Console Settings:
REM =================

Title Filesize Truncator - By Elektro
Mode Con Cols=150 Lines=50
CHCP 1252 1>NUL & REM Windows-1252, Spanish-Latin.



REM =====
REM Info:
REM =====

Echo+
Echo  ------------------------------------------------------------------------------------------------------------
Echo  This script will truncate to Zero the size of the files inside the working directory and it's subdirectories
Echo  ------------------------------------------------------------------------------------------------------------
Echo  Take extreme caution, truncating the filesize has the same effect as deleting the file !!
Echo  -----------------------------------------------------------------------------------------
Echo+



REM ====================
REM User defined values:
REM ====================

REM This value indicates the directory where to list it's file structure.
Set "WorkingDir=%CD%"

REM This value indicates the ubication of the logfile that will record info.
Set "Logfile=%CD%\%~n0.log"

REM This value indicates the File-Extensions to exclude during the process.
REM ( Use an ';' delimiter to separate multiple extensions )
Set "ExcludeExts=.bat;.cmd"

REM This value indicates the filenames to exclude during the process.
REM ( Use an ';' delimiter to separate multiple filenames )
Set "ExcludeNames=%~nx0;Files.txt;Files2List.log"

REM This value indicates the files to exclude during the process.
REM ( Use an ';' delimiter to separate multiple files )
Set "ExcludeFiles=%Logfile%"

REM This value indicates how the hidden files are threated when listing the file structure.
REM  True = List files and also files with the 'hidden' attribute.
REM False = List only normal files without the 'hidden' attribute.
Set "IncludeHiddenFiles=True"



REM =====
REM Main:
REM =====

:: Warning question.
Call :CreateLog
Echo+
Choice /C "YN" /M "This will delete the files, you want to continue?"
If %ErrorLevel% NEQ 1 (Exit)
Echo+

:: Call Methods.
Call :CheckErrors
Call :StartTimer
Call :TruncateFiles "%IncludeHiddenFiles%"
Call :StopTimer
Call :EndLog
Pause&Exit



REM ========
REM Methods:
REM ========

:CreateLog
:: Create the Script Logfile and record starting info on it.
FSutil.exe File CreateNew "%LogFile%" "0" 1>NUL
(
Echo+
Echo    Filesize Truncator
Echo =========================
Echo   %DATE% ^| %TIME:~0,-3%
Echo /\/\/\/\/\/\/\/\/\/\/\/\/
Echo+
Echo [i] Working Directory...: %WorkingDir%
Echo [i] Include Hidden Files: %IncludeHiddenFiles%
Echo [i] Excluded Extensions.: %ExcludeExts%
Echo [i] Excluded Filenames..: %ExcludeNames%
Echo [i] Excluded Files......: %ExcludeFiles%
Echo [i] Log file............: %LogFile%
Echo+
Echo =========================
)>"%LogFile%"

:: Display starting log info.
Type "%LogFile%" | MORE

:: Continue writting log.
(
Echo+
Echo Excluded Files:
Echo ===============
Echo+
)>>"%LogFile%"

Goto:EOF


:EndLog
(
Echo+
Echo [i] Done!
Echo [i] Truncated Files: %TruncatedFileCount% files.
Echo [i] Excluded Files.: %ExcludedFileCount% files.
Echo [i] Elapsed Time...: %ElapsedTime%
Echo+
)>>"%LogFile%"

:: Display ending information.
CLS
Type "%LogFile%"
Goto:EOF


:StartTimer
Set "StartingDate=%Date%"
Set "StarttingTime=%Time:~0,-3%"
Goto :EOF


:StopTimer
(
Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
Echo WScript.Echo Minutes ^& " Minutes"
)>"%TEMP%\%~n0 MinuteDiff.vbs"

For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
) Do (
Set "ElapsedTime=%%#"
)

Goto:EOF


:TakeOwn
(
Takeown.exe /F "%~f1"
ICacls.exe "%~f1" /Grant "%UserName%":"F"
Attrib.exe -R -A -S -H -I "%~f1"
)>NUL || (Exit /B 1)
Goto:EOF


:TruncateFiles
Echo [+] Truncating files with size greater than Zero, this operation could take some minutes long, please wait...
If /I "%~1" EQU "True"  (Call :TruncateHiddenFiles)
If /I "%~1" EQU "False" (Call :TruncateNormalFiles)
Goto:EOF


:TruncateNormalFiles
FOR /R "%WorkingDir%" %%# in ("*") DO (

If %%~z# NEQ 0 (

Set "Exclude="

If Defined ExcludeExts (
(
Echo "%ExcludeExts%" | Find.exe /I "%%~x#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)

If Defined ExcludeNames (
(
Echo "%ExcludeNames%" | Find.exe /I "%%~nx#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)

If Defined ExcludeFiles (
(
Echo "%ExcludeFiles%" | Find.exe /I "%%~f#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)

If Not Defined Exclude (
Set "File=%%~f#"
Call Echo [.] Truncating: %%File:%WorkingDir%=.%%
Call :TakeOwn "%%~f#"
Del /Q "%%~f#"
FSUtil.exe File CreateNew "%%~f#" "0" 1>NUL
Set /A "TruncatedFileCount+=1"
) Else (
Set "File=%%~f#"
Call Echo %%File:%WorkingDir%=.%%>>"%LogFile%"
Set /A "ExcludedFileCount+=1"
)
)
)
Goto:EOF


:TruncateHiddenFiles
FOR /F "Tokens=* Delims=" %%# in ('Dir /B /S /A-D "%WorkingDir%\*"') DO (

If %%~z# NEQ 0 (

Set "Exclude="

If Defined ExcludeExts (
(
Echo "%ExcludeExts%" | Find.exe /I "%%~x#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)

If Defined ExcludeNames (
(
Echo "%ExcludeNames%" | Find.exe /I "%%~nx#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)

If Defined ExcludeFiles (
(
Echo "%ExcludeFiles%" | Find.exe /I "%%~f#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)

If Not Defined Exclude (
Set "File=%%~f#"
Call Echo [.] Truncating: %%File:%WorkingDir%=.%%
Call :TakeOwn "%%~f#"
Del /Q "%%~f#"
FSUtil.exe File CreateNew "%%~f#" "0" 1>NUL
Set /A "TruncatedFileCount+=1"
) Else (
Set "File=%%~f#"
Call Echo %%File:%WorkingDir%=.%%>>"%LogFile%"
Set /A "ExcludedFileCount+=1"
)

)
)
Goto:EOF



REM ===============
REM Error Controls:
REM ===============

:CheckErrors
:: 'IncludeHiddenFiles' Value check.
If /I "%IncludeHiddenFiles%" NEQ "True" If /I "%IncludeHiddenFiles%" NEQ "False" (
Echo [x] Error parsing parameter 'IncludeHiddenFiles',
Echo     value '%IncludeHiddenFiles%' is not a Boolean value.
Pause&Exit
)

Goto:EOF


Saludos
#6994
Scripting / Re: [APORTE] [BATCH] Files2List
14 Abril 2014, 04:40 AM
Cita de: FranciskoAsdf en 14 Abril 2014, 04:00 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!
#6995
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.

Cita de: cixert en 13 Abril 2014, 02:11 AM¿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!
#6996
Cita de: Last_ en 13 Abril 2014, 03:09 AM
¿Podrías explicar un poco más? Gracias.

IDEM.

Explica "No responde".
#6997
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!
#6998
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:
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:
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:
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:
"WIM Registry Tweak Tool.exe" /p "Directorio de montaje" /l

Ejemplo:
"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
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
Dism.exe /Get-Features /Image:"Directorio de montaje" /Format:Table

Ejemplo:
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:
"WIM Registry Tweak Tool.exe" /p "Directorio de montaje"

Ejemplo:
"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:
Dism.exe /Remove-Package /PackageName:"Nombre de la característica" /Imaage:"Directorio de montaje"

Ejemplo:
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:
Dism.exe /Image:"Directorio de montaje" /Disable-Feature /FeatureName:"Nombre de característica"

Ejemplo:
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:
Dism.exe /Unmount-Wim /Commit /MountDir:"Directorio de montaje"

Ejemplo:
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
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 (dos) [Seleccionar]
@Echo OFF



REM =================
REM Console Settings:
REM =================

Title WIM Package Uninstaller - By Elektro
Mode Con Cols=150 Lines=50
CHCP 1252 1>NUL & REM Windows-1252, Spanish-Latin.



REM =====
REM Info:
REM =====

Echo+
Echo  ----------------------------------------------------------------------------------
Echo  This script mounts a Windows Image ^(WIM^) and then removes pre-installed packages
Echo  ----------------------------------------------------------------------------------
Echo+



REM ====================
REM User defined values:
REM ====================

REM This value indicates whether the Windows Image should be mounted.
REM True  = 'DISM' will try to mount the 'WIM' image.
REM False = 'DISM' will not try to mount the WIM image.
REM Set this value to 'FALSE' if the 'WIM' image is already mounted in the specified mount directory,
REM Otherwise, keep it as 'TRUE'.
Set "MountImage=True"

REM This value indicates whether the Windows Image should be unmounted at the end.
REM True  = 'DISM' will try to unmount the 'WIM' image.
REM False = 'DISM' will not try to unmount the WIM image.
REM Set this value to 'FALSE' if you want to keep the image mounted to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "UnmountImage=True"

REM This value indicates whether the Windows Image should be rebuilt at the end.
REM True  = 'ImageX' will try to rebuild the 'WIM' image.
REM False = 'ImageX' will keep the 'WIM' image as is.
REM Set this value to 'FALSE' if you want to keep the image with normal size to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "Rebuild=True"

REM This value indicates the 'WIM' image to be mounted.
Set "WindowsImage=%UserProfile%\Desktop\win 8 .1\win\sources\install.wim"

REM This value indicates the Image Index of the 'WIM' image.
Set "ImageIndex=1"

REM This value indicates the directory where to mount the 'WIM' image.
Set "MountDir=%HomeDrive%\WinMount"

REM This value indicates the textfile that contains the names of the packages to remove.
Set "PackageList=%CD%\Packages.txt"

REM This value indicates the ubication of the 'WIM Registry Tweak Tool.exe' file.
Set "WIMRegistryTweakTool=%CD%\Tools\WIM Registry Tweak Tool\WIM Registry Tweak Tool.exe"

REM This value indicates the ubication of 'ImageX.exe' file.
Set "ImageX=%CD%\Tools\Dism\ImageX.exe"

REM This value indicates the ubication of a custom 'DISM.exe' file if needed.
REM Default ubication: "%SystemRoot%\System32\Dism.exe"
Set "Dism=%CD%\Tools\Dism\Dism.exe"

REM This value indicates the ubication of the logfile that will record 'DISM' errors.
Set "DismLogfile=%CD%\%~n0 DISM.log"

REM This value indicates the logging-level of the 'DISM' process.
REM 1 = Errors only
REM 2 = Errors and warnings
REM 3 = Errors, warnings, and informational
REM 4 = All of the information listed previously, plus debug output
Set /A "DismLogLevel=2"

REM This value indicates the ubication of the logfile that will record Main information.
Set "Logfile=%CD%\%~n0.log"



REM =====
REM Main:
REM =====

:: Call Methods.
Call :CheckErrors
Call :CreateLogs
Call :CreateMountDir
Call :GetWIMSizeBefore
Call :StartTimer
Call :Mount
CLS
Call :ParsePackages
CLS
Call :CleanUp
Call :Unmount
Call :Rebuild
Call :StopTimer
Call :GetWIMSizeAfter
Call :EndLog
Pause&Exit



REM ========
REM Methods:
REM ========


:CreateLogs

:: Create the 'DISM' logfile with 'ANSI' encoding,
:: this is necessary to record a non-default 'DISM' loglevel such as '1' or '2'.
Echo+ >"%DismLogfile%"


:: Create the Main logfile and record starting info on it.
Echo+ >"%Logfile%"
(
Echo+
Echo   WIM Package Uninstaller
Echo ===========================
Echo   %DATE% ^| %TIME:~0,-3%
Echo /\/\/\/\/\/\/\/\/\/\/\/\/\/
Echo+
Echo [i] Mount Image?...: %MountImage%
Echo [i] Unmount Image?.: %UnmountImage%
Echo+
Echo [i] Windows Image..: %WindowsImage%
Echo [i] Image Index....: %ImageIndex%
Echo [i] Mount Directory: %MountDir%
Echo+
Echo [i] ImageX Path....: %ImageX%
Echo [i] Dism Path......: %Dism%
Echo [i] Dism Log File..: %DismLogfile%
Echo [i] Dism Log Level.: %DismLogLevel%
Echo+
Echo [i] Package List...: %PackageList%
Echo [i] Log File.......: %Logfile%
Echo+
Echo ===========================
)>"%Logfile%"

:: Display starting log info.
Type "%Logfile%"

:: Continue writting log.
(
Echo+
Echo Package conflicts:
Echo ==================
Echo+
)>>"%LogFile%"
Goto:EOF


:EndLog
(
Echo+
Echo [i] Done!
Echo [i] WIM Image Size Before........: %WIMSizeBefore%
Echo [i] WIM Image Size After.........: %WIMSizeAfter%
Echo [i] Packages Successfully Removed: %PackagesRemovedCount% Packages.
Echo [i] Packages Failed To Remove....: %PackagesFailedCount% Packages.
Echo [i] Packages Not Found...........: %PackagesNotFoundCount% Packages.
Echo [i] Elapsed Time.................: %ElapsedTime%
Echo+
)>>"%LogFile%"

:: Display ending information.
CLS
Type "%LogFile%"
Goto:EOF


:CreateMountDir
:: Create the mount directory.
(
If Not Exist "%MountDir%" If /I "%MountImage%" EQU "True" (
MkDir "%MountDir%" 2>NUL
)
) || (
Echo+
Echo [x] Error trying to create the directory "%MountDir%" to mount the Windows Image.
Echo [i] Ensure that you have Admin rights to create the directory.
Echo [i] Ensure that the directory name does not contains illegal characters.
Echo+
Pause&Exit
)
Goto:EOF


:Mount
:: Mount the Windows Image into the directory.
Echo+
Echo [+] Mounting WIM Image...
If /I "%MountImage%" EQU "True" (

"%Dism%" /Mount-Image /ImageFile:"%WindowsImage%" /Index:"%ImageIndex%" /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" || (
Echo+
Echo [x] Error mounting the Image Index "%ImageIndex%" in "%MountDir%"
Echo [i] Ensure that the Image Index exist.
Echo [i] Ensure that you have Admin rights to write inside the directory.
Echo [i] Ensure that the directory is not already mounted.
Echo [i] Ensure that the directory is fully empty.
Echo+
REM Try to unmount the failed image and discard changes.
If /I "%UnmountImage%" EQU "True" (
Echo [+] Unmounting and discarding changes...
"%Dism%" /Unmount-WIM /Discard /MountDir:"%MountDir%"
)
Pause&Exit
)

)
Goto:EOF


:CleanUp
Echo [+] CleaningUp WIM Image...
"%Dism%" /CleanUp-Image /StartComponentCleanUp /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet
Echo+
Goto:EOF


:Unmount
:: Unmount the Windows Image commiting changes.
Echo [+] Unmounting WIM Image...
If /I "%UnmountImage%" EQU "True" (
"%Dism%" /Unmount-WIM /Commit /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%"
)
Goto:EOF


:Rebuild
If /I "%Rebuild%" EQU "False" (Goto:EOF)

Echo+
Echo [+] Rebuilding WIM image...

("%ImageX%" /Compress Maximum /Export "%WindowsImage%" "*" "%TEMP%\Rebuilt Image.wim" /Check) && (
Del /Q /F "%WindowsImage%" 1>NUL
Move /Y "%TEMP%\Rebuilt Image.wim" "%WindowsImage%" 1>NUL
) || (
Echo [x] Error rebuilding Image "%WindowsImage%" to "%TEMP%\Rebuilt Image.wim".
)

Goto :EOF


:StartTimer
Set "StartingDate=%Date%"
Set "StarttingTime=%Time:~0,-3%"
Goto :EOF


:StopTimer
(
Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
Echo WScript.Echo Minutes ^& " Minutes"
)>"%TEMP%\%~n0 MinuteDiff.vbs"

For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
) Do (
Set "ElapsedTime=%%#"
)

Goto:EOF


:WriteConvertBytesScript
If Exist "%TEMP%\%~n0 Convert Bytes.vbs" (Goto:EOF)
(
Echo Suffix = Array^("Bytes", "KB", "MB", "GB", "TB"^)
Echo+
Echo Function Convert^(Bytes^)
Echo Convert = convert0^(Bytes, 0^)
Echo End Function
Echo+
Echo Function Convert0^(Bytes, Level^)
Echo If Bytes ^>= 1024 Then
Echo Bytes = Round^(Bytes / 1024, 2^)
Echo Level = Level + 1
Echo Convert0 = Convert0^(Bytes, Level^)
Echo End If
Echo Convert0 = Bytes ^& " " ^& Suffix^(Level^)
Echo End Function
Echo+
Echo WScript.Echo Convert^(WScript.Arguments^(0^)^)
)>"%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF


:GetWIMSizeBefore
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeBefore=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeBefore%"'
) Do (
Set "WIMSizeBefore=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF


:GetWIMSizeAfter
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeAfter=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeAfter%"'
) Do (
Set "WIMSizeAfter=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF


:ParsePackages

Set /A "PackagesRemovedCount=0"
Set /A "PackagesFailedCount=0"
Set /A "PackagesNotFoundCount=0"

:: Unhide packages and take registry ownership.
"%WIMRegistryTweakTool%" /p "%MountDir%"
Echo+

:: Remove Packages.
For /F "UseBackQ Tokens=* Delims=" %%# In ("%PackageList%") Do (

Echo [+] Removing package: %%~#

"%Dism%" /Remove-Package /PackageName:"%%~#" /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet 1>NUL
   Call Set /A "ExitCode=%%Errorlevel%%"

   (Call Echo "%%ExitCode%%"| Findstr.exe "^\"0\"$" 1>NUL 2>&1) && (
    Call Set /A "PackagesRemovedCount+=1"
   )

(Call Echo "%%ExitCode%%"| Findstr.exe "^\"5\"$" 1>NUL 2>&1) && (
Call Set /A "PackagesFailedCount+=1"
Echo Failed to remove package: %%~#>>"%LogFile%"
)

(Call Echo "%%ExitCode%%"| Find.exe "-2146498555" 1>NUL 2>&1) && (
Call Set /A "PackagesNotFoundCount+=1"
Echo Package is not installed: %%~#>>"%LogFile%"
)

)
Goto:EOF



REM ====================
REM File Error Controls:
REM ====================

:CheckErrors
:: WIM File Error-Check.
If /I "MountImage" EQU "True" If Not Exist "%WindowsImage%" (
Echo [x] Windows Image not found at: "%WindowsImage%" | MORE
Pause&Exit
)

:: PackageList File Error-Check.
If Not Exist "%PackageList%" (
Echo [x] PackageList not found at: "%PackageList%" | MORE
Pause&Exit
)

:: 'DISM.exe' File Error-Check.
If Not Exist "%DISM%" (
Echo [x] 'DISM' process not found at: "%DISM%" | MORE
Pause&Exit
)

:: 'ImageX.exe' File Error-Check.
If Not Exist "%ImageX%" (
Echo [x] 'ImageX' process not found at: "%ImageX%" | MORE
Pause&Exit
)

:: 'WIM Registry Tweak Tool.exe' File Error-Check.
If Not Exist "%WIMRegistryTweakTool%" (
Echo [x] 'WIM Registry Tweak Tool' process not found at: "%WIMRegistryTweakTool%" | MORE
Pause&Exit
)


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
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 (dos) [Seleccionar]
@Echo OFF



REM =================
REM Console Settings:
REM =================

Title WIM Feature Uninstaller - By Elektro
Mode Con Cols=150 Lines=50
CHCP 1252 1>NUL & REM Windows-1252, Spanish-Latin.



REM =====
REM Info:
REM =====

Echo+
Echo  -----------------------------------------------------------------------------
Echo  This script mounts a Windows Image ^(WIM^) and then disables Windows features
Echo  -----------------------------------------------------------------------------
Echo+



REM ====================
REM User defined values:
REM ====================

REM This value indicates whether the Windows Image should be mounted.
REM True  = 'DISM' will try to mount the 'WIM' image.
REM False = 'DISM' will not try to mount the WIM image.
REM Set this value to 'FALSE' if the 'WIM' image is already mounted in the specified mount directory,
REM Otherwise, keep it as 'TRUE'.
Set "MountImage=True"

REM This value indicates whether the Windows Image should be unmounted at the end.
REM True  = 'DISM' will try to unmount the 'WIM' image.
REM False = 'DISM' will not try to unmount the WIM image.
REM Set this value to 'FALSE' if you want to keep the image mounted to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "UnmountImage=True"

REM This value indicates whether the Windows Image should be rebuilt at the end.
REM True  = 'ImageX' will try to rebuild the 'WIM' image.
REM False = 'ImageX' will keep the 'WIM' image as is.
REM Set this value to 'FALSE' if you want to keep the image with normal size to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "Rebuild=True"

REM This value indicates the 'WIM' image to be mounted.
Set "WindowsImage=%UserProfile%\Desktop\win 8 .1\win\sources\install.wim"

REM This value indicates the Image Index of the 'WIM' image.
Set "ImageIndex=1"

REM This value indicates the directory where to mount the 'WIM' image.
Set "MountDir=%HomeDrive%\WinMount"

REM This value indicates the textfile that contains the names of the features to disable.
Set "FeatureList=%CD%\Features.txt"

REM This value indicates the ubication of 'ImageX.exe' file.
Set "ImageX=%CD%\Tools\Dism\ImageX.exe"

REM This value indicates the ubication of a custom 'DISM.exe' file if needed.
REM Default ubication: "%SystemRoot%\System32\Dism.exe"
Set "Dism=%CD%\Tools\Dism\Dism.exe"

REM This value indicates the ubication of the logfile that will record 'DISM' errors.
Set "DismLogfile=%CD%\%~n0 DISM.log"

REM This value indicates the logging-level of the 'DISM' process.
REM 1 = Errors only
REM 2 = Errors and warnings
REM 3 = Errors, warnings, and informational
REM 4 = All of the information listed previously, plus debug output
Set /A "DismLogLevel=2"

REM This value indicates the ubication of the logfile that will record Main information.
Set "Logfile=%CD%\%~n0.log"



REM =====
REM Main:
REM =====

:: Call Methods.
Call :CheckErrors
Call :CreateLogs
Call :CreateMountDir
Call :GetWIMSizeBefore
Call :StartTimer
Call :Mount
CLS
Call :ParseFeatures
CLS
Call :CleanUp
Call :Unmount
Call :Rebuild
Call :StopTimer
Call :GetWIMSizeAfter
Call :EndLog
Pause&Exit



REM ========
REM Methods:
REM ========


:CreateLogs

:: Create the 'DISM' logfile with 'ANSI' encoding,
:: this is necessary to record a non-default 'DISM' loglevel such as '1' or '2'.
Echo+ >"%DismLogfile%"


:: Create the Main logfile and record starting info on it.
Echo+ >"%Logfile%"
(
Echo+
Echo   WIM Feature Uninstaller
Echo ===========================
Echo   %DATE% ^| %TIME:~0,-3%
Echo /\/\/\/\/\/\/\/\/\/\/\/\/\/
Echo+
Echo [i] Mount Image?...: %MountImage%
Echo [i] Unmount Image?.: %UnmountImage%
Echo+
Echo [i] Windows Image..: %WindowsImage%
Echo [i] Image Index....: %ImageIndex%
Echo [i] Mount Directory: %MountDir%
Echo+
Echo [i] Dism Path......: %Dism%
Echo [i] Dism Log File..: %DismLogfile%
Echo [i] Dism Log Level.: %DismLogLevel%
Echo+
Echo [i] Feature List...: %FeatureList%
Echo [i] Log File.......: %Logfile%
Echo+
Echo ===========================
)>"%Logfile%"

:: Display starting log info.
Type "%Logfile%"

:: Continue writting log.
(
Echo+
Echo Feature conflicts:
Echo ==================
Echo+
)>>"%LogFile%"
Goto:EOF


:EndLog
(
Echo+
Echo [i] Done!
Echo [i] WIM Image Size Before.........: %WIMSizeBefore%
Echo [i] WIM Image Size After..........: %WIMSizeAfter%
Echo [i] Features Successfully Disabled: %FeaturesRemovedCount% Packages.
Echo [i] Features Failed To Disable....: %FeaturesFailedCount% Packages.
Echo [i] Features Not Found............: %FeaturesNotFoundCount% Packages.
Echo [i] Elapsed Time..................: %ElapsedTime%
Echo+
)>>"%LogFile%"

:: Display ending information.
CLS
Type "%LogFile%"
Goto:EOF


:CreateMountDir
:: Create the mount directory.
(
If Not Exist "%MountDir%" If /I "%MountImage%" EQU "True" (
MkDir "%MountDir%" 2>NUL
)
) || (
Echo+
Echo [x] Error trying to create the directory "%MountDir%" to mount the Windows Image.
Echo [i] Ensure that you have Admin rights to create the directory.
Echo [i] Ensure that the directory name does not contains illegal characters.
Echo+
Pause&Exit
)
Goto:EOF


:Mount
:: Mount the Windows Image into the directory.
Echo+
Echo [+] Mounting WIM Image...
If /I "%MountImage%" EQU "True" (

"%Dism%" /Mount-Image /ImageFile:"%WindowsImage%" /Index:"%ImageIndex%" /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" || (
Echo+
Echo [x] Error mounting the Image Index "%ImageIndex%" in "%MountDir%"
Echo [i] Ensure that the Image Index exist.
Echo [i] Ensure that you have Admin rights to write inside the directory.
Echo [i] Ensure that the directory is not already mounted.
Echo [i] Ensure that the directory is fully empty.
Echo+
REM Try to unmount the failed image and discard changes.
If /I "%UnmountImage%" EQU "True" (
Echo [+] Unmounting and discarding changes...
"%Dism%" /Unmount-WIM /Discard /MountDir:"%MountDir%"
)
Pause&Exit
)

)
Goto:EOF


:CleanUp
Echo [+] CleaningUp WIM Image...
"%Dism%" /CleanUp-Image /StartComponentCleanUp /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet
Echo+
Goto:EOF


:Unmount
:: Unmount the Windows Image commiting changes.
Echo [+] Unmounting WIM Image...
If /I "%UnmountImage%" EQU "True" (
"%Dism%" /Unmount-WIM /Commit /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%"
)
Goto:EOF


:Rebuild
If /I "%Rebuild%" EQU "False" (Goto:EOF)

Echo+
Echo [+] Rebuilding WIM image...

("%ImageX%" /Compress Maximum /Export "%WindowsImage%" "*" "%TEMP%\Rebuilt Image.wim" /Check) && (
Del /Q /F "%WindowsImage%" 1>NUL
Move /Y "%TEMP%\Rebuilt Image.wim" "%WindowsImage%" 1>NUL
) || (
Echo [x] Error rebuilding Image "%WindowsImage%" to "%TEMP%\Rebuilt Image.wim".
)

Goto :EOF


:StartTimer
Set "StartingDate=%Date%"
Set "StarttingTime=%Time:~0,-3%"
Goto :EOF


:StopTimer
(
Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
Echo WScript.Echo Minutes ^& " Minutes"
)>"%TEMP%\%~n0 MinuteDiff.vbs"

For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
) Do (
Set "ElapsedTime=%%#"
)

Goto:EOF


:WriteConvertBytesScript
If Exist "%TEMP%\%~n0 Convert Bytes.vbs" (Goto:EOF)
(
Echo Suffix = Array^("Bytes", "KB", "MB", "GB", "TB"^)
Echo+
Echo Function Convert^(Bytes^)
Echo Convert = convert0^(Bytes, 0^)
Echo End Function
Echo+
Echo Function Convert0^(Bytes, Level^)
Echo If Bytes ^>= 1024 Then
Echo Bytes = Round^(Bytes / 1024, 2^)
Echo Level = Level + 1
Echo Convert0 = Convert0^(Bytes, Level^)
Echo End If
Echo Convert0 = Bytes ^& " " ^& Suffix^(Level^)
Echo End Function
Echo+
Echo WScript.Echo Convert^(WScript.Arguments^(0^)^)
)>"%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF


:GetWIMSizeBefore
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeBefore=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeBefore%"'
) Do (
Set "WIMSizeBefore=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF


:GetWIMSizeAfter
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeAfter=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeAfter%"'
) Do (
Set "WIMSizeAfter=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF


:ParseFeatures

Set /A "FeaturesRemovedCount=0"
Set /A "FeaturesFailedCount=0"
Set /A "FeaturesNotFoundCount=0"

:: Disable Features.
For /F "UseBackQ Tokens=* Delims=" %%# In ("%FeatureList%") Do (

Echo [+] Disabling Feature: %%~#

"%Dism%" /Disable-Feature /FeatureName:"%%~#" /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet 1>NUL
   Call Set /A "ExitCode=%%Errorlevel%%"

   (Call Echo "%%ExitCode%%"| Findstr.exe "^\"0\"$" 1>NUL 2>&1) && (
    Call Set /A "FeaturesRemovedCount+=1"
   )

(Call Echo "%%ExitCode%%"| Findstr.exe "^\"5\"$" 1>NUL 2>&1) && (
Call Set /A "FeaturesFailedCount+=1"
Echo Failed to disable feature: %%~#>>"%LogFile%"
)

(Call Echo "%%ExitCode%%"| Find.exe "-2146498548" 1>NUL 2>&1) && (
Call Set /A "FeaturesNotFoundCount+=1"
Echo Feature is not found.....: %%~#>>"%LogFile%"
)

)
Goto:EOF



REM ====================
REM File Error Controls:
REM ====================

:CheckErrors

:: WIM File Error-Check.
If /I "MountImage" EQU "True" If Not Exist "%WindowsImage%" (
Echo [x] Windows Image not found at: "%WindowsImage%" | MORE
Pause&Exit
)

:: FeatureList File Error-Check.
If Not Exist "%FeatureList%" (
Echo [x] FeatureList not found at: "%FeatureList%" | MORE
Pause&Exit
)

:: 'DISM.exe' File Error-Check.
If Not Exist "%DISM%" (
Echo [x] 'DISM' process not found at: "%DISM%" | MORE
Pause&Exit
)

:: 'ImageX.exe' File Error-Check.
If Not Exist "%ImageX%" (
Echo [x] 'ImageX' process not found at: "%ImageX%" | MORE
Pause&Exit
)

Goto:EOF
#6999
Scripting / Re: [APORTE] [BATCH] Folders2List
12 Abril 2014, 15:04 PM
Cita de: Trebla1011 en 12 Abril 2014, 10:24 AMPero, ¿A que viene la función del tiempo? xD

Es un simple capricho, la verdad es que el script trabaja rápido pero aun así me gusta saber cuanto tarda, estoy acostumbrado a medir el tiempo de ejecución en la programación .NET para optimizar los procedimientos que den señales de conflictos en el tiempo de ejecución.

PD: Gracias por comentar.

Saludos!
#7000
Scripting / [APORTE] [BATCH] Folders2List
12 Abril 2014, 00:31 AM
Hola

Este Script es el hermano de este otro Script, genera un archivo de texto que contiene la lista de estructura de carpetas del directorio de trabajo y de sus subdirectorios, el directorio de trabajo se puede modificar en las variables del Script, y la lista de capetas se registra usando la ruta relativa de los archivos de dicho directorio de trabajo.

El Script tiene 2 métodos de listar las carpetas, que son: 1. Listado normal, y 2. Listado incluyendo carpetas ocultas.
El Script tiene la funcionalidad de medir el tiempo transcurrido de la operación.

Todo lo que he mencionado se puede configurar en las variables que están documentadas con comentarios de ayuda en el código.

· Una imagen de muestra:


· El código:

Folders2List.cmd
Código (dos) [Seleccionar]
@Echo OFF



REM =================
REM Console Settings:
REM =================

Title Folders2List - By Elektro
Mode Con Cols=150 Lines=50
CHCP 1252 1>NUL & REM Windows-1252, Spanish-Latin.



REM =====
REM Info:
REM =====

Echo+
Echo  ------------------------------------------------------------------------------------------------------------------------------------
Echo  This script writes a textfile containing the relative paths of the folder structure at the working directory and it's subdirectories
Echo  ------------------------------------------------------------------------------------------------------------------------------------
Echo+



REM ====================
REM User defined values:
REM ====================

REM This value indicates the directory where to list it's folder structure.
Set "WorkingDir=%CD%"

REM This value indicates the resulting folder list.
Set "OutputFile=%CD%\Folders.txt"

REM This value indicates how the hidden folders are threated when listing the folder structure.
REM  True = List folders and also folders with the 'hidden' attribute.
REM False = List only normal folders without the 'hidden' attribute.
Set "IncludeHiddenFolders=True"



REM =====
REM Main:
REM =====

:: Display starting info.
Echo [i] Working Directory...: %WorkingDir%
Echo [i] Output file.........: %OutputFile%
Echo [i] Include Hidden Files: %IncludeHiddenFolders%
Echo+

:: Call Methods.
Call :CheckErrors
Call :StartTimer
Call :ListFolders "%IncludeHiddenFolders%"
Call :StopTimer

:: Finish.
Echo [i] Done!           | MORE
Echo [i] Listed Folders: %FolderCount% folders.
Echo [i] Elapsed Time..: %ElapsedTime%
Echo+
Pause&Exit



REM ========
REM Methods:
REM ========

:StartTimer
Set "StartingDate=%Date%"
Set "StarttingTime=%Time:~0,-3%"
Goto :EOF


:StopTimer
(
Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
Echo WScript.Echo Minutes ^& " Minutes"
)>"%TEMP%\%~n0 MinuteDiff.vbs"

For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
) Do (
Set "ElapsedTime=%%#"
)

Goto:EOF


:ListFolders
Echo [+] Collecting folders, this operation could take some minutes long, please wait...
If /I "%~1" EQU "True"  (Call :ListHiddenFolders)
If /I "%~1" EQU "False" (Call :ListNormalFolders)
Goto:EOF


:ListNormalFolders
(FOR /D /R "%WorkingDir%" %%# in ("*") DO (
Set "Folder=%%~f#"
Call Echo %%Folder:%WorkingDir%=.%%
Set /A "FolderCount+=1"
))>"%OutputFile%"
Goto:EOF


:ListHiddenFolders
(FOR /F "Tokens=* Delims=" %%# in ('Dir /B /S /AD "%WorkingDir%\*"') DO (
Set "Folder=%%~f#"
Call Echo %%Folder:%WorkingDir%=.%%
Set /A "FolderCount+=1"
))>"%OutputFile%"
Goto:EOF



REM ===============
REM Error Controls:
REM ===============

:CheckErrors
:: 'IncludeHiddenFolders' Value check.
If /I "%IncludeHiddenFolders%" NEQ "True" If /I "%IncludeHiddenFolders%" NEQ "False" (
Echo [x] Error parsing parameter 'IncludeHiddenFolders',
Echo     value '%IncludeHiddenFolders%' is not a Boolean value.
Pause&Exit
)

Goto:EOF