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?










share|improve this question
























  • 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















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?










share|improve this question
























  • 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













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?










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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










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





share|improve this answer





















  • 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


















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.






share|improve this answer

















  • 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











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























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





share|improve this answer





















  • 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















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





share|improve this answer





















  • 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













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





share|improve this answer












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






share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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












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.






share|improve this answer

















  • 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















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.






share|improve this answer

















  • 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













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.






share|improve this answer












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.







share|improve this answer












share|improve this answer



share|improve this answer










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














  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Probability when a professor distributes a quiz and homework assignment to a class of n students.

Aardman Animations

Are they similar matrix