Auto-start and auto-close with a game using a .bat file (alternative to AutoProfile feature)

Post Reply
f-hagemann
Posts: 7
Joined: 19 Feb 2012, 10:06
Location: Germany
Contact:

Auto-start and auto-close with a game using a .bat file (alternative to AutoProfile feature)

Post by f-hagemann »

I figured this tipp might be of use to others, I used it for years.

Starting a game auto-starts Xpadder and auto-closes it when you exit the game
  1. Create a new .txt document (preferably in the base folder of the game you want to use Xpadder with), name it whatever you want. Let's call it template.txt for this tutorial.
    .
  2. Open the document, copy & paste the following code:

    Code: Select all

    start "" "X:\Programmpath1\Programm1.exe"
    
    wait
    
    call "X:\Programmpath2\Programm2.exe"
    
    wait
    
    taskkill /im "Programm1.exe" /F
    
    wait
    
    exit
    
  3. Now edit the code to fit your own programm paths. The first program should always be the tool / program (in this case Xpadder), the second the game executable. Let's asume you use the following path for Xpadder and for the game Freespace 2 Open. For me it looks like this:

    Code: Select all

    start "" "C:\Program Files (x86)\Xpadder\Xpadder.exe"
    
    wait
    
    call "E:\Freespace 2\Launcher.exe"
    
    wait
    
    taskkill /im "Xpadder.exe" /F
    
    wait
    
    exit
    
    Make sure to alter the paths to fit YOUR folders and filenames!
    .
  4. Save and close the .txt. If not already done, set Windows to show file extensions in the folder properties (control panel). Now change the extension from .txt to .bat (template.txt --> template.bat)
    .
  5. Test it by double-clicking in the .bat. Start the game, see if Xpadder is loaded. Exit the game, see if Xpadder is terminated. NOTE: You have to move your mouse cursor over the tray icon of Xpadder manually in order to update the tray list.
    .
  6. You can always send a shortcut of this .bat to the desktop and assign an icon. Since absolute paths are used you can also place the .bat file anywhere you want, it will still work.
You can easily combine this with the build-in feature of Xpadder to recognize a certain game and load the fitting profile for that game, but with the automatic termination of Xpadder you make sure you wont accidentally hit some buttons via the controller when on the desktop. ;)


PS: I got this "piece of code" from someone else a long time ago. Back then I was specifically asking for the right parameters to set it up like this and someone helped me. Or maybe I googled it. Bottom line: I forgot where and I forgot who, but it's not originally created by my own mind ^^. So my thanks goes to this person and yours should, too.
Last edited by Primal Fear on 15 Apr 2013, 23:23, edited 2 times in total.
Reason: Edited topic title to prevent confusion with AutoProfile feature

Reboot
Xpadder Xpert
Posts: 137
Joined: 15 Jul 2010, 09:06
Contact:

Re: Auto-start with a game and auto-close (using a .bat file)

Post by Reboot »

Thanks hagemann, that’s a nice piece of code, (I will be saving that), can be used for other things as well. :rightthumbup:

f-hagemann
Posts: 7
Joined: 19 Feb 2012, 10:06
Location: Germany
Contact:

Re: Auto-start with a game and auto-close (using a .bat file)

Post by f-hagemann »

Reboot wrote:Thanks hagemann, that’s a nice piece of code, (I will be saving that), can be used for other things as well. :rightthumbup:
Indeed. I also used it in combination with the d3d-overrider to force v-sync on some games that don't support it. ^^

PS: I might add (and will do so for the start-post, too) that I got this "piece of code" from someone else a long time ago. Back then I was specifically asking for the right parameters to set it up like this and someone helped me. I forgot where and I forgot who. So my thanks goes to this person and yours should, too. :)

Reboot
Xpadder Xpert
Posts: 137
Joined: 15 Jul 2010, 09:06
Contact:

Re: Auto-start with a game and auto-close (using a .bat file)

Post by Reboot »

f-hagemann wrote:So my thanks goes to this person and yours should, too. :)
Yes, and thanks to both of you.

Errol
Xpadder Xpert
Posts: 306
Joined: 02 Oct 2011, 19:48
Location: Strange Place
Contact:

Re: Auto-start with a game and auto-close (using a .bat file)

Post by Errol »

I've been using this command for years now on many of my programs. And since my daughter bought Xpadder for me October of last year I've been using it for that too.
I always thought in my mind that practically everybody knew about it. So I never gave it a second thought.

Full credit to f-hagemann for posting it for other users. You're the man.

