Saturday
Jun132015

"Kiosk Mode" in Windows 8.x

This little snippet of code came from a real project I worked on. The customer wanted a touch-screen Kiosk. We had to use Windows 8.1 due to hardware requirements. I was able to make a great WPF UX using touch and make it full screen with no borders, and always on top.

In your <Window> Xaml object set these properties: 

 WindowStyle="None" WindowState="Maximized" Topmost="True" ResizeMode="NoResize"

That only got me so far. That pesky right-swipe charm is always there, and there's seemingly no way to get around it.

Turns out all that charm stuff is in explorer.exe, the Windows Explorer. That's the shell that lets you run all your apps. It contains all the taskbar, and gives you all the swipy gestures, corner hot spots, and all that. All you need to do is kill it. 

Also turns out that if you don't kill it properly it will come back with a vengence. So, I discovered this little trick using a ProcessStartInfo object. I call this in the MainWindow_Loaded event and all is well.

If you ever want to restart Explorer after running this app, you can press Ctrl-Alt-Del, bring up the Task Manager and run explorer from File -> Run new task -> "explorer.exe"

Be careful, and enjoy!

        void KillExplorer()
        {
            // Create a ProcessStartInfo, otherwise Explorer comes back to haunt you.
            ProcessStartInfo TaskKillPSI = new ProcessStartInfo("taskkill", "/F /IM explorer.exe");
            // Don't show a window
            TaskKillPSI.WindowStyle = ProcessWindowStyle.Hidden;
            // Create and start the process, then wait for it to exit.
            Process process = new Process();
            process.StartInfo = TaskKillPSI;
            process.Start();
            process.WaitForExit();
        }

 

 

PrintView Printer Friendly Version

EmailEmail Article to Friend

References (46)

References allow you to track sources for this article, as well as articles that were written in response to this article.

Reader Comments (6)

foreach (var process in Process.GetProcessesByName("explorer"))
{
process.Kill();
}

June 18, 2015 | Unregistered CommenterPaulo Morgado

I haven't gotten around to looking in to this, but might the IoT SKU for Raspberry PI 2 be a better way to build a Kiosk?

June 18, 2015 | Unregistered CommenterJoe

Heard this from the dot net rocks podcast, and had to comment-- killing processes feels dirty to me and we had a similar problem in windows 2003/2008. our solution was to make our application a shell replacement. you just need to add a new value to the registry and the executable specified will be loaded on login instead of explorer.exe (and it can be per user, so a tech login can by pass it if troubleshooting is needed)

the key is HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System and you create a string value named "Shell" and the value is the exe you want to take the place of explorer.

AFAIK this should work in windows 8/8.1...

June 18, 2015 | Unregistered CommenterSteve

Errmmm there is a better way to enable Kiosk mode on Windows 8.1. Kiosk mode is a feature that's built in, and will run an app in Kiosk mode, with no charms etc. To log out you hit the Windows key 5 times (not an issue, as kiosks usually have keyboards hidden away)

I used this method at my last contract

http://blogs.msdn.com/b/hyperyash/archive/2013/10/25/enable-kiosk-mode-in-windows-8-1.aspx

You just need to setup a local account, login to create the profile, go back to your admin account, and under Settings -> PC Accounts, you can manage a local account to set Kiosk Mode.

Easy enough, and works like a charm, no pun intended

P.S. Love dotnetrocks. Been listening for years

Regards,

Glenn Edwards

June 19, 2015 | Unregistered CommenterGlenn Edwards

Awesome information in the post

July 4, 2015 | Unregistered CommenterGovt Jobs in India

thanks for sharing the useful information

August 6, 2015 | Unregistered CommenterLatestNews
Comments for this entry have been disabled. Additional comments may not be added to this entry at this time.
« Introducing "2 Keto Dudes" Ketogenic Lifestyle Podcast | Main | In Defense of Flavor »