Can delete a file through windows explorer but not through batch file
up vote
1
down vote
favorite
When trying to delete a file from a network location via windows (I am on windows 7) batch file using a "del" command with /f and /q flags, I see an "Access is denied." message, and the file is not deleted. However, I can successfully delete the file manually through the windows explorer.
I have been running the batch file with my personal user account, which should use the same permissions as manually deleting through windows explorer.
There is nothing special about the file I am trying to delete, it is a blank text file that I created for testing after I noticed that some of our automation code couldn't delete files from this location.
This issue is only present on one specific network share, in all other locations, I can delete files with windows batch files with no issue.
Additionally, I can successfully create a text file in the network location in question without any problems via a batch file. It is just the delete command that gives me the "Access is denied." issue.
My account is in a group that does not have access to the Share holding the folder in question, but does have access to the folder on the share. The way the security is setup for this network location is as follows:
\ServerShareFolder1
\ServerShareFolder2
Where the group my account is in has "modify" access to Folder1 and Folder2, but not Share.
Edit:
The command line in question, as requested:
del \ServerShareFolderTEST_FILE.txt /F /Q
Does anyone know any network/security phenomenon that could be causing this issue, and how can I fix it?
windows-7 windows windows-explorer batch batch-file
add a comment |
up vote
1
down vote
favorite
When trying to delete a file from a network location via windows (I am on windows 7) batch file using a "del" command with /f and /q flags, I see an "Access is denied." message, and the file is not deleted. However, I can successfully delete the file manually through the windows explorer.
I have been running the batch file with my personal user account, which should use the same permissions as manually deleting through windows explorer.
There is nothing special about the file I am trying to delete, it is a blank text file that I created for testing after I noticed that some of our automation code couldn't delete files from this location.
This issue is only present on one specific network share, in all other locations, I can delete files with windows batch files with no issue.
Additionally, I can successfully create a text file in the network location in question without any problems via a batch file. It is just the delete command that gives me the "Access is denied." issue.
My account is in a group that does not have access to the Share holding the folder in question, but does have access to the folder on the share. The way the security is setup for this network location is as follows:
\ServerShareFolder1
\ServerShareFolder2
Where the group my account is in has "modify" access to Folder1 and Folder2, but not Share.
Edit:
The command line in question, as requested:
del \ServerShareFolderTEST_FILE.txt /F /Q
Does anyone know any network/security phenomenon that could be causing this issue, and how can I fix it?
windows-7 windows windows-explorer batch batch-file
Can you share all of, or at least the important part, of your BAT file?
– YetAnotherRandomUser
Dec 1 at 1:23
Yes, updated the post with that info @YetAnotherRandomUser
– roger21
Dec 3 at 17:55
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
When trying to delete a file from a network location via windows (I am on windows 7) batch file using a "del" command with /f and /q flags, I see an "Access is denied." message, and the file is not deleted. However, I can successfully delete the file manually through the windows explorer.
I have been running the batch file with my personal user account, which should use the same permissions as manually deleting through windows explorer.
There is nothing special about the file I am trying to delete, it is a blank text file that I created for testing after I noticed that some of our automation code couldn't delete files from this location.
This issue is only present on one specific network share, in all other locations, I can delete files with windows batch files with no issue.
Additionally, I can successfully create a text file in the network location in question without any problems via a batch file. It is just the delete command that gives me the "Access is denied." issue.
My account is in a group that does not have access to the Share holding the folder in question, but does have access to the folder on the share. The way the security is setup for this network location is as follows:
\ServerShareFolder1
\ServerShareFolder2
Where the group my account is in has "modify" access to Folder1 and Folder2, but not Share.
Edit:
The command line in question, as requested:
del \ServerShareFolderTEST_FILE.txt /F /Q
Does anyone know any network/security phenomenon that could be causing this issue, and how can I fix it?
windows-7 windows windows-explorer batch batch-file
When trying to delete a file from a network location via windows (I am on windows 7) batch file using a "del" command with /f and /q flags, I see an "Access is denied." message, and the file is not deleted. However, I can successfully delete the file manually through the windows explorer.
I have been running the batch file with my personal user account, which should use the same permissions as manually deleting through windows explorer.
There is nothing special about the file I am trying to delete, it is a blank text file that I created for testing after I noticed that some of our automation code couldn't delete files from this location.
This issue is only present on one specific network share, in all other locations, I can delete files with windows batch files with no issue.
Additionally, I can successfully create a text file in the network location in question without any problems via a batch file. It is just the delete command that gives me the "Access is denied." issue.
My account is in a group that does not have access to the Share holding the folder in question, but does have access to the folder on the share. The way the security is setup for this network location is as follows:
\ServerShareFolder1
\ServerShareFolder2
Where the group my account is in has "modify" access to Folder1 and Folder2, but not Share.
Edit:
The command line in question, as requested:
del \ServerShareFolderTEST_FILE.txt /F /Q
Does anyone know any network/security phenomenon that could be causing this issue, and how can I fix it?
windows-7 windows windows-explorer batch batch-file
windows-7 windows windows-explorer batch batch-file
edited Dec 3 at 17:55
asked Nov 29 at 22:04
roger21
254
254
Can you share all of, or at least the important part, of your BAT file?
– YetAnotherRandomUser
Dec 1 at 1:23
Yes, updated the post with that info @YetAnotherRandomUser
– roger21
Dec 3 at 17:55
add a comment |
Can you share all of, or at least the important part, of your BAT file?
– YetAnotherRandomUser
Dec 1 at 1:23
Yes, updated the post with that info @YetAnotherRandomUser
– roger21
Dec 3 at 17:55
Can you share all of, or at least the important part, of your BAT file?
– YetAnotherRandomUser
Dec 1 at 1:23
Can you share all of, or at least the important part, of your BAT file?
– YetAnotherRandomUser
Dec 1 at 1:23
Yes, updated the post with that info @YetAnotherRandomUser
– roger21
Dec 3 at 17:55
Yes, updated the post with that info @YetAnotherRandomUser
– roger21
Dec 3 at 17:55
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
I'm not sure why this is happening, but I suspect the del
command does not support UNC path names properly.
I could easily reproduce this, and the error went away when I used a mapped drive:
del \sharefolderfile.txt
:: got an error 'Access denied'
net use Z: \sharefolder
del Z:file.txt
:: file deleted successfully
Strangely enough, other commands did work. For instance, I could create a subdirectory, move the file there and then delete the subdirectory:
mkdir \sharefoldertrash
move \sharefolderfile.txt \sharefoldertrash
rmdir /s /q \sharefoldertrash
Wow, this actually worked for me. Very strange that i'm only experiencing this issue on one network share, but hey, if it works, it works. Thanks!
– roger21
Nov 30 at 15:55
add a comment |
up vote
-1
down vote
The command 'del yx' does a search in 'y' for all files matching 'x', so you'll need list-directory access on 'y'.
With regard to network shares, the access you get is the intersection of permissions on the share and on the object you're accessing, If a file permits you write, but the share does not, then you can't write.
1
Thanks for the answer, want to clarify some things. When you say ill need “list-directory access on y”, if i can see x directory contents in windows explorer, does that mean i have that access? Second, if i can create the file manually and write to it manually, does that not mean i have access to the object im accessing?
– roger21
Nov 30 at 4:07
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
I'm not sure why this is happening, but I suspect the del
command does not support UNC path names properly.
I could easily reproduce this, and the error went away when I used a mapped drive:
del \sharefolderfile.txt
:: got an error 'Access denied'
net use Z: \sharefolder
del Z:file.txt
:: file deleted successfully
Strangely enough, other commands did work. For instance, I could create a subdirectory, move the file there and then delete the subdirectory:
mkdir \sharefoldertrash
move \sharefolderfile.txt \sharefoldertrash
rmdir /s /q \sharefoldertrash
Wow, this actually worked for me. Very strange that i'm only experiencing this issue on one network share, but hey, if it works, it works. Thanks!
– roger21
Nov 30 at 15:55
add a comment |
up vote
2
down vote
accepted
I'm not sure why this is happening, but I suspect the del
command does not support UNC path names properly.
I could easily reproduce this, and the error went away when I used a mapped drive:
del \sharefolderfile.txt
:: got an error 'Access denied'
net use Z: \sharefolder
del Z:file.txt
:: file deleted successfully
Strangely enough, other commands did work. For instance, I could create a subdirectory, move the file there and then delete the subdirectory:
mkdir \sharefoldertrash
move \sharefolderfile.txt \sharefoldertrash
rmdir /s /q \sharefoldertrash
Wow, this actually worked for me. Very strange that i'm only experiencing this issue on one network share, but hey, if it works, it works. Thanks!
– roger21
Nov 30 at 15:55
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
I'm not sure why this is happening, but I suspect the del
command does not support UNC path names properly.
I could easily reproduce this, and the error went away when I used a mapped drive:
del \sharefolderfile.txt
:: got an error 'Access denied'
net use Z: \sharefolder
del Z:file.txt
:: file deleted successfully
Strangely enough, other commands did work. For instance, I could create a subdirectory, move the file there and then delete the subdirectory:
mkdir \sharefoldertrash
move \sharefolderfile.txt \sharefoldertrash
rmdir /s /q \sharefoldertrash
I'm not sure why this is happening, but I suspect the del
command does not support UNC path names properly.
I could easily reproduce this, and the error went away when I used a mapped drive:
del \sharefolderfile.txt
:: got an error 'Access denied'
net use Z: \sharefolder
del Z:file.txt
:: file deleted successfully
Strangely enough, other commands did work. For instance, I could create a subdirectory, move the file there and then delete the subdirectory:
mkdir \sharefoldertrash
move \sharefolderfile.txt \sharefoldertrash
rmdir /s /q \sharefoldertrash
answered Nov 30 at 7:51
Berend
1,5161713
1,5161713
Wow, this actually worked for me. Very strange that i'm only experiencing this issue on one network share, but hey, if it works, it works. Thanks!
– roger21
Nov 30 at 15:55
add a comment |
Wow, this actually worked for me. Very strange that i'm only experiencing this issue on one network share, but hey, if it works, it works. Thanks!
– roger21
Nov 30 at 15:55
Wow, this actually worked for me. Very strange that i'm only experiencing this issue on one network share, but hey, if it works, it works. Thanks!
– roger21
Nov 30 at 15:55
Wow, this actually worked for me. Very strange that i'm only experiencing this issue on one network share, but hey, if it works, it works. Thanks!
– roger21
Nov 30 at 15:55
add a comment |
up vote
-1
down vote
The command 'del yx' does a search in 'y' for all files matching 'x', so you'll need list-directory access on 'y'.
With regard to network shares, the access you get is the intersection of permissions on the share and on the object you're accessing, If a file permits you write, but the share does not, then you can't write.
1
Thanks for the answer, want to clarify some things. When you say ill need “list-directory access on y”, if i can see x directory contents in windows explorer, does that mean i have that access? Second, if i can create the file manually and write to it manually, does that not mean i have access to the object im accessing?
– roger21
Nov 30 at 4:07
add a comment |
up vote
-1
down vote
The command 'del yx' does a search in 'y' for all files matching 'x', so you'll need list-directory access on 'y'.
With regard to network shares, the access you get is the intersection of permissions on the share and on the object you're accessing, If a file permits you write, but the share does not, then you can't write.
1
Thanks for the answer, want to clarify some things. When you say ill need “list-directory access on y”, if i can see x directory contents in windows explorer, does that mean i have that access? Second, if i can create the file manually and write to it manually, does that not mean i have access to the object im accessing?
– roger21
Nov 30 at 4:07
add a comment |
up vote
-1
down vote
up vote
-1
down vote
The command 'del yx' does a search in 'y' for all files matching 'x', so you'll need list-directory access on 'y'.
With regard to network shares, the access you get is the intersection of permissions on the share and on the object you're accessing, If a file permits you write, but the share does not, then you can't write.
The command 'del yx' does a search in 'y' for all files matching 'x', so you'll need list-directory access on 'y'.
With regard to network shares, the access you get is the intersection of permissions on the share and on the object you're accessing, If a file permits you write, but the share does not, then you can't write.
answered Nov 30 at 4:02
dave
1
1
1
Thanks for the answer, want to clarify some things. When you say ill need “list-directory access on y”, if i can see x directory contents in windows explorer, does that mean i have that access? Second, if i can create the file manually and write to it manually, does that not mean i have access to the object im accessing?
– roger21
Nov 30 at 4:07
add a comment |
1
Thanks for the answer, want to clarify some things. When you say ill need “list-directory access on y”, if i can see x directory contents in windows explorer, does that mean i have that access? Second, if i can create the file manually and write to it manually, does that not mean i have access to the object im accessing?
– roger21
Nov 30 at 4:07
1
1
Thanks for the answer, want to clarify some things. When you say ill need “list-directory access on y”, if i can see x directory contents in windows explorer, does that mean i have that access? Second, if i can create the file manually and write to it manually, does that not mean i have access to the object im accessing?
– roger21
Nov 30 at 4:07
Thanks for the answer, want to clarify some things. When you say ill need “list-directory access on y”, if i can see x directory contents in windows explorer, does that mean i have that access? Second, if i can create the file manually and write to it manually, does that not mean i have access to the object im accessing?
– roger21
Nov 30 at 4:07
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1379581%2fcan-delete-a-file-through-windows-explorer-but-not-through-batch-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you share all of, or at least the important part, of your BAT file?
– YetAnotherRandomUser
Dec 1 at 1:23
Yes, updated the post with that info @YetAnotherRandomUser
– roger21
Dec 3 at 17:55