Carey Payette
Published © GPL3+

Windows IoT Core: Running a PowerShell Script on Startup

Windows IoT Core: Running a PowerShell Script on Startup

IntermediateProtip9,987
Windows IoT Core: Running a PowerShell Script on Startup

Things used in this project

Software apps and online services

Windows 10 IoT Core
Microsoft Windows 10 IoT Core

Story

Read more

Code

StartupScript.ps1

Powershell
PowerShell script that is to be run at startup of the Windows IoT Core OS.
# startup script
$logFile = 'C:\startupLog.txt'
get-date >> $logFile

Startup.bat

Plain text
Batch file that is called from the scheduled task. Executes the PowerShell file.
powershell -command "C:\StartupScript.ps1"

PowerShell Remote Execution Policy

Powershell
Setting the Remote Execution Policy so that PowerShell scripts can be run.
Set-ExecutionPolicy RemoteSigned

(Optional) Permanently Adding System32 to the System Path

Plain text
Permanently Adding System32 to the System Path
setx PATH "%PATH%;C:\Windows\System32"

Creating a scheduled startup task

Plain text
Creating a scheduled task on Windows IoT Core to execute a batch file upon startup.
schtasks /create /tn "Startup PowerShell" /tr c:\Startup.bat /sc onstart /ru SYSTEM

Deleting a Scheduled Task

Plain text
Deleting a Scheduled Task
schtasks /Delete /TN "Startup PowerShell"

Running a scheduled task

Plain text
If you want to test out your task, you can run it from the command line
schtasks /Run /tn "Startup PowerShell"

Credits

Carey Payette

Carey Payette

13 projects • 134 followers
Sr. Software Engineer at Independent

Comments