Click here to Skip to main content
15,885,767 members
Articles / Programming Languages / C#
Article

User Interface Replacement for Explorer

Rate me:
Please Sign up or sign in to vote.
4.32/5 (11 votes)
16 Sep 20074 min read 73.8K   1.5K   48   6
Replace Explorer User Interface with your own User Interface for Kiosks
Screenshot - UserInterface1.png

Introduction

The desktop that most people use with Windows 2000 and Windows XP is called the Explorer User Interface. This is an application at C:\Windows\explorer.exe. The Explorer User Interface gives us the power to access our Windows System through the use of the task bar, desktop, and Explorer directory browser. On some systems, the Explorer User Interface provides too much flexibility and user control. On Kiosk systems, you would probably want to limit the user's interaction only with the Kiosk application but still give the administrator some user interface to restart the Kiosk application or execute maintenance. This article is about replacing the standard Explorer User Interface with your own user interface.

Please note that this article covers changing system settings that could potentially limit access to your computer. The demo software does contain multi methods to try and limit this possibility, but run the demo at your own risk.

Background

We want to create a kiosk system that limits people from gaining access to our computer. You can try and limit access by various means, but sometimes the access is not restrictive enough or too restrictive. How many times have you seen kiosks that got corrupted and could not be restarted by the regular attendants? We want to alleviate this problem by giving the attendant some ability to restart the kiosk software. We will accomplish this by having the kiosk software run on top of a user interface. If the kiosk software fails, the user interface is present to allow the software to be restarted. Some places try and do this by changing many registry settings to disable applications, disable using the command line interpreter, etc., but most of this increased security just creates maintenance problems. Instead of configuring the user interface, let's just replace it.

This is not security by obscurity. This is security by limiting the user's interface. There is a setting in the group policy that does all this for us. See the following image:

Sample Image - maximum width is 600 pixels

The Custom User Interface setting allows us to use our own user interface instead of the standard Explorer. The trick is to know what to put on our own user interface to restrict access but allow for simple maintenance. In this following example, we are using the command line interpreter as the application that we want to remain running. On login, the User Interface application is started and the command line interpreter is started. Every 10 seconds, we check to ensure that there is a command line interpreter executing, otherwise we start a new one.

We need to provide access to administrators. This can be accomplished by enabling buttons based upon the user's security level (e.g. part of the Administrators group). For this example we have not implemented that but we do provide the "Group Policy Editor" button to access the group policy editor and the Command interface to execute any application on your system. These two features should ensure that you are able to switch back to the Explorer User Interface.

Please note that if you run explorer, the Explorer User Interface is launched and the familiar task bar will appear. The group policy editor can be run by entering gpedit.msc in the command line interpreter or Start > Run.

Using the User Interface

You can see how this works by copying UserInterface.exe to a simple to access directory. For this example we will use C:\. Launch the application and you will get the black screen above.

  1. Click the Group Policy Editor button
  2. Browse to Local Computer Policy > User Configuration > Administrative Templates > System
  3. Double click Custom User Interface
  4. Select Enabled
  5. In the Interface File Name text box, enter C:\UserInterface.exe
  6. Restart your computer

When you restart the computer, you will be using the new user interface. As long as you do not run explorer, you will remain in the new user interface. To restore Explorer as the system interface, follow these instructions:

  1. Click the Group Policy Editor button
  2. Browse to Local Computer Policy > User Configuration > Administrative Templates > System
  3. Double click Custom User Interface
  4. Select Not Configured
  5. Restart your computer

Using the Code

The MainForm is a really ugly GUI which provides limited functionality. It starts the command line interpreter and checks to see if it is running.

C#
private void ActionMonitorProcess() 
{
    System.Diagnostics.Process[] processes = 
            System.Diagnostics.Process.GetProcesses();
    for (int i = 0; i < processes.Length; i++) 
    {
        if (processes[i].ProcessName == COMMAND_PROCESS_NAME) 
        {
            return;
        }
    }
    LaunchCmd();
}

If the command line interpreter is not running, it is started:

