Hiding First Setup During OSD

I have been working on a task sequence all week with a custom background showing the progress of the task sequence on different images. However when you get to the Windows setup, the black “Setup is preparing…” window comes up, if you have lots of post Windows tasks like my customer such as configuration, software installs etc then you never see your swanky background. Can we remove the background? Most certainly can.

FirstUxWnd

You have all seen this before, you are running your task sequence with a custom background maybe just the defaults from the UDI wizard in MDT, or your own custom background. However, when you get to this phase your background disappears.

We can hide this window using some compiled C# which invokes a couple of API methods to hide the window. The two we use here are FindWindow and ShowWindow. We first need a couple of API calls which we do as follows:

[DllImport("user32.dll", SetLastError = true)] internal static extern int FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", SetLastError = true)] internal static extern int ShowWindow(int hwnd, int nCmdShow);

Then from here it is a simple case of getting the handle of the window which we know to be FirstUxWnd and then issuing a command to hide the window.

// Hide Window : 0 = Hide, 1 = Show
if (hwnd != 0) { ShowWindow(hwnd, 0); }

Sorry the code doesn’t wrap very well at all in WordPress, however I have compiled the executable which you can find on my SkyDrive: http://sdrv.ms/15IFSYJ

If you would like the basic source code, then you can also find this on my SkyDrive: http://sdrv.ms/15IGfCR

Hope this is something people will find useful especially for making your state restore phase back to it’s pretty self.

Tags: , , , , , , , , ,

About Martyn

Martyn is a Senior Azure Consultant with Ensono. He is responsible for working with clients on the implementation of their Microsoft Azure environments and strategies on DevOps. Martyn is a regular speaker at Microsoft events and community events on Azure and DevOps, giving his insight to a growing number of audiences.

One response to “Hiding First Setup During OSD”

  1. Jack says :

    Have you looked at a way to do the same thing in Windows 10 yet? It doesn’t seem like any of the previous methods works to allow BGInfo custom screens to display after the “Setup Windows and SCCM Advanced Client” task…

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.