November 21, 2019, 01:57:20 pm

Author Topic: How to Setup a cpuminer (minerd) on Task Scheduler - Optionally Hidden  (Read 9985 times)

0 Members and 1 Guest are viewing this topic.

Offline ElscottHavoc

  • Newbie
  • *
  • Posts: 24
  • Karma: +6/-0
    • View Profile
In this tutorial, I’m going to explain how to setup a CPUMiner a couple of different ways and then use those methods to setup a CPUMiner that will run automatically using Windows Task Scheduler.  The main benefit of running a miner using the Task Scheduler is that it simplifies the management of miners running on remote machines that you might not have access to on a routine basis and/or you’d rather not have the console window displayed – not that you’d ever install these on family members’ or work computers…right?

Furthermore, I’ve found that if you setup a miner to run on the Task Scheduler, newer versions of Windows have the ability to export and import tasks, providing a fairly simple method of transferring tasks to other computers by simply copying over your mining program files to the new computer with a USB and verifying the task is correctly identifying the executable directory, allowing you to essentially set it and forget it.

Obviously, as I’m sure most people are aware, CPU mining is far from the most effective method of efficient mining, but it is also the most readily accessible for beginners as it doesn’t require any special hardware or GPU considerations – which also makes it useful if you’re just looking to create a farm of slave mining computers (PCs belonging to friends, family, work, etc) without considering their hardware limitations.  While GPU mining, along with other more advanced mining programs are certainly going to offer better likelihoods of profitability for any crypto currency, CPU Mining should be relatively successful for finding shares and generating new coins for crypto currencies with low difficulties to provide at the very least a very small starting account balance that will hopefully over time appreciate in value.

Of course, while we’ll be covering CPU mining in this particular tutorial, many of the concepts from the task scheduling stand point will be identical or very similar.


We're going to be using this cpuminer:  https://bitcointalk.org/index.php?topic=55038.0
Of course, the general idea of this tutorial can be altered to fit a variety of different miners and a variety of different pools, coins, etc.

Setting Up a Miner
There's a couple of ways you can set your miner up, one is using the "Shortcut File" method and the other is to run it using a batch file.  First we'll, cover the batch file, as it is probably the easiest to setup and also is the simplest to setup a task with as all you need to do is set the Task Scheduler to run the batch file.

Batch File Method - Should work with all versions of Windows, but typically requires you keep the batch file in the same folder as executable:
1.)  After you download the cpuminer, you're going to be presented with a folder that includes minerd.exe. 
2.) Within that folder, create a new text document using notepad.  Give the document a relevant name to your pool and coin you'll be mining.
3.) Copy the following into the document replacing the URL, username, password, and number of threads you want to use as necessary: minerd -a scrypt -o stratum+tcp://URL:port -u username -p password -t 4
4.) Save and exit the document.  Change the file extension to .bat and then double click the batch file and it will start running the miner.

Shortcut Method - May not work on some version of Windows and doesn't work well with Task Scheduler, but allows you more freedom with where you place the shortcut on your computer as it will always reference the minerd.exe:
1.)  After you download the cpuminer, you're going to be presented with a folder that includes minerd.exe.
2.)  Right click on the shortcut you just created to Minerd.exe and click rename.  I recommend renaming it to something that includes the pool you'll be using and the coin you'll be mining.
3.)  Now, you can right click on the shortcut and click on properties.  You should be on the "Shortcut" tab and you'll want to find the text box labeled "Target:"
4.)  Select everything in that box and replace the contents with:  -a scrypt -o stratum+tcp://URL:port -u username -p password -t 4
5.)  Click apply and then right click again and choose properties and you should see something like this example in the Target: textbox:
C:\Users\Admin\Desktop\pooler-cpuminer-2.4.1-win64\minerd.exe -a scrypt -o stratum+tcp://us-west.multipool.us:7777 -u elscotthavoc.slave -p x -t 4
The number following "-t" is the number of cores you want to use.
6.)  Test to make sure the miner works.

Setting A Miner To Work In Task Scheduler

Note:  If you use the batch method, you should be able to direct the Task Scheduler to simply run the batch file you created as long as it is still in the same folder as the miner executable.  Unfortunately if you used the Shortcut Method, we can't just re-use the shortcut we just created in the task scheduler, but instead we will be scheduling minerd.exe as the program and then adding the information from step 4 in the previous section as "arguments" on the task properties.

