Friday, 16 September 2011

Windows startup script not running Windows 7 wireless clients

So many administrators are posting about their woes with Windows 7 processing group policy computer startup scripts.


The Root Cause

The root cause of this problem is that Window 7 simply ignores the group policy settings "Computer Configuration\Administrative Templates\System\Logon\Run logon scripts synchronously" and "Computer Configuration\Administrative Templates\System\Logon\Always wait for the network at computer startup and logon" that previously worked so well in Windows XP.


Some Background

I previous wrote a BLOG post about how to make the netlogon service start correctly on wireless clients by adding some service dependencies to netlogon service itself. This unfortunately still doesn't make the computer startup script run on all wireless clients.


The Solution

Here is a quick solution that will ensure group policy computer startup scripts are executed when the computer boots and its so easy, two words, task scheduler.
I have created a task that runs on startup with a 1 minute delay, runs as SYSTEM user and executes my computer startup script, I have then deployed this script with System Center Configuration Manager to all of my wireless clients. Yes it does mean that some of my clients will run the computer startup script twice, but at 300ms to complete the entire script, I am sure this won't inconvenience my users too much.

This is so easy it feels like cheating, but it solves my problems and all my computer startup scripts are running perfectly again.

Below is an example of a task schedule, you just need to replace "<Command>\\domain.local\scripts\launch.cmd</Command>" with the path to your startup script and then save it as "startupscript.xml".
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2011-09-16T13:31:06.4110949</Date>
    <Author>Administrator</Author>
  </RegistrationInfo>
  <Triggers>
    <BootTrigger>
      <Enabled>true</Enabled>
      <Delay>PT1M</Delay>
    </BootTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-18</UserId>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>\\domain.local\scripts\launch.cmd</Command>
    </Exec>
  </Actions>
</Task>
You can import the startupscript.xml file with the following command.
schtasks.exe /create /XML startupscript.xml /TN startupscript
To make it easier to deploy I put that into a SCCM package and deploy it to all my Wireless clients. Voila, problem solved!

No comments:

Post a Comment