6

The following is a hack, but for what I need it for its fine.

I created a C# program that shows some EULA text and has an Agree and Disagree button.

I set the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell to launch that program.

When the computer boots, the normal login prompt shows.

After logging in, the custom EULA program launches.

There is no explorer shell, no start menu, no background, etc. (which is what I want).

The disagree button shuts down the pc and works fine.

I want the Agree button to load the normal windows explorer shell (start menu, background, etc).

I used the following C# command: Process.Start("explorer.exe");

However this launches an explorer window, not the shell. I want the shell to launch.

What am I missing?

  • 2
    is explorer.exe already running as the desktop process when you invoke it? if there is no instance of explorer running for the login, it will spawn the desktop process, but if it is already running, it will spawn an explorer window. in what context is your application running? I assume it is before login? if not, the netlogin process has probably already spawned your desktop process. – Frank Thomas Sep 12 '13 at 16:45
  • No, explorer.exe is not running when the custom shell is launched. It doesnt run till I click the agree button. I assume I need to start something other than explorer.exe... I dont know... – Keltari Sep 12 '13 at 17:04
  • Are you doing this for RDP connections or do you need to show your EULA for locally logged on users too? If RDP only try using this group policy (the site can be flaky in non IE browsers) instead of the registry key you are using. – Scott Chamberlain Sep 12 '13 at 17:41
  • looking at this article, it doesnt look like this method will work... social.technet.microsoft.com/Forums/windows/en-US/… – Keltari Sep 12 '13 at 19:28
  • 1
    I'd highly question the need to replace the entire Shell just to show a EULA. Global solution to a local problem. – surfasb Sep 14 '13 at 4:11
3

In Windows10, to restart an Explorer Desktop you must set Shell registry key to "explorer.exe" and kill the process "sihost.exe" or restart a new "sihost.exe" process.

  • That's it, restarting sihost.exe did it for me. Thanks a lot! – cheeesus Jul 24 '18 at 7:13
2

I do the exact same thing as you are doing, here is how I am launching Explorer

Process explorer = new Process();
explorer.StartInfo.FileName =
    Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "explorer.exe");
if (explorer.Start() == false)
{
    MessageBox.Show("Explorer failed to start.");
}
else
{

    //(Snip) some other code that is not relevant.

    explorer.WaitForExit();
}

//(Snip) some cleanup code I run after the user logs off.

and it works fine.

Now I am doing this inside a RDP session using this group policy (Computer Configuration\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Remote Session Environment\Start a program on connection) not via the registry file you are using, so maybe that is why it works for me and not for you.

One other thing I may be doing different is I also call explorer.WaitForExit(); in my code and wait for explorer to close itself before closing my app.

Try using the way I start explorer and see if it works for you.

  • I tried your code, but it just launches a file explorer window, not the shell – Keltari Sep 12 '13 at 19:27
  • @Keltari do you need to support local logins or will only showing the EULA for RDP users work for what you want to do? – Scott Chamberlain Sep 12 '13 at 22:34
1

Explorer must see some fulfilled conditions to launch as shell:

  1. Explorer must not run (which includes Control Panel, for instance)
  2. Explorer must see it is the actual shell - hence you need to replace that value before launching explorer.exe (could change it back a few seconds later)
  3. Sometimes it seems (on newer Windows versions) it depends on the process that launches explorer.exe - if it is "known" to explorer.exe -- I don't have any more details for this part though (and you couldn't change it, unfortunately)

Judging from your question you are at least missing part 2.

-1

Modify registry,put explorer.exe to shell, start new explorer.exe process (you does not have any process explorer.exe running) and return shell to your shell (empty value if needs).

  • 1
    Please rewrite this in clear English (i.e., multiple complete sentences with correct grammar).  Expand shorthand like ‘‘modify registry’’ to usable instructions. Do not respond in comments; edit your answer to make it clearer and more complete. – G-Man Oct 12 '17 at 20:39

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.