|
I have a script whose role is to create a new folder with today's date, and then delete the folder more than 4 days apart from the current date. The specific content of the script is as follows:
On Error Resume Next
a = Date
b = Replace(a, "-", "_")
delDate=4
Set oShell = WScript.CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
If Not fs.FolderExists ("D:\backup\"&b) Then
fs.CreateFolder("D:\backup\"&b)
End If
Set fd = fs.getfolder("D:\backup")
for each sbfd in fd.subfolders
if (date-CDate(replace(sbfd.name,"_","-")))> delDate then
fs.DeleteFolder(sbfd.name)
end if
next
Set oshell = nothing
Set fd = nothing
Set fs = nothing
Execute this script directly under the command line and it can succeed. Then I directly created a task to execute the script in the "Control Panel" -> "Scheduled Tasks" (this task is run by my own account), and executed the task successfully. Then I used the at command to create a new scheduled task (at 15:00 d:\backup\backup.vbs, the task is run by the system account by default), but when the task is executed, only a new folder can be created, and the file cannot be deleted Folder, I double-checked and found that the "fs.DeleteFolder(sbfd.name)" statement could not be executed smoothly. The security permissions of my folders are set to full control by everyone. The operating system is windows server. Why can't the scheduled task run with the system account execute this statement? What is the difference between running a scheduled task with the system account and running a scheduled task with a normal account? Can the scheduled tasks executed by the system account fail to execute certain tasks? |
|