Blogpost about NVIDIA Optimus and a .exe launcher


Recently I have spent quite some time trying to get the NVIDIA Optimus driver to select the high-performance card by default for my Java game.

I turns out that (as far as I know) the only way to do that is to launch your java game from C++.

Since it took me some time to figure it out, I wrote a bit about how I did it.

Hopefully it will save someone some time!

BTW, this thread helped quite a bit.


you could have just used batch to exe
make a batch file, convert it to an exe and rename your java.exe to whatever you want

But that way I couldn’t have set the global variable NvOptimusEnablement that I needed to get the Optimus driver to select the high performance GPU for my game, instead of the integrated GPU.

Not an expert but I think you can do this with batch as well.
Might be easier for most people than dusting off their C++ ide.
Of course it sucks that you have to set that variable to begin with

For this trick to work you need to export the variable in such a manner that the driver can find it by looking at the compiled .exe. It probably uses something like __declspec(dllimport) to find it.

It looked at the documentation of batch to exe, but I couldn’t find a way to do this. Did I miss something?

Probably not no, this is awfully specific =/

Yeah, that’s mostly why I posted. Maybe it will save the next guy some trouble…