How to run a command in PowerShell on startup?

Hi,

I’m new here. I just want to know how could I run a command in PowerShell automatically every time I turn on my PC. The command is this one:

“$i=99999900; while (1) { $j=[System.Math]::Sqrt($i); write-host $i,:,$j; $i=($i+1)%99999999; }”

It is just a counter to keep my CPU busy for preventig BSODs due to a faulty processor. Anyone knows how can I achieve this?

Thanks in advance!

I realize your question isn’t really related to PoshTools but…

You can always run a PS script via task Scheduler on Start up: https://www.sevenforums.com/tutorials/67503-task-create-run-program-startup-log.html

You could also create a registry entry under

HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

with
powershell.exe -command “$i=99999900; while (1) { $j=[System.Math]::Sqrt($i); write-host $i,:,$j; $i=($i+1)%99999999; }”

1 Like