1.) Open the "Task Scheduler" on your computer. 
2.) Certain version of Windows have different ways of displaying and handling the Task Scheduler, but this should give you the jist of it.
3.) Click "Create New Task" or "Add Scheduled Task" depending upon version of Windows.
4.) Now, we're just going to work our way through the tabs to create the task.  Some versions of windows might not display each heading as tabs, so read through this first and then apply the directions as necessary to your task scheduler.
5.) General Tab:  We'll be coming back to this tab later in case you want it to run hidden from view, but for now just fill in the Name and Description.  In order to change the "author" we'll actually need to export the task, but more on that later also.  Be sure, at least for now until we come back to this, for testing purposes leave it as "Run Only When User is Logged On".
6.) Triggers Tab:  This is where you'll actually create the triggers that cause the miner program to run.  You might want to have it auto run as soon as the computer is started or maybe have it launched on a certain schedule.  I think this area is pretty self explanatory, just keep in mind that if you set triggers to occur in a way that may create multiple instances, you'll need to account for that by checking the "Do Not Create a New Instance" under the Settings Tab for what to do if an existing task is running.
7.) Actions Tab:  This is where we're actually going to choose what miner program to use and pool to mine.  So, first of all we're going to want to create a new action. In this case, we want the action to be "Start a Program" and then we're going to want to browse for the location of our miner program on the local machine.  If you used a batch file, simply direct the task to the batch file, otherwise, we'll be searching for minerd.exe - keep in mind, we want the default minerd.exe and not the shortcut if that's the method you created with your pool information in the target.  Also, keep in mind that if you're importing this task, you want to make sure to double check the directory path as it may be a different path on the new computer than it was on the original computer.  If your task scheduler gives you errors or doesn't allow you to set arguments, than you'll most likely need to use the batch method.
8.) Do this step only if you are NOT using a batch file.  Now that we have a path to minerd.exe found, we can go to the box in the Actions Tab labeled "Add Arguments:" and insert the necessary information to run the miner for a certain pool:
An example of what you'd paste replacing your pool information is:  -a scrypt -o stratum+tcp://URL:port -u username -p password -t 4
9.)  Finish up going through the additional tabs (Conditions, Settings) to set the task to run just as you'd like it based upon whatever rules you choose.
10.)  Click OK and then highlight the task in the list and click Run in the Actions menu on the right hand side.  If everything is filled out correctly, the miner should start working.  Then, simply close the miner and the next time the miner restarts will be based upon the rules you set up as a trigger.

Running the Miner Hidden From View

1.)  In order to ensure that the miner console window remains hidden from view, we need to return to the "General" tab on the task.
2.)  I've found that if you select "Run whether user is logged in or not", "Run with the highest privileges", and check "Hidden" that the miner console will remain hidden from view, including not even showing up in the Task Manager.  You'll may also have to check "Do not store password" depending upon adminstration and user account password settings.
3.)  Once, again, click okay and now select "Run".  Sometimes I've found Task Scheduler to be buggy regarding it reporting whether or not a task has run successfully or not after I choose to manually end it, so an easy way to check would be to set up a new worker on your mining pool and then verify that everything works correctly by whether or not a new miner is reporting and then you could go back later and alter the worker in the task to something different if you're comfortable that everything is set up correctly.

Exporting/Importing Tasks - May not work on some versions of Windows.

1.) Exporting the task is an easy way to save it as a .xml file to a USB stick and then importing the .xml file on a new computer within the Task Scheduler.
2.) Doing so is as simple as highlighting a task and then selecting export and then saving it.
3.) To move it to a new computer, simply import the saved file and now everything is copied over and the task will work exactly as it did on the original computer - of course, you want to make sure that the computer your copying to has the necessary mining software required by the task and that the task has the correct path to the executable.

Changing the Task Author & Other Task Data Via the Exported .xml File

For a variety of reasons, you might feel uncomfortable having the task refer to the originating computer, as it is possible that the author name could give away personal details about who setup the task on the computer.  I don't want people to think I support illegal mining activities or mining on someone's computer without permission, but regardless, changing the author's name is as simple as altering the .xml file that the task is saved as if you export it.  To do so, simply right click on the saved .xml task file and select edit.  This should open up a notepad file and you'll want to search for the line <Author>example author name</Author> and change the name to something else.  You'll also find that within this file are all of the other settings and rules you created at the time the task was created, so you can easily search for a line that reflects a change you'd like to make and alter it right from the text file, which is great if you'd like to make a few changes prior to importing the file to a new computer.

I know I'm new around here, but I hope this information is at least partially helpful to someone and appreciate any feedback.




« Last Edit: March 02, 2015, 12:01:44 pm by ElscottHavoc »
GLD Tip Address:  DvwVGKumuYGV2PCRCeqEcW7TgvWB1EUvQz