# Windows IoT Core Application Management

## Overview

In this tutorial, we introduce a new Windows tool, called _PowerShell_. We'll be using PowerShell to configure our Blinky apps to automatically run at system startup.

![](https://cdn-learn.adafruit.com/assets/assets/000/034/466/medium800/projects_PS_installedApps.png?1469901696)

# Windows IoT Core Application Management

## PowerShell: Getting Started

Windows PowerShell is a command-line utility that runs on your Windows 10 computer, and allows you to execute commands on a Windows IoT device, like a Raspberry Pi.

PowerShell has lots of uses, but we’ll focus on setting applications to run at startup in Windows IoT.

PowerShell should appear in the `All Apps` submenu of your Start menu, as `Windows PowerShell`

Make sure you run PowerShell as “Administrator”. To do this, right-click on the PowerShell icon and select `Run as Administrator` from the popup.

![](https://cdn-learn.adafruit.com/assets/assets/000/034/123/medium800/projects_PowerShell_run_as_admin.png?1469034220)

If you can’t find it there, you can type `Windows PowerShell` into the Cortana box (lower left of your screen) to have Windows find it for you.

![](https://cdn-learn.adafruit.com/assets/assets/000/034/124/medium800/projects_Cortana_powershell_run.png?1469034279)

You’ll be asked if you want to allow PowerShell to make changes to your system. This is because you ran it as **Administrator**. Click **OK**. The PowerShell console window will open.

![](https://cdn-learn.adafruit.com/assets/assets/000/034/126/medium800/projects_PowerShell_Startup.png?1469034359)

Initially, PowerShell is open you the `windows\system32` directory on your computer. So, the first step we need to do is to connect PowerShell to your Windows IoT device.

PowerShell needs the **WinRM** service to be running on your computer. On the PowerShell command line, type

```auto
net start WinRM
```

![](https://cdn-learn.adafruit.com/assets/assets/000/034/127/medium800/projects_net_start_winrm.png?1469034490)

The next step is to establish a “trusted” relationship between your computer and the Windows IoT device. This is done with the **Set\_Item** command:

```auto
Set-Item WSMan:\localhost\Client\TrustedHosts –Value <machine-name or IP address>
```

Substitute the name of your IoT device, or use its IP address. Both are available on the standard Windows IoT start screen. Our Raspberry Pi still has the default name of **minwinpc** :

Windows will ask you to confirm that you want to modify the list of trusted computers. Reply ‘ **Y** ’ to confirm:

![](https://cdn-learn.adafruit.com/assets/assets/000/034/125/medium800/projects_Powershell_session_begin.png?1469034324)

With that out of the way, we can start a command line session on the Raspberry Pi. The command looks like this

```auto
Enter-PSSession -ComputerName <machine-name or IP Address> -Credential <machine-name or IP Address or localhost>\Administrator
```

Again, substitute the name or IP address of your Raspberry Pi. Mine is still&nbsp; **_minwinpc_** :

![](https://cdn-learn.adafruit.com/assets/assets/000/034/128/medium800/projects_Powershell_enter_session.png?1469034678)

When you execute the `Enter_PSSession` command, an authentication window will pop up. Enter the Windows IoT password for your Raspberry Pi. The default password is **p@ssw0rd**.

Enter your password and click **OK**. It may take a minute or so for the command to complete. When it does, you’ll see a new command-line prompt, showing that you are in a `Documents` directory. You are now ready to execute PowerShell commands on your Windows IoT Core Raspberry Pi:

![](https://cdn-learn.adafruit.com/assets/assets/000/034/129/medium800/projects_Powershell_session_begin.png?1469034726)

# Windows IoT Core Application Management

## PowerShell: Overview

We’ll be using PowerShell to set our startup applications, but it can do a lot more. See this page for a summary of the Windows IoT PowerShell commands

[Microsoft PowerShell Command Line Page](https://developer.microsoft.com/en-us/windows/iot/win10/tools/commandlineutils)
Meanwhile, let’s get started by listing the apps installed on the Windows IoT Raspberry Pi. In PowerShell, enter the command

```auto
IotStartup list
```

![](https://cdn-learn.adafruit.com/assets/assets/000/034/130/medium800/projects_PS_installedApps.png?1469034945)

This shows us that we have several Headed apps and a few Headless apps as well. The Headless apps include the BlinkyHeadless app, and a Dotstar app we’ve been working on for a future project tutorial.

In general, the application names are kind of dense looking. Lots of characters and numbers. You can pretty much ignore the clutter, because PowerShell can do pattern matching. So, instead of laboriously typing the entire app name into a command, you can just type part of it. For instance, we can enter the command

```auto
IoTStartup list Blinky
```

and PowerShell will just list the apps that match:

![](https://cdn-learn.adafruit.com/assets/assets/000/034/131/medium800/projects_PS_list_blinky.png?1469035030)

In this tutorial, we’re interested in setting startup apps. We can list the currently registered startup apps with the _IoTStartup startup_ command

```auto
IoTStartup startup
```

![](https://cdn-learn.adafruit.com/assets/assets/000/034/132/medium800/projects_PS_default_startup.png?1469035117)

The default headed startup app is _IoTCoreDefaultApp_. This is the app that put up the information screen on HDMI when you first booted your Pi. _ZWaveHeadlessAdapterApp_&nbsp;implements&nbsp;Z-Wave, a wireless communications protocol designed to allow devices in the home (lighting, appliances, etc.) to communicate with one another for home automation (see here:&nbsp;[https://developer.microsoft.com/en-us/windows/iot/samples/zwavetutorial](https://developer.microsoft.com/en-us/windows/iot/samples/zwavetutorial))

In the next section, we’ll register BlinkyHeadless as a startup app.

# Windows IoT Core Application Management

## Headless Apps at Startup

If you haven’t yet gone through the BlinkyHeadless tutorial, now is a good time to do so.

You should have BlinkyHeadless running from Visual Studio. That means that the app is already “deployed” on the Raspberry Pi.

[If you don’t see BlinkyHeadless in the list of apps, click here](https://learn.adafruit.com/windows-iot-application-management/help-2-dot-3-1-dot-1-blinkyheadless-or-blinkyheaded-don-t-appear-in-the-list-of-apps)
In PowerShell, enter the command

```auto
IoTStartup add headless BlinkyHeadless
```

Now, restart your pi from PowerShell. The easy way to do this is to enter the command

```auto
shutdown /r /t 0
```

![](https://cdn-learn.adafruit.com/assets/assets/000/034/133/medium800/projects_PS_AddBlinkyHeadless.png?1469035692)

Your Pi will perform an orderly shutdown, and will then reboot. This may take a few minutes, but you should see your LED start blinking when the restart is complete.

You can have as mny headless startup apps as you like.

# Windows IoT Core Application Management

## Headed Apps at Startup

The procedure for setting a headed app to run at startup is virtually identical to the procedure for setting up a headless app.

In the previous section, we rebooted the Pi, and (hopefully) the LED started blinking.

Have a look at the IoT Dashboard. When the restart is complete, you should see your Pi reappear in the **My devices** list. From the dashboard, open the **Device Portal** and navigate to the **Apps** page. You should see `BlinkyHeadless` in the list of Running apps.

Since we’re going to replace BlinkyHeadless with BlinkyHeaded, find `BlinkyHeadless` in the list of running apps and click the **X** ’ next to its name to stop it.

(We have to remove `BlinkyHeadless` because it uses the same GPIO pin as `BlinkyHeaded`. &nbsp;You can't run&nbsp;two apps that access the same pin!)

Now, make sure `BlinkyHeaded` runs correctly from Visual Studio (at the time of this writing there was a deployment bug in Visual Studio that happened when the Pi was restarted. The workaround is to close and reopen Visual Studio after the restart is complete).

Go back to PowerShell on your Windows computer. Since you rebooted, you’ll have to reconnect PowerShell to the Pi.

Re-enter the **Set\_Item** command (which establishes a trusted relationship between the computer and the Pi). You’ll be asked for your user name and password again. Then re-issue the **Enter-PSSession** command.

Both of these commands were explained in the PowerShell section of this tutorial, so refer back to that if you’ve forgotten them.

PowerShell should now be reconnected to your Pi. Enter the `IoTStartup` startup command to see that `BlinkyHeadless` is in the list of startup apps:

![](https://cdn-learn.adafruit.com/assets/assets/000/034/134/medium800/projects_PS_startuplist.png?1469035980)

The next step is to remove `BlinkyHeadless` as a startup app, and replace it with `BlinkyHeaded`.

Enter the following command to remove `BlinkyHeadless` from the startup list

```auto
IotStartup remove headless BlinkyHeadless
```

And enter the following command to add BlinkyHeaded to the startup list

```auto
IotStartup add headed BlinkyHeaded
```

[If you don’t see BlinkyHeaded in the list of apps, click here](https://learn.adafruit.com/windows-iot-application-management/help-2-dot-3-1-dot-1-blinkyheadless-or-blinkyheaded-don-t-appear-in-the-list-of-apps)
Let’s review: We stopped BlinkyHeadless, we removed BlinkyHeadless from the list of startup apps, and we added BlinkyHeaded to the list of startup apps. Enter the restart command in PowerShell.

You should already have an HDMI monitor attached to the Pi, from when you first developed BlinkyHeaded. Restart the Pi with the `shutdown /r /t 0` command. When the boot completes, you should see the BlinkyHeaded GUI on the monitor, and the LED should be blinking.

## Wait – what happened to the original Windows IoT Core GUI?

When you set BlinkyHeaded as the startup headed app, you replaced the default headed startup app. There can be only one headed startup app. But you can go back to the original app. It’s called IoTCoreDefaultApp, and you can set that back to be the headed startup app in PowerShell.

In this example, we issued the **IoTStartup startup** command to list the current startup apps. Then we issued the command **IoTStartup add headed IoTCoreDefaultApp** to set the headed startup app back to the default. Issuing the **IoTStartup startup** command again shows the change:

![](https://cdn-learn.adafruit.com/assets/assets/000/034/135/medium800/projects_PS_deafultstartup.png?1469036195)

# Windows IoT Core Application Management

## Help! BlinkyHeadless or BlinkyHeaded don’t appear in the list of apps!

You may run into a situation where PowerShell doesn’t list an app matching the name BlinkyHeadless or BlinkyHeaded. In my system, for example, there is no app named BlinkyHeaded. So, we’ll use BlinkyHeaded as an example in this section. Substitute BlinkyHeadless in this section if that’s the one you’re having trouble with.

Here’s where the dense, encoded-looking application names come into play.

When you run BlinkyHeaded from Visual Studio, you’ll see BlinkyHeaded in the list of running apps on the Device Portal Apps page:

![](https://cdn-learn.adafruit.com/assets/assets/000/034/136/medium800/projects_ShowBlinkyHeaded.png?1469036397)

Danger: 

You can see BlinkyHeaded in the running apps list, but it doesn’t seem to appear in the list of installed apps. Well, actually, it does appear in the list of installed apps, but the name is encoded. In the picture, look at the “Package Full Name”, all the way to the right of the BlinkyHeaded line. You’ll see that the package full name starts with **692c8bff…**. Now look at the list of installed apps. You’ll see that the first app in that list _also_ starts with **692c8bff…**. It’s the BlinkyHeaded app in disguise!

Your BlinkyHeaded app will have a different full package name. Use that in PowerShell to set the Headed startup app. I’ll use **692c8bff** here – but you should use the first few characters of your Blinky app’s package name

```auto
IoTStartup add headed 692c8bff
```

It’s possible that you wont have this problem on your system. But if you do, you can apply this solution to the problem.


## Featured Products

### Microsoft IoT Pack for Raspberry Pi 3 - w/ Raspberry Pi 3

[Microsoft IoT Pack for Raspberry Pi 3 - w/ Raspberry Pi 3](https://www.adafruit.com/product/2733)
The **Microsoft Internet&nbsp;of Things&nbsp;Pack for Raspberry Pi 3** &nbsp;is the best way to get started using Windows 10 and your Raspberry Pi as an IoT enabled device.

A collaboration between Microsoft's IoT division and Adafruit, this pack's the best way to get...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2733)
[Related Guides to the Product](https://learn.adafruit.com/products/2733/guides)
### Microsoft IoT Pack for Raspberry Pi 3 - No Pi

[Microsoft IoT Pack for Raspberry Pi 3 - No Pi](https://www.adafruit.com/product/2702)
The **Microsoft Internet&nbsp;of Things&nbsp;Pack for Raspberry Pi 3** is the best way to get started using Windows 10 and your Raspberry Pi as an IoT enabled device.

A collaboration between Microsoft's IoT division and Adafruit, this pack's the best way to get...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/2702)
[Related Guides to the Product](https://learn.adafruit.com/products/2702/guides)

## Related Guides

- [Getting Started With Windows IoT Core on Raspberry Pi](https://learn.adafruit.com/getting-started-with-windows-iot-on-raspberry-pi.md)
- [Windows IoT Core Application Development: Headed Blinky](https://learn.adafruit.com/windows-iot-application-development-headed-blinky.md)
- [Windows IoT Core Application Development: Headless Blinky](https://learn.adafruit.com/windows-iot-application-development-headless-application.md)
- [Adafruit Class Library for Windows IoT Core](https://learn.adafruit.com/adafruit-class-library-for-windows-iot-core.md)
- [Adafruit GPS Hat in Windows IoT Core](https://learn.adafruit.com/adafruit-gps-hat-in-windows-iot-core.md)
- [Programmable 12v Outdoor Cafe Lights](https://learn.adafruit.com/programmable-12v-outdoor-cafe-lights.md)
- [Wireless LED Juggling Balls with ESP-NOW](https://learn.adafruit.com/wireless-juggling-balls-esp-now.md)
- [Adafruit NeoPixel Überguide](https://learn.adafruit.com/adafruit-neopixel-uberguide.md)
- [ISS Pin](https://learn.adafruit.com/iss-pin.md)
- [MagicLight Bulb Color Mixer with Circuit Playground Bluefruit](https://learn.adafruit.com/magiclight-bulb-mixer.md)
- [Arcade Synth Controller](https://learn.adafruit.com/arcade-synth-controller.md)
- [Controlling Motors using the Raspberry Pi and RasPiRobot Board V2](https://learn.adafruit.com/controlling-motors-using-the-raspberry-pi-and-raspirobot-board-v2.md)
- [Adafruit Pixel Trinkey](https://learn.adafruit.com/adafruit-pixel-trinkey.md)
- [Adafruit Sparkle Motion Stick](https://learn.adafruit.com/adafruit-sparkle-motion-stick.md)
- [Battery Power for LED Pixels and Strips](https://learn.adafruit.com/battery-power-for-led-pixels-and-strips.md)
