How To: Make and Work with a Windows Batch File


Setx is used to create or modify environment variables in the user or system environment of the OS. We often use it in batch files to set various environmental variables related to GPU functionality. This allow us to modify or overwrite default settings that may not be optimized for mining. This is indeed a useful feature as most defaults are geared to using video cards for gaming, and not necessarily mining cryptocurrencies. While we can go into the registry to change these variables directly, setx offers a more convenient way to do so.

Elsewhere on this site you have probably seen reference to the following setx variables:


These 5 variables optimize various parameters to more efficiently use the GPU proprieties when mining. They mainly deal with adjusting the memory allocations and allow full access to the graphic card’s memory for use by the mining program.

Without going into great detail, a summary of each of the variables and their possible values is listed below:

  • GPU_FORCE_64BIT_PTR [0 | 1] – When set to 0 allows access to 32-bit address space of memory ~3.8 GB. When set to 1 allows access to 64-bit address space. While it may sound like a good idea to set it at 1, it may actually hurt performance since then pointer access would require twice the number clock cycles to complete than it would if left in 32bit mode.
  • GPU_MAX_HEAP_SIZE [0 – 100] – By default the memory made available to OpenCL is limited to just 50%. With this setting it is possible to increase the amount available up to 100%.
  • GPU_USE_SYNC_OBJECTS [0 | 1] – Syncs the system CPU with the GPU actions to improve performance. The value of 0 is thought to lock usage to just one CPU core while the value of 1 is thought to allow access to multiple CPU cores. Since this is undocumented setting it is hard to tell for sure. If you see 100% CPU utilization while mining, try the opposite setting. There is even some debate if this works at all with Windows.
  • GPU_MAX_ALLOC_PERCENT [0 – 100] – Maximum amount of memory that can be allocated globally. Needs to be equal to or higher than the next setting.
  • GPU_SINGLE_ALLOC_PERCENT [0 – 100] – Maximum amount of memory that can be allocated to a single process.




To demonstrate setx’s usage, go ahead a create a new empty batch file, name it Set_GPU_Variables.bat and copy and paste the 5 lines found above into it, followed by the pause command. Save the file and then double click it to execute to commands. The pause command at the end will keep the command prompt window open until you close it. You should see results similar to that shown below:



You can see in the image above each command being executed line-by-line, and the command interpreter responding with a Success message for each one. Finally, we see our old friend pause in action allowing us to view the results. The pause command is optional, and we would get the same results without it with the exception the window would automatically close after the last command and we would be left guessing as to the results.

So not only is this a demonstration, it is the foundation of future miner launch batch files, as many mining programs will require that these variable are set prior to running. I should point out that these setx commands do not need to be run one each batch file, as they persist between sessions, but it also does not hurt to have them present as they provide a safety net should some other process or tweaking revert them back to their default settings.


We will look at a few more commands on the next page before moving on to our workable examples in the last section.



    • Well those apps actually interact with the driver software to control the functions on the GPU. It is a far more advanced topic than this article’s content which only covers basic Windows scripting, but on a very rudimentary level yes it is similar.

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.