Temp script missing on reboot?

Aug 7, 2013 at 8:56 PM
I just wrote and tested my first Boxstarter package and received the following error upon reboot:

C:\Windows\system32>Call powershell -NoProfile -ExecutionPolicy bypass -command
"Import-Module 'C:\Users\Administrator\AppData\Roaming\Boxstarter\Boxstarter.Boo
tstrapper\boxstarter.bootstrapper.psd1';Invoke-Boxstarter -RebootOk"
Boxstarter Version 1.1.18
(c) 2013 Matt Wrock http://boxstarter.codeplex.com
  • Boxstarter starting Installation session.
    No Script was specified to call.
    Remove-Item : Cannot find path 'C:\Users\ADMINI~1\AppData\Local\Temp\1\Boxstarter.Script' because it does not exist.
    At C:\Users\Administrator\AppData\Roaming\Boxstarter\Boxstarter.Bootstrapper\Cleanup-Boxstarter.ps1:11 char:24
  • remove-item <<<< "$env:temp\Boxstarter.Script"
    • CategoryInfo : ObjectNotFound: (C:\Users\ADMINI...xstarter.Script:String) [Remove-Item], ItemNotFoundException
    • FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
Boxstarter: Starting Windows Update Service

Type ENTER to exit:

My script ends with the following:
....
Install-WindowsUpdate -AcceptEula

Write-ChocolateySuccess 'Boxstarter.AppSvr08R2'

#  Ensure IIS has the latest environment variable changes
iisreset
} catch {
Write-ChocolateyFailure 'Boxstarter.AppSvr08R2' $($_.Exception.Message)
throw
}


Pressing Enter dismisses the console window but the red error text will cause my Admins and QA testers to cry foul...ideas of what I'm missing or what could be done to make it clean and smooth?
Coordinator
Aug 7, 2013 at 10:06 PM
I’m sorry for the trouble here. Can you take a look at $env:temp\Boxstarter.log and see if it contains an entry:

"writing restart file"

I really should include the path that it writes it to. This would at least indicate if it made the attempt. Is there perhaps an exception logged immediately after the “writing restart file” entry? Do you see a Boxstarter.Script file in another directory at or under temp? This is my hunch that Boxstarter is writing the file directly to temp the first time or maybe temp\2 or any number other than \1\ where it tries to find it. It would be great if you could let me know.

That is certainly an easy fix if that is the case.

Again, sorry for the hassle.
Aug 8, 2013 at 1:59 AM
Matt,

No need for apologies...you've done everyone a great service with Boxstarter!

Here's the log entries from the end of $env:temp\Boxstarter.log

[2013-08-07T16:31:17.7500000-04:00] ++ Boxstarter starting Installing Updates
This may take several minutes...
[2013-08-07T16:47:10.6093750-04:00] Boxstarter: Restart Required. Restarting now...
[2013-08-07T16:47:10.6093750-04:00] ++ Boxstarter finished Installing Updates 00:15:52.8924155
[2013-08-07T16:47:10.6250000-04:00] Boxstarter: writing restart file
[2013-08-07T16:47:10.7187500-04:00] + Boxstarter finished Calling Chocolatey to install Boxstarter.AppSvr08R2 00:23:00.8228323
[2013-08-07T16:47:10.7343750-04:00] Boxstarter: Securely Storing WIN-8H5EVGKVORK\Administrator credentials for automatic logon
[2013-08-07T16:47:11.1250000-04:00] Boxstarter: Logon Set
[2013-08-07T16:47:11.1250000-04:00] Boxstarter: Restarting...


Here's the log entry under $env:temp\1\Boxstarter.log

[2013-08-07T16:47:47.9531250-04:00] Boxstarter Version 1.1.18
[2013-08-07T16:47:48.0156250-04:00] (c) 2013 Matt Wrock http://boxstarter.codeplex.com

[2013-08-07T16:47:48.0468750-04:00] + Boxstarter starting Installation session.
[2013-08-07T16:47:48.1718750-04:00] No Script was specified to call.
[2013-08-07T16:47:48.5937500-04:00] Boxstarter: Starting Windows Update Service
[2013-08-07T16:53:33.7343750-04:00] + Boxstarter finished Installation session. 00:05:45.7146660


The $env:temp\Boxstarter.script file looks like this

Import-Module (Join-Path "C:\Users\Administrator\AppData\Roaming\Boxstarter" BoxStarter.Chocolatey\Boxstarter.Chocolatey.psd1) -global -DisableNameChecking;
Invoke-ChocolateyBoxstarter -bootstrapPackage Boxstarter.AppSvr08R2


Based on the above, the script is located in $env:temp but the Remove-Item instruction from Cleanup-Boxstarter.ps1 is looking for it in $env:temp\1

Best regards,
John
Coordinator
Aug 8, 2013 at 2:30 AM
Thanks. This is very helpful. Technically, while your RDP session maps $env:temp to the temp directory and was the same directory you launched boxstarter from, the process that Boxstarter rebooted into must have mapped to temp/1. Lately I have been doing all of my testing from the Hyper-V connection window and therefore my test cases missed this. I should have this fixed tonight with a new package available then. Its a trivial fix and I'll respond when it is available.
Aug 8, 2013 at 2:36 AM
Thanks Matt...full disclosure, I'm doing preliminary work on my Mac OS X 10.8.4 Mountain Lion using Parallels 8.0; planning on moving to Hyper-V 2 (08R2), 3 (2012) and VMWare ESX 5.1 as target environments once the kinks are worked out. If all goes well, will introduce Boxstarter as our internal infrastructure standard for automated and repeatable environments.
Coordinator
Aug 8, 2013 at 6:12 AM
That sounds awesome. I just deployed a fix in 1.1.22. Let me know if you run into any other issues or if there is anything you think could be better.
Aug 8, 2013 at 3:34 PM
Hi Matt,

Just a follow-up to say the fix you put into 1.1.22 worked like a charm. Rebooted and completed normally, without errors. Thanks!

John