Reputation: 407
In my program, after installing, I'm adding a task to the task scheduler using the following command :
schtasks.exe /create /xml "task.xml" /tn "MyTasks/Task1" /f
In order to properly uninstall the program, I want to be able to remove totally the task folder "MyTasks". I can selectively delete this task using this command, but the folder still exists in the end :
schtasks.exe /delete /tn "MyTasks/Task1" /f
Is there a way to completely delete the folder ?
Thanks !
Upvotes: 1
Views: 3735
Reputation:
This is a vbs file.
Set TS = CreateObject("Schedule.Service")
TS.Connect("ComputerName")
Set RootFolder = TS.GetFolder("\")
RootFolder.DeleteFolder "MyTasks", 0
Substitute your computer name.
https://learn.microsoft.com/en-us/windows/win32/taskschd/taskfolder-deletefolder
Upvotes: 4
Reputation: 17565
There is a way to do this, but not using schtasks
: schtasks
is able to create a directory, if asked for, but when using schtasks
it can delete a task entry within a directory, but it can't delete the directory itself. I can only advise you to find the directory on your computer and to perform an rmdir
.
Upvotes: 2