当前位置:网站首页>Dism command usage summary

Dism command usage summary

2022-06-11 05:40:00 zhmhbest

DISM Command use summary

operation WIM Mirror image

explain

REM  Make a mirror and add a volume 
dism /capture-image /imagefile:<WIM Image path > /captureDir:< Backup directory > /name:< Sub volume name > [/description:< Sub volume description >]

REM  Add a subvolume to the image 
dism /append-image /imagefile:<WIM Image path > /captureDir:< Backup directory > /name:< Sub volume name > [/description:< Sub volume description >]

REM  Delete a subvolume in the mirror ( It is possible to modify the indexes of all subvolumes )
dism /delete-image /imagefile:<WIM Image path > /Index:< Volume index >

REM  Export a subvolume from the image to become a new image 
dism /export-image /sourceimageFile:< Source WIM Image path > /sourceindex:< Volume index > /destinationimagefile:< new WIM Image path >

REM  View the mirror volume information 
dism /get-imageinfo /imagefile:<WIM Image path >

REM  View the file contents of a mirrored volume 
dism /list-image /imagefile:<WIM Image path > /index:< Volume index >

REM  Mount the image 
dism /mount-wim /wimfile:<WIM Image path > /index:< Volume index > /mountdir:< Mount Directory > [/readonly]

REM  Unmount the image and discard the changes 
dism /unmount-wim /mountdir:< Mount Directory > /discard
REM  Unload the image and save the changes 
dism /unmount-wim /mountdir:< Mount Directory > /commit

REM  Use the image to restore the directory 
dism /apply-image /imagefile:<WIM Image path > /index:< Volume index > /applydir:< Restore directory >

demonstration

REM  Run as administrator CMD
MKDIR "%Temp%\DismDemo" 2>NUL
PUSHD "%Temp%\DismDemo"
MKDIR package
MKDIR mounted

REM  Create... For the first time 
ECHO first>package\test.txt
dism /capture-image /imagefile:test.wim /captureDir:package /name:1st /description: for the first time >NUL

REM  Add image 
ECHO second>package\test.txt
dism /append-image /imagefile:test.wim /captureDir:package /name:2nd /description: The second time >NUL
ECHO third>package\test.txt
dism /append-image /imagefile:test.wim /captureDir:package /name:3rd /description: third time >NUL

REM  View the volume file 
dism /list-image /imagefile:test.wim /index:1

REM  View mirrored volumes 
dism /get-imageinfo /imagefile:test.wim

REM  Mount the image and view the recorded contents 
dism /mount-wim /wimfile:test.wim /index:1 /mountdir:mounted /readonly>NUL
type mounted\test.txt
dism /unmount-wim /mountdir:mounted /discard>NUL

REM  Use the image to restore the directory 
type package\test.txt
dism /apply-image /imagefile:test.wim /index:2 /applydir:package>NUL
type package\test.txt

REM  Mount the image and modify the contents of the record 
dism /mount-wim /wimfile:test.wim /index:2 /mountdir:mounted>NUL
ECHO second changed>mounted\test.txt
dism /unmount-wim /mountdir:mounted /commit>NUL
dism /mount-wim /wimfile:test.wim /index:2 /mountdir:mounted /readonly>NUL
type mounted\test.txt
dism /unmount-wim /mountdir:mounted /discard>NUL

REM  Delete a subvolume 
dism /delete-image /imagefile:test.wim /Index:1>NUL
dism /get-imageinfo /imagefile:test.wim

REM  Export a subvolume 
dism /export-image /sourceimageFile:test.wim /sourceindex:1 /destinationimagefile:new.wim>NUL
dism /get-imageinfo /imagefile:new.wim

POPD
RMDIR /S /Q "%Temp%\DismDemo"

Mount a file with the same name .wim

@ECHO OFF
MKDIR %SystemRoot%\testauth 2>nul && RMDIR %SystemRoot%\testauth || echo "Please run as administrator!" && PAUSE && GOTO :EOF
ECHO mounting...
CD /d %~dp0
SET MYNAME=%~n0
IF NOT EXIST %MYNAME%.wim GOTO :EOF
IF EXIST %MYNAME% (
    DISM /unmount-wim /mountdir:"%MYNAME%" /discard
    RMDIR %MYNAME%
) ELSE (
    MKDIR %MYNAME%
    DISM /mount-wim /wimfile:"%MYNAME%.wim" /mountdir:"%MYNAME%" /index:1 /readonly
)

Operating system image

explain

REM  Target a running operating system  |  Specify the root directory path of the offline image 
dism { /online | /image:< The address to which the image is mounted > } ...

REM  Scan for component storage corruption in the image 
dism /online /cleanup-image { /checkhealth | /scanhealth | /restorehealth }

REM  Get the current system driver list 
dism /online /get-drivers

REM  Get the list of current system functions 
dism /online /get-features /format:table

REM  Enable current system functions 
dism /online enable-feature /featurename:< The name of the function > /all

Add functionality

DIR /b %SystemRoot%\servicing\Packages

Enable local policy

If it cannot be started gpedit.msc, Then run a command window as an administrator , Enter the following :

@ECHO OFF
SET PACKAGES_LOCATION=%SystemRoot%\servicing\Packages
SET ENABLE_LIST="%Temp%\PACKAGES%RANDOM%%RANDOM%.txt"
REM ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
DIR /b %PACKAGES_LOCATION%\Microsoft-Windows-GroupPolicy-ClientExtensions-Package~3*.mum>%ENABLE_LIST%
DIR /b %PACKAGES_LOCATION%\Microsoft-Windows-GroupPolicy-ClientTools-Package~3*.mum>>%ENABLE_LIST%
REM ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
FOR /F %i in ('FINDSTR /I . %ENABLE_LIST% 2^>NUL') DO (
    echo %i
    dism /online /norestart /add-package:"%PACKAGES_LOCATION%\%i">NUL
)
DEL /F /Q %ENABLE_LIST%
ECHO Done!

Enable Hyper-V

dism /online /get-features /format:table | findstr /i Hyper-V

@ECHO OFF
SET PACKAGES_LOCATION=%SystemRoot%\servicing\Packages
SET ENABLE_LIST="%Temp%\PACKAGES%RANDOM%%RANDOM%.txt"
REM ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
DIR /b %PACKAGES_LOCATION%\Microsoft-Hyper-V-*.mum>%ENABLE_LIST%
REM ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
FOR /F %i in ('FINDSTR /I . %ENABLE_LIST% 2^>NUL') DO (
    echo %i
    dism /online /norestart /add-package:"%PACKAGES_LOCATION%\%i">NUL
)
DEL /F /Q %ENABLE_LIST%
dism /online /norestart /enable-feature /featurename:Microsoft-Hyper-V-All /all
ECHO Done!
原网站

版权声明
本文为[zhmhbest]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110538163966.html