hi
batch file code delete stubborn file ?
batch file code delete stubborn file ?
Moderator: DosItHelp
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: batch file code delete stubborn file ?
Probably some combination of the TAKEOWN and ICACLS commands, but there's probably a very good reason why you aren't able to delete that file.
Re: batch file code delete stubborn file ?
I have done extensive testing on how to delete stubborn files and i have a few solutions.
A)
B)
Change the User Account Permission's and Ownership
Hope is Helpful
A)
note: lots of usefully settings in gpedit.exe however you can very easily break your OS install this also applies to User Account Permission's and Ownership/InherenceEdit group policy to allow the user about to delete files admirative permissions.
- open gpedit.exe
- goto Local Computer Policy / Computer Configuration / Windows Settings / Security Settings / User Rights Assignment / Take ownership of files or other objects
B)
Change the User Account Permission's and Ownership
OR- Open Security and Maintenance in Control Panel/System and Security.
than you can- "Security" Tab in the left click file properties menu
- Set user permissions and ownership to :
Allow Administrators
Allow Users
Allow Everyone
Remove all the other user permission's
Disable File Inheritance
this will insure that whatever account your using can access it the file or folder.
C)- RD /F
- Del /F
- Shift Delete in the UI
- boot any windows media in boot mode,
- get to a cmd window and
- manually delete the file with del or rd
- type notepad into the cmd window
goto "open file"
Select "all file types"
search for the file you want to delete
note: this will also work with an offline Linux live boot os/ or as alongside Linux install
Hope is Helpful
Re: batch file code delete stubborn file ?
What do you mean by stubborn file?
Before going through complex and risky procedures like updating group policies, it'd be easier if we knew more about what you did, and what error messages you got.
The most common cases are
- A read-only file
- A file for which you don't have the necessary user rights
- Did you try doing this in an Administrator command shell?
- Some files are owned by the Windows system. Deleting them is usually a very bad idea. If you know for sure it's safe to delete it, MS SysInternals has tools for running a command as system.
- Maybe the file has a name incompatible with standard WIN32 APIs? (Like ending with a space, or called "nul", etc. This can happen when using the WSL.)
In which case prefixing the full pathname with \\?\ usually resolves the issue.
Before going through complex and risky procedures like updating group policies, it'd be easier if we knew more about what you did, and what error messages you got.
The most common cases are
- A read-only file
- A file for which you don't have the necessary user rights
- Did you try doing this in an Administrator command shell?
- Some files are owned by the Windows system. Deleting them is usually a very bad idea. If you know for sure it's safe to delete it, MS SysInternals has tools for running a command as system.
- Maybe the file has a name incompatible with standard WIN32 APIs? (Like ending with a space, or called "nul", etc. This can happen when using the WSL.)
In which case prefixing the full pathname with \\?\ usually resolves the issue.