Click here to Skip to main content
15,881,863 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hello friends.
i have a windows form and want to when a program start, Explorer.exe disable and when user click on specific button, explorer.exe starts and show taskbar and start menu correctly.
here is my problem: when my program starts working, explorer.exe disable correctly and there is no problem.but when i click button1, just "My Document" window appear and taskbar and start menu are invisible. note that when i start explorer.exe by cmd there is not any problem and taskbar and start menu become visible, but when i execute same command by c#, just my document window appear.
here is my code:
C#
  public Form1()
        {
            InitializeComponent();
            System.Diagnostics.Process process = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new    System.Diagnostics.ProcessStartInfo();
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo.FileName = "cmd.exe";
            startInfo.Arguments = "/C Taskkill /IM explorer.exe /F";//command for kill explorer.exe process
            process.StartInfo = startInfo;
            process.Start();

        }

private void button1_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process process = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo.FileName = "cmd.exe";
            startInfo.Arguments = "/C explorer.exe /F";//command for start explorer.exe
            process.StartInfo = startInfo;
            process.Start();

        }


please someone help me.
thanks in advance.
Posted

1 solution

First, Explorer.exe is one of those process that you DO NOT SCREW WITH.

The command line to launch it is "explorer.exe", not "CMD /C explorer.exe /F".

The /F switch is not valid in Explorer. It, or any other invalid switch, will force Explorer to open a single window opened to MyDocuments for the current user. It will not start the entire Explorer process with a complete desktop.

There is no guarantee that the entire Explorer process (with desktop) will launch correctly when you try to restart it. There is no way to fix any such situation as you have to restart Windows to get it to work correctly again.
 
Share this answer
 
Comments
Ron Beyer 21-Jul-13 10:10am    
+5, killing Explorer.exe is not an acceptable. solution for keeping the user off the desktop/system.
hamed1991 21-Jul-13 13:57pm    
OK, your solution sounds be useful. but how?
how can in keep the user off the system?
Dave Kreskowiak 21-Jul-13 16:53pm    
You have to setup Windows in Kiosk mode. There's various registry values you have to create, which you can find at http://www.lockergnome.com/it/2011/04/12/kiosk-mode-with-windows-7.

After that, you have to go through Group Policy (run gpedit.msc) and configure a ton of settings the way you want for your particular kiosk.

I would also suggest creating a normal user account and severely restricting it so it only has access to the resources it needs to run your app.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900