Task Close after process finishes.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Silent44
Posts: 14
Joined: 26 Jan 2012 18:09

Task Close after process finishes.

#1 Post by Silent44 » 02 Mar 2015 07:17

Hello,

I am having a bit of trouble figuring out how to kill a task after it has been completed in batch.


@echo off
gcit game.iso -f DiscEx -d J:\games\extracted\


I would like a line to follow that will close the task when it has finished its operation which could be 1 minute or 5 minutes. I have tried with taskkill and no success. I am not sure how to make it loop until the process is idle and then kill it so my other script can continue.

Thanks for your help.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Task Close after process finishes.

#2 Post by foxidrive » 02 Mar 2015 07:21

Silent44 wrote:I am having a bit of trouble figuring out how to kill a task after it has been completed in batch.

@echo off
gcit game.iso -f DiscEx -d J:\games\extracted\


Google doesn't help determine what you are going. https://www.google.com.au/search?q=gcit

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Task Close after process finishes.

#3 Post by Compo » 02 Mar 2015 07:52

Why don't you use the [-Q|-Quit], Quit after the operation if there are no errors, or [-AQ|-AlwaysQuit], Quit after the operation even if there are errors, switches:

Code: Select all

@gcit game.iso -aq -f DiscEx -d J:\games\extracted