simpleco
Posts: 3
Joined: 27 Mar 2012, 14:31

Re: Auto-start with a game and auto-close (using a .bat file)

Post by simpleco »

f-hagemann wrote:I figured this tipp might be of use to others, I used it for years.

Starting a game auto-starts Xpadder and auto-closes it when you exit the game

Code: Select all

start "" "C:\Program Files (x86)\Xpadder\Xpadder.exe"

wait

call "E:\Freespace 2\Launcher.exe"

wait

taskkill /im "Xpadder.exe" /F

wait

exit
Make sure to alter the paths to fit YOUR folders and filenames!
.


PS: I got this "piece of code" from someone else a long time ago. Back then I was specifically asking for the right parameters to set it up like this and someone helped me. Or maybe I googled it. Bottom line: I forgot where and I forgot who, but it's not originally created by my own mind ^^. So my thanks goes to this person and yours should, too.

Thank you VERY VERY MUCH! It lead me to EXACTLY what I wanted to do.

My "code" is slightly different, but whomever you got this from (and yourself) definately has my thanks!

Here is what I did....

(First understand that I wanted to bring up Xpadder - loading the profile for the game I was about to play, then the game, play the game, and then after closing the game; have Xpadder go away.)

(Secondly, I use the .lnk [shortcut] to the game because the game's shortcut has extra line commands that I want the game to start with and the shortcut has those commands in it - so that's why I used the .lnk. Of course, I could have just run the game command with extra start commands on the line.. but.. anyway..)

(Lastly, I'm using Windows 7 (32bit) and it doesn't recognize the "wait" command)

So I ended up with this:


Start "" C:\Games\Xpadder\Xpadder.exe "D:\My Documents\Game Files\Return to Castle Wolfenstein.xpadderprofile"

Call "C:\Return to Castle Wolfenstein\Return to Castle Wolfenstein.lnk"

C:\Games\Xpadder\Xpadder.exe /c

exit


AND.. It does what I want! Thank you TONS!

mattdawson75
Posts: 18
Joined: 22 Jul 2012, 02:22

Re: Auto-start and auto-close with a game using a .bat file (alternative to AutoProfile feature)

Post by mattdawson75 »

I can't get this to work. I have Windows 8.1 Pro version 64 bit. Will this work for that?

Here's what I have:


start "" "E:\Program Files\Xpadder\Xpadder.exe"

wait

call "E:\Program Files\Games\MKFMasterv053.exe"

wait

taskkill /im "Xpadder.exe" /F

wait

exit



I changed the title to template.bat, double clicked it, and ran the video game.

Xpadder doesn't open.


Any suggestions? I would really appreciate it.

f-hagemann
Posts: 7
Joined: 19 Feb 2012, 10:06
Location: Germany
Contact:

Re: Auto-start and auto-close with a game using a .bat file (alternative to AutoProfile feature)

Post by f-hagemann »

To be totally honest, this has worked and refused to over the years. Sometimes it did, sometimes it did not. And it also refused any kind of analysis as to why this is. I could never really figure it out.

I know today that the executables of games can have some kind of flag as an internal switch for certain features. Like the flag to use more than 4gb of memory for instance, which didn't became important until a year ago when Skyrim mods demanded more memory than the designer of that game originally predicted.

Maybe it is something like that, maybe some games work because of different internal flags and others don't.

What was also suggested to me on several occasions: The code I use is wrong. Well to be honest again I scraped this together via google and when it once worked I thought it to be correct. I even followed up on this suggestion and tried several other batch orders but to no avail. Once this stopped working for me it was doomed. Like a curse lol. :D

TL;DR: Today I use Xpadder just in some very rare occasions and am fine with manually disabling it after use. I don't bother trying to get the batch to work anymore. Sorry I couldn't be of any more help. :oops:

mattdawson75
Posts: 18
Joined: 22 Jul 2012, 02:22

Re: Auto-start and auto-close with a game using a .bat file (alternative to AutoProfile feature)

Post by mattdawson75 »

Hey that's okay, thanks for replying. :D

f-hagemann
Posts: 7
Joined: 19 Feb 2012, 10:06
Location: Germany
Contact:

Re: Auto-start and auto-close with a game using a .bat file (alternative to AutoProfile feature)

Post by f-hagemann »

If you find something in your own experiments, it would be cool if you post it here of course. Maybe it can be figured out after all. Remeber: The truth is out there! :D

Post Reply

Return to “AutoProfile problems”