MULTITASKING IN BATCH DONE!

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
(_osd_)
Posts: 25
Joined: 01 Mar 2015 07:41

MULTITASKING IN BATCH DONE!

#1 Post by (_osd_) » 06 Apr 2015 11:45

Hi guys :)
I found a way how you can MULTITASK / MULTITHREAD in batch (the batch does multiple things at the same time).

Code:

Code: Select all

@echo off
title Multitasking test

if not "%1"=="" goto %1

start /b %~nx0 2
start /b %~nx0 3

:1
echo Output loop 1
ping localhost -n 3 >nul
goto 1

:2
echo Output loop 2
ping localhost -n 2 >nul
goto 2

:3
echo Output loop 3
ping localhost -n 2 >nul
goto 3



Code: Select all

if not "%1"=="" goto %1
checks if the batch was started by itself or by a user.

Code: Select all

start /b %~nx0 2
starts the batch itself again in the same window and goes to the springpoint 2.

Code: Select all

:2
echo Output loop 2
ping localhost -n 2 >nul
goto 2
is basically just a loop which represents a task


Have fun experimenting with this! :D

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: MULTITASKING IN BATCH DONE!

#2 Post by ShadowThief » 06 Apr 2015 15:07

I don't know how to tell you this, but we've known about this for years.

Good job independently discovering it, though.

Post Reply