Location:
State:
Carrier
Country
Status

Dism /Apply-Image and remove the entire content of the directory


Hi

I installed Windows ADK 10 v1511 on Windows 10 v1511 Enterprise 64 bit.

I typed the following commands:

Code:
Dism /Apply-Image /ImageFile:"<wim_File_Path>install.wim" /Index:1 /ApplyDir:"<Apply_Directory_Path>" /Verify /CheckIntegrity Dism /Capture-Image /ImageFile:"<Windows_Files_Path>sourcesinstall.wim" /CaptureDir:"<Apply_Directory_Path>" /Name:"<Edition_name>" /Description:"<Description_name>" /Compress:max /Verify /CheckIntegrity
Now, what is the command that allows to completely remove the entire content of the <Apply_Directory_Path> directory?

Thanks

Bye

Do you mean you want to delete everything in the directory but leave the directory itself?

If so this should do it
Code:
pushd "<Apply_Directory_Path>" && (rd /s /q "<Apply_Directory_Path>" 2>nul & popd)

Do you mean you want to delete everything in the directory but leave the directory itself?

If so this should do it
Code:
pushd "<Apply_Directory_Path>" && (rd /s /q "<Apply_Directory_Path>" 2>nul & popd)
I already tried and this command does not work because the files and directories owner is the System or TrustedInstaller user.

I noticed that the <Apply_Directory_Path> directory has also changed owner and now it has, as owner, TrustedInstaller user. Why?

Thanks

Bye

You can try to take ownership with
Code:
takeown  /f  "<Apply_Directory_Path>" /r icacls       "<Apply_Directory_Path>" /grant "%USERDOMAIN%\%USERNAME%":(F) /t
and then delete the contents.

You applied the install.wim to the directory... Thus by applying the install.wim - you installed windows (trusted installer)....

You can try to take ownership with
Code:
takeown  /f  "<Apply_Directory_Path>" /r icacls "<Apply_Directory_Path>" /grant "%USERDOMAIN%\%USERNAME%":(F) /t
and then delete the contents.
Unfortunately, in the <Apply_Directory_Path> directory, there are also some read-only subdirectories.

So, how do I change the icacls command to also remove the read-only attribute to delete also these subdirectories?

Thanks

Bye

I await a reply.

Thanks

Bye

acl - How to remove read-only attribute recursively on Windows 7 - Super User

acl - How to remove read-only attribute recursively on Windows 7 - Super User
If I write:

Code:
takeown  /f  "<Apply_Directory_Path>" /r icacls "<Apply_Directory_Path>" /grant "%USERDOMAIN%\%USERNAME%":(F,WDAC) /t
I reach the same my purpose?

Thanks

Bye

In conclusion, if I use the following commands

Code:
takeown /f "<Apply_Directory_Path>" /R /A /D Y icacls "<Apply_Directory_Path>" /grant administrators:(F,WDAC) /t pushd "<Apply_Directory_Path>" && (rd /s /q "<Apply_Directory_Path>" 2>nul & popd)
I would reach my initial goal?

Thanks

Bye

Dism /Apply-Image and remove the entire content of the directory