I want the script to run as soon as I press the power button, WITHOUT ANYONE LOGGING IN. Hence why I cannot simply use the startup folder or the task scheduler, as both of these only call programs when a user logs in.

Why I need this:

I'm attempting to setup a headless Ethereum miner on my old Windows 10 PC. Sometimes I experience short power blips at home, just long enough to knock the miner offline. I would like to be able to restart the mining process simply by pressing the power button, instead of going through the whole hassle of dealing with RDP.

My script:

@echo off
echo Starting Etherminer >> log.txt
goto START


etherminer.exe --farm-recheck 200 -G -S us1.ethermine.org:4444 -FS us2.ethermine.org:4444 -O <My_Wallet_Hash>.<My_System_Name> >> log.txt 2>>&1

echo Error: Etherminer Application Exited >> log.txt
echo Attempting to Restart >> log.txt

goto START

The script runs fine on its own, but now I need help getting it to launch when the system is powered on.

Thank you for your time, and for whatever help you may be able to provide.


You could simply use Windows's "Task Scheduler" to execute a script on power on (assuming that you have administrative permissions). To create a new task do the following:

  1. Press WINDOWS+R on your keyboard
  2. Enter "taskschd.msc" and press ENTER
  3. Click on "Create Basic Task...", which is located in the section called "Actions"
  4. Now the wizard will help you to create your task

To start the task on system startup you also need to do the following (after you did the steps above and selected "At startup" as your trigger):

  1. Double click on the task you created earlier
  2. Click on "Change User or Group..."
  3. Enter "LocalService" and press ENTER
  4. Goto the "Conditions" tab and uncheck everything unless you want a condition
  5. Click on "OK" to save the changes

After testing your new task you might wonder why your task doesn't get triggered on Windows 8 or Windows 10 by using "Shut down" and then powering your pc on again.That's caused by a function called "fast startup" which is enabled by default on every Windows 8 or 10 system, it achieves faster startups by hibernating the core system, which only copies the ram data of the kernel and other system-relevant components to a file on your hard drive on shutdown and copies that data back on startup.So your task usually never gets triggered because the system never does a full shutdown and never does a full startup except by doing system updates or using the "Restart" function of windows.

To deactivate "fast startup" go to "Control Panel > Hardware and Sound > Power Options > System Settings" and uncheck the "Turn on fast startup" box.

To run a script at startup without disabling "fast startup" take a look at RunAsService which helps you to register a script as a service. Example for a BAT script:

RunAsService.exe install "yourservicename" "C:\Windows\System32\cmd.exe" "/C C:\Program Files\myscripts\dosomething.bat"

TIP: If RunAsService.exe returns "A referral was returned from the server.", open it's properties, go to the tab "Compatibility", click on "Change settings for all users", check "Run this program as an administrator" and click twice on "OK".

Another way of running a script/program on every startup without disabling "fast startup" is using "taskschd.msc" to set a task whose trigger is a system event generated on each startup even if "fast startup" is enabled.

  • I tried this, but for whatever reason, the script still only executed when I logged in. – Chef Cyanide Jun 28 '17 at 19:37
  • I forgot some things in my answer, so I updated it. – testeaxeax Jun 30 '17 at 16:50

Maybe have your computer automatically log in? Run> “control userpasswords2” and untick require password to log in.

Or perhaps you can reference the script in the Registry: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

  • Interesting. Being more of a Unix person, I never would have thought to use the registry. I'll look into it and get back to you – Chef Cyanide Jun 28 '17 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.