How can I make sure Windows has established network connections on login before my program is run?
To reduce login time Windows does not wait for the network to be fully initialized at startup or login. This means that programs run on startup may not be able to contact remote computers.
To change this you must set the following DWORD value to 1 (create it if it doesn't exist):
More details on Windows Fast Logon Optimization feature
By default in Windows 8, Windows 7 and Windows Vista, the Fast Logon Optimization feature is set for domain and workgroup members. Policy settings apply asynchronously when the computer starts and when the user signs in. As a result, Windows 8, Windows 7 and Windows Vista do not wait for the network to be fully initialized at startup and sign-in. Existing users are logged on by using cached credentials. This results in shorter logon times. Group Policy is applied in the background after the network becomes available. Be aware that, because this is a background refresh, extensions such as Software Installation and Folder Redirection take two logons to apply changes. Additionally, changes that are made to the user object, such as adding a roaming profile path, root directory, or user object logon script, may take two logons to be detected.
If you turn off this feature, Windows waits for the network to be fully initialized before users are logged on. This results in the synchronous application of policies when the computer starts and when the user logs on. This application of policies resembles a background refresh process and can reduce the time that is required for the Logon dialog box to display and the time that is required for the shell to be available to the user. An administrator can change the default by using the Group Policy MMC snap-in.
Fast Logon Optimization is always off during logon when a user first logs on to a computer.
You should be aware that, under the previous conditions, computer startup can still be asynchronous. However, because logon is synchronous under these conditions, logon does not exhibit optimization.
When your folder redirection policy is not completely applied at first logon, you can find the following warning in the event log:
Folder redirection and software installation policies
Be aware that when logon optimization is turned on, a user may have to log on to a computer two times before folder redirection policies and software installation policies are applied. This is because applying these kinds of policies requires the synchronous policy application. During a policy refresh (which is asynchronous), the system sets a flag that indicates that applying folder redirection or a software installation policy is required. The flag forces synchronous application of the policy at the user's next logon.
Be aware that Windows clients support Fast Logon Optimization in any domain environment. To turn off Fast Logon Optimization, you can use the following policy setting:
Computer Configuration\Administrative Templates\System\Logon\ Always wait for the network at computer startup and logon
When this policy is enabled, a Windows 7 or Windows 8 client behaves in the same manner as a Windows 2000 client at both system startup and at user logon.