8

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?

7
  • 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. Sep 12, 2013 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, 2013 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. Sep 12, 2013 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, 2013 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, 2013 at 4:11

7 Answers 7

5

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.

1
  • That's it, restarting sihost.exe did it for me. Thanks a lot! Jul 24, 2018 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.

2
  • I tried your code, but it just launches a file explorer window, not the shell
    – Keltari
    Sep 12, 2013 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? Sep 12, 2013 at 22:34
2

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

On Windows 64-bit the 32-bit explorer.exe does not start the user shell.

  • c:\windows\explorer.exe is the 64-bit version.
  • For 64-bit programs c:\windows\syswow64\explorer.exe is the 32-bit version.
  • For 32-bit programs c:\windows\system32\explorer.exe is the 32-bit version and c:\windows\system32 is used before c:\windows.

When explorer.exe is not running as user shell:

  • calling explorer.exe from 32-bit program starts an explorer window.
  • calling explorer.exe from 64-bit program starts the explorer as user shell.
  • calling c:\windows\explorer.exe starts the explorer as user shell.

Tested on Windows 10.

0

What I experienced when I followed the instructions on how to install a custom Shell, by installing and using Microsoft's Shell Launcher, I would first see my custom shell appear (without the taskbar, etc), but then the moment I launched Windows Explorer it would display the taskbar. See: https://docs.microsoft.com/en-us/windows-hardware/customize/enterprise/shell-launcher

0

Based on the working answer of @Jieff, I created a batch script to escape the custom shell.

@echo OFF

echo|set /p="Escape (1/6) - Changing shell to explorer.exe .......................... "
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell /t REG_SZ /d "explorer.exe" /f > NUL 2>NUL
IF %ERRORLEVEL% == 0 ( ECHO OK! ) ELSE ( ECHO FAIL! )

echo|set /p="Escape (2/6) - Killing sihost.exe ...................................... " 
taskkill /F /IM sihost.exe > NUL 2>NUL
echo OK!

echo|set /p="Escape (3/6) - Waiting some time for sihost.exe to shutdown ............ " 
timeout /T 5 /nobreak > NUL 2>NUL
echo OK!

echo|set /p="Escape (4/6) - Restarting sihost.exe ................................... " 
start sihost.exe > NUL 2>NUL
echo OK!

echo|set /p="Escape (5/6) - Waiting some time for sihost.exe to start ............... " 
timeout /T 15 /nobreak > NUL 2>NUL
echo OK!

:: 6/6 could be a REG change back to the previous custom shell for the next system (re)start. The explorer shell will still be available.
-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
  • 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. Oct 12, 2017 at 20:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .