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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
balubeto
Posts: 136
Joined: 08 Dec 2011 12:14

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

#1 Post by balubeto » 10 Jan 2016 03:23

Hi

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

I typed the following commands:

Code: Select all

Dism /Apply-Image /ImageFile:"<wim_File_Path>\install.wim" /Index:1 /ApplyDir:"<Apply_Directory_Path>" /Verify /CheckIntegrity
Dism /Capture-Image /ImageFile:"<Windows_Files_Path>\sources\install.wim" /CaptureDir:"<Apply_Directory_Path>" /Name:"<Edition_name>" /Description:"<Description_name>" /Compress:max /Verify /CheckIntegrity


Now, knowing that some directories and files have the TrustedInstaller or System user as owner, what are the commands that allows to completely remove the entire content of the <Apply_Directory_Path> directory?

Thanks

Bye

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

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

#2 Post by foxidrive » 10 Jan 2016 10:26

Do you want to script this, or just remove the folders?

balubeto
Posts: 136
Joined: 08 Dec 2011 12:14

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

#3 Post by balubeto » 10 Jan 2016 11:12

foxidrive wrote:Do you want to script this, or just remove the folders?


I would like to remove the entire contents of the Apply_Directory_Path directory.

I tried these commands

Code: Select all

takeown /F "<Apply_Directory_Path>\*" /R /A /D S

icacls "<Apply_Directory_Path>\*.*" /T /grant administrators:F

pushd "<Apply_Directory_Path>" && ( rd /S /Q "<Apply_Directory_Path>" 2>nul & popd )


but some subdirectories with their files are not deleted. Why?

Thanks

Bye

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

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

#4 Post by foxidrive » 11 Jan 2016 15:34

balubeto wrote:
foxidrive wrote:Do you want to script this, or just remove the folders?


I would like to remove the entire contents of the Apply_Directory_Path directory.

It's still not clear if it's something you need a script to do. The task can be done manually very easily.

Some locations are very difficult to gain access too in modern Windows.

balubeto
Posts: 136
Joined: 08 Dec 2011 12:14

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

#5 Post by balubeto » 12 Jan 2016 04:21

foxidrive wrote:
balubeto wrote:
foxidrive wrote:Do you want to script this, or just remove the folders?


I would like to remove the entire contents of the Apply_Directory_Path directory.

It's still not clear if it's something you need a script to do. The task can be done manually very easily.

Some locations are very difficult to gain access too in modern Windows.


I tried these commands

Code: Select all

takeown /F "<Apply_Directory_Path>\*" /R /A /D Y >nul 2>&1

icacls "<Apply_Directory_Path>\*.*" /T /grant administrators:F /T /Q

pushd "<Apply_Directory_Path>" && ( rd /S /Q "<Apply_Directory_Path>" 2>nul & popd )


but some subdirectories with their files are not deleted.

I also tried to restart Windows and repeat this sequence but those subdirectories are not yet eliminated. Why?

Thanks

Bye

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

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

#6 Post by foxidrive » 12 Jan 2016 04:30

balubeto wrote:but some subdirectories with their files are not deleted.


I'm just reminding you that I asked the same question twice, and am still waiting for an answer. :wink:

balubeto
Posts: 136
Joined: 08 Dec 2011 12:14

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

#7 Post by balubeto » 12 Jan 2016 05:02

foxidrive wrote:
balubeto wrote:but some subdirectories with their files are not deleted.


I'm just reminding you that I asked the same question twice, and am still waiting for an answer. :wink:


The sequence of my command is like a dos script (bat file). Right?

This sequence is performed from a "Command Prompt" window run as administrator.

Thanks

Bye

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

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

#8 Post by foxidrive » 13 Jan 2016 04:55

balubeto wrote:The sequence of my command is like a dos script (bat file). Right?

This sequence is performed from a "Command Prompt" window run as administrator.


My question was not about if it was run as administrator.

I have a solution if you are trying to do this on one computer, but not a script solution.

balubeto
Posts: 136
Joined: 08 Dec 2011 12:14

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

#9 Post by balubeto » 13 Jan 2016 05:16

foxidrive wrote:
balubeto wrote:The sequence of my command is like a dos script (bat file). Right?

This sequence is performed from a "Command Prompt" window run as administrator.


My question was not about if it was run as administrator.

I have a solution if you are trying to do this on one computer, but not a script solution.


I also hidden and system files in this structure.

I also have a subdirectory structure that I can not see its owner, and when I try to open it, File Explorer request the sysadmin authorization although I am logged on with an Administrators account. Why?

How do I prevent this? Using the Command Prompt, how do I become owner of this subdirectory structure with complete control over it so that I can also delete it?

So, what is your solution?

Thanks

Bye

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

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

#10 Post by foxidrive » 13 Jan 2016 05:31

balubeto wrote:How do I prevent this? Using the Command Prompt, how do I become owner of this subdirectory structure with complete control over it so that I can also delete it?


In the spirit of conversation, the why is because Administrator does not have full permissions as it did in older versions of Windows, and the how...

Google will show you, and if you reveal which folders you are processing then people will help you by searching also.

balubeto
Posts: 136
Joined: 08 Dec 2011 12:14

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

#11 Post by balubeto » 13 Jan 2016 05:42

foxidrive wrote:
balubeto wrote:How do I prevent this? Using the Command Prompt, how do I become owner of this subdirectory structure with complete control over it so that I can also delete it?


In the spirit of conversation, the why is because Administrator does not have full permissions as it did in older versions of Windows, and the how...

Google will show you, and if you reveal which folders you are processing then people will help you by searching also.


So, how can I do to remove this directory structure?

Thanks

Bye

balubeto
Posts: 136
Joined: 08 Dec 2011 12:14

takeown problem

#12 Post by balubeto » 16 Jan 2016 11:44

Hi

I have Windows 10 v1511 Enterprise 64 bit with two Microsoft account.

From the Command Prompt (run as administrator), I tried to write

Code: Select all

 takeown /S localhost /U "<Microsoft_account_(E-Mail_Address)>" /P <User_password>" /F "<Directory_path>" /R /A /D Y
 


but I get the "Access Denied" error. Why?

Thanks

Bye

balubeto
Posts: 136
Joined: 08 Dec 2011 12:14

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

#13 Post by balubeto » 17 Jan 2016 04:24

If I write the net user command, the profile names of the Microsoft accounts are displayed.

If, however, I write

Code: Select all

takeown /S localhost /U "<Account_profile_name>" /P "<Password>" /F "<Directory_path>" /R /A /D Y


Windows indicates that this user does not exist.

Also, if I try to activate the hidden administrator

Code: Select all

net user Administrator /Active:yes

net user Administrator "<Password>"


and then I try to write

Code: Select all

takeown /S localhost /U Administrator /P "<Password>" /F "<Directory_path>" /R /A /D Y


Windows always indicates that this user does not exist.

So, how should I use the /U option of takeown?

Thanks

Bye

Post Reply