Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch file to show or delete a numbered task names  (Read 2936 times)

0 Members and 1 Guest are viewing this topic.

Hackoo

    Topic Starter


    Hopeful
  • Thanked: 42
  • Experience: Expert
  • OS: Windows 10
Batch file to show or delete a numbered task names
« on: November 09, 2017, 04:53:33 PM »
Hi  ;)
I need a little help to improve my new batch to show or delete a numbered task names
The code below works fine if the task name does not contains a space  :D
So i'm looking how can i modify it to read a task name with a space   ???
Thank you for any help  :-*
Code: [Select]
@echo off
Title Delete Tasks with their time tasks execution by Hackoo 2017
Mode 90,30 & color 0A
:Menu
cls & echo(
echo Type the time with this format "hh:mm" to show or delete for scheduled Tasks
set /a "count=0"
set /p "strTime="
cls & echo(
Setlocal EnableDelayedExpansion
@for /f "tokens=1 delims= " %%a in ('schtasks /query ^| find /I "%strTime%"') do (
set /a "Count+=1"
set "TaskName[!Count!]=%%a"
)
Rem Display numbered Task Names
@for /L %%i in (1,1,%Count%) do (
set "msg=[%%i] - !TaskName[%%i]!"
echo !msg!
)
echo(
Rem Asking the user if he wants to delete or not the numbered task names
echo Type the number of the task to delete !
set /p "Input="
@for /L %%i in (1,1,%Count%) Do (
    If "%INPUT%" EQU "%%i" (
schtasks /delete /tn "!TaskName[%%i]!"
)
)
echo(
echo Type any key to show and delete another task !
Pause>nul
Goto Menu

Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other
Re: Batch file to show or delete a numbered task names
« Reply #1 on: November 09, 2017, 06:40:33 PM »
Answered on DosTips

Hackoo

    Topic Starter


    Hopeful
  • Thanked: 42
  • Experience: Expert
  • OS: Windows 10
Re: Batch file to show or delete a numbered task names
« Reply #2 on: November 09, 2017, 07:18:07 PM »
Answered on DosTips
Thank you very much for your help  ;)