title: Is there a way for a Chef recipe to continue after a reboot (Windows)?
body: <p>I am trying to use Chef to automate installation/deployment of an older version of a Windows product (Sharepoint 2007, specifically), and I almost have it working, but, at one point during the installation, the installer encounters an "application compatibility" problem and pops up a window that asks whether to continue or not.  If I click to continue, the installation continues to the end, and it works properly.</p>
  
  <p>I found a way to avoid the popup, by adding an "Appcompat" key in the windows registry, but if I use regedit to add the key during the Chef run, I have to get Chef to reboot the machine and then to continue with the rest of the installation afterwards.</p>
  
  <p>I've tried a recipe with something like:</p>
  
  <pre><code>reboot 'Restart Computer' do
    action :nothing
  end
  
  
  powershell_script "install-Sharepoint2007-PREREQUISITES" do
  code &lt;&lt;-EOH
  
  regedit /s .\appcompat.reg
  
  EOH
  
  notifies :reboot_now, 'reboot[Restart Computer]', :immediately
  
  end
  
  
  powershell_script "install-Sharepoint2007" do
  code &lt;&lt;-EOH
  
  ... the rest of the installation....
  
  EOH
  
  notifies :reboot_now, 'reboot[Restart Computer]', :immediately
  
  end
  </code></pre>
  
  <p>but the processing basically stops, after the reboot after setting the registry key.</p>
  
  <p>So I was wondering:  Is there a way to do this with Chef?</p>
  
  <p>Thanks,
  Jim</p>
  
  <p>EDIT:</p>
  
  <p>I find it hard to use just the comments because of lack of formatting so I'm adding information on what I have tried thus far here.</p>
  
  <p>Basically, the only way I can get the chef-client to run in a scheduled task so far is to do a "ONCE" scheduled task, setting the time for the task to run (so far, I'm manually setting the time in my schtasks command, just to test).  </p>
  
  <p>When I do that, and set the "/RU" to SYSTEM, I can see the "chef-client -o" start to run and it actually seems to complete, but I see errors in the Sharepoint installer logs, and in particular, it appears that some of the steps in the psconfig (the Sharepoint command line configuration tool) are failing.</p>
  
  <p>I think/guess that the reason for those failures is that the schtasks is running the "chef-client -o" as the wrong Windows user.</p>
  
  <p>The thing is, if I run the "chef-client -o" on the 2nd part cookbook "manually", i.e., if I log into the Windows machine and type:</p>
  
  <p>chef-client -o install-SHAREPOINT-PART2</p>
  
  <p>Then, Sharepoint gets installed and configured correctly.</p>
  
  <p>So, the thing I'm stuck on now is when I do that same "chef-client -o" command via schtasks, what should I use as the "/RU" and "/RP" for the schtasks command?</p>
  
  <p>Thanks,
  Jim</p>
  
  <p>EDIT 2:  Sorry, I forgot to include the schtasks line in the first cookbook/recipe, which sets up the task for the second cookbook/recipe chef run:</p>
  
  <pre><code>schtasks /create /tn Task_Name /tr "chef-client -o install-SHAREPOINT2007FULL-PART2" /sc once /RU "SYSTEM" /SD 06/27/2015 /ST 12:30
  </code></pre>
  
  <p>EDIT 3: The original reason that I was looking into this (having Chef work "through" a reboot) was that as part of installing Sharepoint, I had to set a Windows registry key, and I thought that I had to reboot to make that registry change effective for the rest of the install process.  </p>
  
  <p>However, I did some testing yesterday, and it appears that is not the case.  I can make the registry change, then do the rest of the installation, without having to reboot in between.</p>
  
  <p>So, bottom line is that I didn't need to process after the reboot after all.</p>
  
  <p>But anyway, hopefully some of the info here may help someone later.  The main thing I found was was I couldn't get it to work using ONSTART with the /Z /V1...  I had to use the ONCE and would have had to have code in my Chef recipe to figure out the date and time to fire the ONCE tasks.</p>