Let me start by saying I am self taught in VBScript.
I have a folder that gets filled with temporary files and I need to delete them.
So I created a script when it runs I am getting a permission denied when the script tries to delete the file. I am a Domain Admin, but to be sure I manually deleted a file and had no issues. I get the same message even when I run the script on the server.
I tried to post all of my code here put I had a hard time reading it. If you can tell me how to post it so you can read it please let me know. I saw something about putting a ">" on the first line put It was not putting everything on one line.
Here is the section I am having issues with, the error is the last line (Permission Denied)
Set objFile = objFSO.GetFile(strFolder1 & "\\" & strFileName.Name) objFSO.DeleteFile myFileToDelete, True
OK I looked at help more. I could not indent even with 4 spaces in front. Not sure how to code this, I tried but I cannot get it to accept it.
TIA, Rodger
This should do what you're asking:
Sub DeleteMyFile(myFileToDelete)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(myFileToDelete)
End Sub
myFileToDelete = strFolder1 & "\" & strFileName
DeleteMyFile(myFileToDelete)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.