Set Network Location automation during Windows 7 Audit mode.

When automating installation of Windows 7 and booting to Audit mode you may see the “Set Network Location” prompting you to set Home, Public, or Work Network. If this is an issue for you and you would like to close this window. The following sample script worked for me to close the windows as part of automated installation.

Copy the following to a text file and save as: Closewin.vbs:

Set WshShell = Wscript.CreateObject("WScript.Shell")
Do While Not Wshshell.AppActivate ("Set Network Location")
Wscript.sleep 100
Loop
Wshshell.AppActivate "Set Network Location"
Wshshell.SendKeys "%{F4}"

Calling VBS script from autounattend.xml using the ‘RunAsynchronousCommand’ (Synchronous command will wait and not work):

    <settings pass="auditUser">
        <component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="https://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance">
            <RunASynchronous>
                <RunAsynchronousCommand wcm:action="add">
                    <Description>Close Window</Description>
                    <Order>1</Order>
                    <Path>wscript e:\closewin.vbs</Path>
                </RunAsynchronousCommand >
            </RunASynchronous>
        </component>
    </settings>