Windows 10 IoT Core is widely popular for Intel Galileo Gen 2, Raspberry Pi 2 and MinnowBoard MAX (when this project was written). Windows 10 IoT Core is essential for embedded projects.
Once Windows IoT Core is deployed on the device, is starts booting and default application starts at startup. If you are new to Windows 10 IoT Core, please click here to know more.
Now the tricky part is after each boot or reboot, default application starts. There is no app to register your application for startup except PowerShell to make Windows IoT Core much lighter as possible. So let's explore PowerShell.
Update (September 28, 2015): With the latest release of Windows 10 IoT Core, web-management portal is easy to use and provides simple way to register app as startup application without using PowerShell commands.
Update: September 28, 2015
You can register your Universal Windows App as startup application by using any of the following method:
- Web-Management Portal
- PowserShell
Web-Management Portal
Most simplest way to register you app as startup application. To do so, you just need to log-in to the Web-Management Portal hosted by Windows 10 IoT Core. This article is going to explore Web-Management Portal of the latest Insider Preview OS update(when this article was updated) '10.0.10531
'. You can find this update for specific board on Microsoft's IoT website.
In Step 4, you need to find out your application's package family name. It might be confusing sometimes. You can find your application's package family name by using Step 7 & 8 of the PowserShell method which is explained below.
PowerShell
As per wikipedia PowerShell: "Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework."
In informal way, it can be said to the more advance command prompt with scripting facility.
PowerShell Commands for IoT
Refer Microsoft's IoT website to see available commands for the Windows 10 IoT Core.
This project article is going to focus on the commands required to register an application as startup only.
Startup Command : IoTStartup
To view application you have deployed to your device, you can use following commands.
IotStartup list
lists all installed headed and headless application.
IotStartup headed list
lists all installed headed application.
IotStartup headless list
lists all installed headless application.
Headed application are those with user interface. Headless application does not have user interface instead they are background applications only.
IotStartup startup
lists headed and headless applications registered for startup.
IotStartup add
registers headed and headless applications as startup.
IotStartup add DefaultApp
registers factory default headed application as startup.
IotStartup remove
removes headed and headless applications from startup and registers back factory default headed application.
NOTE : Only two startup application can be there. One headed and another must be headless. Two headed or two headless can't be registered as startup.
Let's begin
In order to register your application as startup application, first you must have to deploy it to the device. If you are not familiar with deployment, see this webpage.
Step 1
Launch an PS console on your local PC. The easiest way to do this is to type ‘powershell’ in the “Search the web and Windows” textbox near the Windows Start Menu: Windows will find PowerShell on your machine:
To start PS as an administrator, right click on the “Windows PowerShell ISE” entry and select “Run as administrator”.
Step 2
Turn on WinRM service by typing: net start WinRM
Service will start and if it is already started you will see following screen:
Step 3
Note down your device name and IP address by using Windows IoT Core Watcher application:
Step 4
From the PS console, type the following, substituting <machine-name or IP Address>
with the appropriate value (using your machine-name is the easiest to use, but if your device is not uniquely named on your network, try the IP address):
Set-Item WSMan:\localhost\Client\TrustedHosts -Value <machine-name or IP Address>
When asks for to modify TrustedHosts, click on Yes button.
Step 5
Now you can start a session with you Windows IoT Core device. From you administrator PS console, type:
Enter-PSSession -ComputerName <machine-name or IP Address> -Credential <machine-name or IP Address or localhost>\Administrator
If you have changed password before then type that one else default password is p@ssw0rd
.
It will take 30 seconds - 1 minute to initialize session so be patient.
Step 6
Now session with your device has been initialized and you should see prompt like:
Step 7
Open your IoT project in Visual Studio 2015 and right-click on project from solution explorer and select properties. You can open project properties from Project menu.
Step 8
In general group, click on "Package Manifest...
" button and you will see:
You can modify package name. By default Visual Studio generates random name. After renaming package name, copy and note-down package family name.
NOTE : After changing Package name, you must re-deploy your application in order to register new package family name for the application.
Step 9
From PowerShell, type command to list all installed applications: IoTStartup list
In Step 8, we have collected Package Family Name. Find that family name into installed application list. If it is not there, your project has not been deployed to the device. Deploy it first.
Step 10
Copy text highlighted in yellow box from Step 9. Do not copy Headed :
.
IoTStartup add <your project's package family name + !App>
Hooray. Its done. Now your application is registered as startup application. To view startup application type: IoTStartup startup
Reboot your device by: shutdown /r /t 0
and your application will be started up after booting every time.
Reverting back to Default App
To revert back factory default app, you just need to type: IoTStartup add DefaultApp
After so, type again: IoTStartup startup
to verify that default app is registerd.
Known Issue
After registering your own application as startup, it is not possible to debug it with Visual Studio. Visual Studio shows error that the application you are trying to deploy is already running on the remote machine.
How to resolve this issue? To resolve this issue, you must have to revert back to default application in order to debug project. I have already explained how "Revert back to Default App" earlier in this article.
Comments