Page 1 of 1

Get help on file

Posted: 29 Nov 2018 09:35
by duonga
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

Re: Get help on file

Posted: 29 Nov 2018 22:37
by ShadowThief
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.

Re: Get help on file

Posted: 30 Nov 2018 05:19
by duonga
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

Re: Get help on file

Posted: 30 Nov 2018 10:27
by Ed Dyreen
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. . .

Re: Get help on file

Posted: 01 Dec 2018 02:31
by duonga

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

Re: Get help on file

Posted: 01 Dec 2018 12:26
by Ed Dyreen
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.

Re: Get help on file

Posted: 01 Dec 2018 20:27
by duonga
thank you .i have got confusion about copy file about. it works very well

Re: Get help on file

Posted: 01 Dec 2018 22:18
by duonga
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