C#
private void LaunchCmd() 
{
    string s = "";
    try 
    {
        System.Diagnostics.Process.Start(COMMAND);
        timerCmd.Start();
    } 
    catch (Exception ex) 
    {
        s = "Could not launch the command line processor." + NL + NL;
        s += ex.Message + NL + NL;
        s += ex.StackTrace;
        textBoxMain.Text = s;
        timerError.Start();
    }
}

As you can see, we use the System.Diagnostics classes to create and monitor processes. The most complicated one, which is not complicated at all, is the command:

C#
private void CmdExecute() 
{
    string s = "";
    string command = textBoxCommand.Text.Trim();

    // check to see if there is a command to execute
    if (command.Length == 0) 
    {
        return;
    }

    // break off the command into the command and the arguments
    string[] arr = command.Split(new char[] { ' ' });
    command = arr[0];
    string arguments = "";

    for (int i = 1; i < arr.Length; i++) 
    {
        if (arguments.Length > 0) 
        {
            arguments += " ";
        }
        arguments += arr[i];
    }

    // execute the command
    try 
    {
        System.Diagnostics.ProcessStartInfo o = 
        new System.Diagnostics.ProcessStartInfo(command, arguments);
        System.Diagnostics.Process.Start(o);
    } 
    catch (Exception ex) 
    {
        s = "Could not launch " + textBoxCommand.Text.Trim() + "." + NL + NL;
        s += ex.Message + NL + NL;
        s += ex.StackTrace;
        textBoxMain.Text = s;
        timerError.Start();
    }
}

Even the logging off and shutting down is just an execution of a process:

C#
private void CmdExit() 
{
    if (APPLICTION_MODE) 
    {
        Application.Exit();
        return;
    }

    ShutdownDialog dlg = new ShutdownDialog();
    if (dlg.ShowDialog() == DialogResult.Cancel) 
    {
        return;
    }

    string arguments = "";
    string s = "";

    if (dlg.ShutdownType == ShutdownType.Restart) 
    {
        arguments = "-r -t 00";
    } 
    else if (dlg.ShutdownType == ShutdownType.Shutdown) 
    {
        arguments = "-s -t 00";
    } else 
    {
        arguments = "-l -t 00";
    }

    try 
    {
        System.Diagnostics.ProcessStartInfo o = 
        new System.Diagnostics.ProcessStartInfo(SHUTDOWN, arguments);
        System.Diagnostics.Process.Start(o);
    } 
    catch (Exception ex) 
    {
        s = "Could not shutdown the application." + NL + NL;
        s += ex.Message + NL + NL;
        s += ex.StackTrace;
        textBoxMain.Text = s;
        timerError.Start();
    }
}

Conclusion

Creating a basic user interface for a limited access computer or kiosk system is very simple and all the functionality is currently present in Windows. Creating your own user interface may be much easier than trying to lock down the computer using security and policy settings--especially for small organizations that do not have the administrative knowledge in-house.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect
United States United States
Michael Carey is the Head of Development for an Automation Integrator in Philadelphia, PA. Michael specializes in Batch Automation, Process History, and Factory to Enterprise Integration.

Comments and Discussions

 
QuestionDeveloping a Kiosk environment Pin
Member 1055860029-Jan-14 7:49
Member 1055860029-Jan-14 7:49 
Hi,

As apart of a monitoring system, I need the ability to secure the system (the kiosk) as best I can. I would like to use this as the base for the shell and I noticed that while there is no explicit statement going over it's usage I did notice the copyright symbol you have put on your code.

In short, is it OK if I use this code as a base for my kiosk environment?

Thanks!
QuestionHow to change user interface for some users only... Pin
yarns14-May-08 21:56
yarns14-May-08 21:56 
AnswerRe: How to change user interface for some users only... Pin
zam66415-May-08 1:58
zam66415-May-08 1:58 
GeneralRe: How to change user interface for some users only... Pin
yarns15-May-08 3:05
yarns15-May-08 3:05 
GeneralSimilar work successfully in use. Pin
davepermen16-Sep-07 21:21
davepermen16-Sep-07 21:21 
GeneralRe: Similar work successfully in use. Pin
NovaNuker22-Oct-07 21:13
NovaNuker22-Oct-07 21:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.