Get help on file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
duonga
Posts: 5
Joined: 29 Nov 2018 09:21

Get help on file

#1 Post by duonga » 29 Nov 2018 09:35

Hi everybody,
Hi everybody
I have a txt file to run various exe files
1.exe
2.exe
3.exe
Which script I can run from the beginning to the end of the file and when finished running a file, then remove from the file is always txt
Please help everyone

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

Re: Get help on file

#2 Post by ShadowThief » 29 Nov 2018 22:37

Just change the extension from .txt to .bat and the three executables will run one after the other in order until all three are done.

duonga
Posts: 5
Joined: 29 Nov 2018 09:21

Re: Get help on file

#3 Post by duonga » 30 Nov 2018 05:19

My idea as well as random scrip just now is that I want to run the lines in the txt file and every time I run it, I delete the line that was running.

@Echo Off
For /F "tokens=2 delims=:" %%j in ('Find /C /V "" random.txt') Do (
Set MOD=%%j
)
Set MOD=%MOD:~1%

:LOOP
Set N=%random%
If %N% gtr 132 Set N= %N:~-2,2%
Set N=%N: 0=%
Set /A N=%N%%%%MOD%+1

Set GRTS=
For /F "tokens=1-2 delims=[]" %%j in ('Find /N /V "" random.txt') Do (
If "%%j"=="%N%" If not "%%k"=="" Set GRTS=%%k
)
If not defined GRTS GoTo :LOOP

Echo. %GRTS% > lastactionlaunched.txt

set /a timeout=!random! %%10

start %GRTS%


Set MOD=
Set N=
Set GRTS=
:: End_Of_Batch

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Get help on file

#4 Post by Ed Dyreen » 30 Nov 2018 10:27

duonga wrote:
29 Nov 2018 09:35
Hi everybody,
Hi everybody
I have a txt file to run various exe files
1.exe
2.exe
3.exe
Which script I can run from the beginning to the end of the file and when finished running a file, then remove from the file is always txt
Please help everyone

Code: Select all

@echo off &setlocal enableDelayedExpansion

set  "$fileIn=exeLines.txt"
set "$fileTMP=exeLines.tmp"
::
:loop ()
:: (
	< "!$fileIn!" (

		set "$=" &set /P "$=" &if defined $ (

			echo.start '!$!'
		rem	start "" /WAIT "!$!"
		)
	)

	copy/V/Y/B "!$fileIn!" "!$fileTMP!" >nul

	< "!$fileTMP!" >"!$fileIn!" (

		more +1
	)

	del /F "!$fileTMP!"

	< "!$fileIn!" (

		set "$=" &set /P "$=" &if defined $ (

			goto :loop "()"
		)
	)
:: )
pause
exit

Code: Select all

start 'program1.exe'
start 'program2.exe'
start 'program3.exe'
Druk op een toets om door te gaan. . .

duonga
Posts: 5
Joined: 29 Nov 2018 09:21

Re: Get help on file

#5 Post by duonga » 01 Dec 2018 02:31

Code: Select all

@echo off &setlocal enableDelayedExpansion

set  "$fileIn=exeLines.txt"
set "$fileTMP=exeLines.tmp"
::
:loop ()
:: (
	< "!$fileIn!" (

		set "$=" &set /P "$=" &if defined $ (

			echo.start '!$!'
		rem	start "" /WAIT "!$!"
		)
	)

	copy/V/Y/B "!$fileIn!" "!$fileTMP!" >nul

	< "!$fileTMP!" >"!$fileIn!" (

		more +1
	)

	del /F "!$fileTMP!"

	< "!$fileIn!" (

		set "$=" &set /P "$=" &if defined $ (

			goto :loop "()"
		)
	)
:: )
pause
exit

Code: Select all

start 'program1.exe'
start 'program2.exe'
start 'program3.exe'
Druk op een toets om door te gaan. . .
[/quote]

Thank you very much
But this is also a random script in txt file exeLines. The idea I need is that when running scrip it will run in line order in the txt file exeLines
program1.exe
program2.exe
program3.exe
After running the program1, it deletes the line from exeLines.txt

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Get help on file

#6 Post by Ed Dyreen » 01 Dec 2018 12:26

duonga wrote:
01 Dec 2018 02:31
Thank you very much
But this is also a random script in txt file exeLines. The idea I need is that when running scrip it will run in line order in the txt file exeLines
program1.exe
program2.exe
program3.exe
After running the program1, it deletes the line from exeLines.txt
No, not a random script in txt file exeLines, but a reply to your initial question.

duonga
Posts: 5
Joined: 29 Nov 2018 09:21

Re: Get help on file

#7 Post by duonga » 01 Dec 2018 20:27

thank you .i have got confusion about copy file about. it works very well

duonga
Posts: 5
Joined: 29 Nov 2018 09:21

Re: Get help on file

#8 Post by duonga » 01 Dec 2018 22:18

No, not a random script in txt file exeLines, but a reply to your initial question.
[/quote]
You can add conditions if the empty exeLines.txt file copies the data from the input.txt file

Post Reply