Additionally, (although it shouldn't be necessary), you could try using Start with Wait if you're wanting to run something after it.

Code: Select all

@Start /wait gcit game.iso -aq -f DiscEx -d J:\games\extracted


In either case gcit would need to be in your path.

Silent44
Posts: 14
Joined: 26 Jan 2012 18:09

Game Cube ISO Tool Script

#4 Post by Silent44 » 02 Mar 2015 08:23

removed~useless code
Last edited by Silent44 on 04 Mar 2015 11:53, edited 2 times in total.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Task Close after process finishes.

#5 Post by Squashman » 02 Mar 2015 09:04

Amazing what you can do when you read the help file for the progam you are using.

Code: Select all

Command line

gcit [Source] [Options]
Source is either an ISO filename or folder in GCReEx/DiscEx format.
All options are case insensitive.
-Quit or -Q
Quit after the operation if there's no errors.
-AlwaysQuit or -AQ
Quit after the operation even if there's errors.
Exit codes are as follows
0 - No error
1 - Error during operation
2 - User cancelled
3 - Command line error
-Flush
Flush the file buffers so that the SD card can be ejected almost immediately after the operation.
-Backup or -B
Save a backup of the original fst.bin and boot.bin files inside the trimmed ISO.
-Align or -A [4|32|32K]
Set the alignment used in the ISO. 4 bytes, 32 bytes or 32KB. Default is auto.
-Format or -F [GCReEx|DiscEx|FullISO]
Set the destination format. Default is Trimmed ISO.
-Dest or -D [filename|folder]
Set the output location.
GCReEx and DiscEx formats expect a folder.
The ISO formats expect a filename.
When extracting games from a GCOS multiboot disc, a folder is expected regardless of the output format.
Default is a file or folder called "out" in the same folder as the source.
Some simple examples of usage
gcit game.iso
gcit game.iso -b -d c:\backup\trimmed.iso
gcit game.iso -b -a 32K -d c:\backup\trimmed.iso
gcit game.iso -f gcreex -d e:\games
gcit game.iso -f DiscEx -d e:\games
gcit game.iso -q -flush -f FullISO -d "c:\folder with spaces\full.iso"
gcit multigame.iso -q -f discex -d "e:\games"

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Task Close after process finishes.

#6 Post by Compo » 02 Mar 2015 09:40

@Silent44, I'm not sure of your exact intentions, but does this single script not do the same as the two you've posted:

Code: Select all

@Echo Off & Setlocal
If %CD%\ NEq %~dp0 Pushd %~dp0
For %%A In (*.gcm *.iso) Do (
   If Not Exist "%%~nA\" MD "%%~nA"
   Move "%%~A" "%%~nA\game%%~xA"
   If /I %%~xA Equ .iso Call Set Dirs=%%Dirs%% "%%~nA")
For %%A In (%Dirs%) Do (
   "%~dp0gcit" "%%~nA\game.iso" -aq -f DiscEx -d "%~dp0Extracted")

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Task Close after process finishes.

#7 Post by Squashman » 02 Mar 2015 10:18

Good Call Compo,
I didn't really look at the script until right now. That is a whacky way to process files.

Silent44
Posts: 14
Joined: 26 Jan 2012 18:09

Re: Task Close after process finishes.

#8 Post by Silent44 » 02 Mar 2015 10:41

Yours works great, much thanks! :D

Silent44
Posts: 14
Joined: 26 Jan 2012 18:09

Making Task Recursive

#9 Post by Silent44 » 03 Mar 2015 14:36

removed~useless code
Last edited by Silent44 on 04 Mar 2015 11:52, edited 1 time in total.

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Task Close after process finishes.

#10 Post by Compo » 03 Mar 2015 17:28

@Silent44, The people in this group, myself included, have no idea about your exact task, nor about the specific programs you are using. What we do know is how best to structure a script in order to best manage the processes required to achieve the goal.

You've now changed the goal and created additional batch files which we haven't seen, and have effectively ignored the majority of the help I've thus far given, (which was partly based incidentally on guess work). Did you read the code which you agreed works? Did you not try to figure out why I did certain things or wonder what my code was doing and where the main differences were from yours?

Let me give you an example of a 'whacky', (read insane), idea; "copying the gcit executable and two batch files into each and every folder in a tree"!

You need to help us to help you, provide us with the content of the additional batch files and try to explain what you are trying to do with a layout of the tree you are working with and showing the location of the main script within that tree.

Silent44
Posts: 14
Joined: 26 Jan 2012 18:09

Re: Task Close after process finishes.

#11 Post by Silent44 » 03 Mar 2015 18:15

removed~useless code
Last edited by Silent44 on 04 Mar 2015 11:50, edited 4 times in total.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Task Close after process finishes.

#12 Post by Squashman » 03 Mar 2015 18:28

Compo wrote:Let me give you an example of a 'whacky', (read insane), idea; "copying the gcit executable and two batch files into each and every folder in a tree"!

And doing it with THREE separate FOR /D commands when it could have been done with ONE!!!!!!!!!!!!!!!!!!

I have never seen such convoluted branching of code in my entire life.

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Task Close after process finishes.

#13 Post by Compo » 04 Mar 2015 00:15

What are the .gcm files and are they supposed to be renamed to game.gcm or do they remain named as they were?
What other same named files are along side the .gcm and .iso files and are being moved to the respective directories?

Silent44
Posts: 14
Joined: 26 Jan 2012 18:09

Re: Task Close after process finishes.

#14 Post by Silent44 » 04 Mar 2015 01:04

removed~
Last edited by Silent44 on 04 Mar 2015 11:51, edited 1 time in total.

Silent44
Posts: 14
Joined: 26 Jan 2012 18:09

Game Cube ISO Tool Script - FINSIHED

#15 Post by Silent44 » 04 Mar 2015 11:39

FINAL UPDATE ~ everything is working great now!

Now I can just extract a zip file into my source directory containing all necessary bat files and programs.
Edit the start.bat to my destination directory and run the start.bat.
Final result = what I had originally hope for.
I guess the two for commands could be merged into one, but not sure how to do that.
Maybe like this:

Code: Select all

for /R %%i IN (.) do (
     Rar.exe x "%%i/*.rar" %target%
     Rar.exe x "%%i/*.001" %target%)

I will test and see!
Thanks for your help Compo!

Game Cube ISO Tool Script
(-) = usage, (~) = explanations
- extract all files to your source directory
- edit start.bat ( set target=your destination directory )
~ extracts all gcm and iso files from archived folders in the source directory
~ trims the iso files and aligns at 32k (this can be edited in gcit-wit.bat)
~ creates a folder structure as follows ( Game Name [GAMEID] )
~ renames a corresponding iso file to game.iso and moves it to the folder structure above
~ results = \destination directory\Game Name [GAMEID]\game.iso



start.bat =

Code: Select all

@echo off & setlocal

set target=

move gcit.exe %target%
move gcit-wit.bat %target%
move wit.exe %target%
for /R %%i IN (.) do Rar.exe x "%%i/*.rar" %target%
for /R %%i IN (.) do Rar.exe x "%%i/*.001" %target%
del rar.exe
pushd %target%
call gcit-wit.bat
del gcit.exe
del gcit-wit.bat
del wit.exe
del prefs.ini
del *.jpg


gcit-wit.bat =

Code: Select all

@echo off & Setlocal

GOTO WIT

:WIT
wit move *.iso *.gcm '%%T [%%6I].iso'
GOTO GCIT

:GCIT
If %CD%\ NEq %~dp0 Pushd %~dp0
For %%A In (*.iso) Do (
   If Not Exist "%%~nA\" MD "%%~nA"
   Move "%%~A" "%%~nA\game%%~xA"
   If /I %%~xA Equ .iso Call Set Dirs=%%Dirs%% "%%~nA")
For %%A In (%Dirs%) Do (
   "%~dp0gcit" "%%~nA\game.iso" -aq -a 32k -d "%~dp0%%~nA.iso")

If %CD%\ NEq %~dp0 Pushd %~dp0
For %%A In (*.iso) Do (
   If Not Exist "%%~nA\" MD "%%~nA"
   Move "%%~A" "%%~nA\game%%~xA"
   If /I %%~xA Equ .iso Call Set Dirs=%%Dirs%% "%%~nA")

Locked