Build Your Own Arcade Controls Forum

Main => Software Forum => Topic started by: tony.silveira on October 23, 2009, 12:18:42 am

Title: help with pc bat file
Post by: tony.silveira on October 23, 2009, 12:18:42 am
hi guys,

i was hoping someone could offer an assist.

i want to write a small bat file to launch a pc game thru my front end (mamewah) and have it also close xpadder.  i'm running into an issue when loading pc games in that some of them control wonky with my 360 pad and the key definitions i have set for my xpadder pc profile.

i know i can have multiple profiles for xpadder but since all my pc games launch with the same profile, i'm going to have to create a bat file to launch specific games and turn off xpadder; returning it to a standard 360 controller thru windows.

my confusion with the bat file is, will the bat file close upon exiting the loaded game or does it close once it's executed?

any input is appreciated,

tony
Title: Re: help with pc bat file
Post by: protokatie on October 23, 2009, 12:34:26 am
Just a little info.
A batch file will "lock" on any particular line until the program it is running frees it (usually by being a windows program, or by ending).
CALLing a batch file from within a batch file will prevent the first batch file from ending prematurely (being cut off).

I know nothing of xpadder, but see if there is a /quit style command for it (run it in the command prompt with /? after it to see). If there is, you should be able to have that first in the batch file, then run the windows game. Might also want to check if the windows game releases the console(batch file) until after it is exited. If it waits until after you quit the game, you could have the third line on the batch file be for restarting xpadder. (All of this hinges on if xpadder can be given a command argument to have it quit itself)
Title: Re: help with pc bat file
Post by: arzoo on October 23, 2009, 08:37:11 am
tony - I would suggest using a vbscript. The trick is getting the windows handle for the running instance of xpadder. Search google for vbscript and "kill process" or "close application" and you should find examples.
Title: Re: help with pc bat file
Post by: axewater on October 30, 2009, 08:45:34 am
great .. something *I* can help with !!! I'm the batch file MASTER :)
I'm going to assume you are using windows XP or later for this ...

modify this to your needs (ie the xpadder.exe filename I guessed) and save as batchfile.cmd :

@echo off
taskkill xpadder.exe /f
c:
cd \games\game1
start game.exe
exit


notes :
-taskkill.exe only exists on XP and later, i dont know what xpadder executable name is, but change this to your needs
-I recommend putting the lines 'c:' and 'cd .....blah' in the batch file to make sure the game will start from its own folder, or it might fail to run properly (as it cannot find the rest of the files)
-using START will make sure the batch file continues to the next line without waiting for the game to end
-the exit command is not really necesarry, but it wont do any harm and will make 100% sure the batch file closes while the game runs

good luck !
Title: Re: help with pc bat file
Post by: protokatie on November 01, 2009, 02:38:53 am
YAY! I have a new batch command in my arsenal! How did I ever miss Taskkill* ?!!! Also, I thought they got rid of Run, and from what I understand they did; I seemed to have forgotten completely about the Start command being its replacement...   :banghead:


*Seriously, how come I have never heard of this before? I checked it (taskkill) out and now have a lot of new flexibility in my batch files...
Title: Re: help with pc bat file
Post by: headkaze on November 02, 2009, 10:38:01 pm
You should avoid taskkill.exe as much as possible because the process it kills will not exit "gracefully". I recommend a command line app such as process (http://www.beyondlogic.org/solutions/processutil/processutil.htm) which can close an app using WM_CLOSE message which will allow the program to clean up and close properly.
Title: Re: help with pc bat file
Post by: axewater on November 03, 2009, 04:55:13 am
nice one headkaze ... now I also have something new to use in batch files :)
so far I have not needed it, but I assume some games might only save highscore if you exit gracefully ...