Anton Todorov
Anton Todorov

Reputation: 1236

How to run scheduled job

I am struggling to find a way to run a scheduled job that has a special datestamp into it's name.
The name always starts with "OS_HOUSEKEEP_", followed by the datestamp - e.g.

OS_HOUSEKEEP_2018022616171014980.job

Also, no other jobs having "OS_HOUSEKEEP_" in their names are present on the machine.

Could someone advise easiest way to target it and run it once with MS-DOS command(s)?

In addition, I thought to list the current jobs with the following command:

 schtasks /query /v /fo LIST | findstr "OS_HOUSEKEEP_". 

Unfortunately it only comes as a result and I am unable to cache it then to process it by sections (devided with space).
No other solutions has come to my mind..

Upvotes: 0

Views: 90

Answers (1)

Stephan
Stephan

Reputation: 56180

for /f "tokens=2 delims=," %%a in ('schtasks /query /v /fo csv^|find "OS_HOUSEKEEP_"') do set "task=%%~a"
set "task=%task:~1%"
echo taskname is:%task%.

the tilde in %%~a removes the quotes, the second set command removes the first character.

Upvotes: 1

Related Questions