<commit_before># Creating Windows 10 base image automatically

Based on: http://www.hurryupandwait.io/blog/creating-windows-base-images-for-virtualbox-and-hyper-v-using-packer-boxstarter-and-vagrant
His packer templates: https://github.com/mwrock/packer-templates
Problem: no Windows 10 image

## How to run it?

```
packer build -force vbox-win10ent.json
```

Or with different ISO:
```
packer build -force -var 'iso_url=file:///c:/work/iso-images/Windows10.iso' -var 'iso_checksum=d083c55ecb86158e3419032f4ed651e93e37c347' vbox-win10ent.json
```

Current problems:
* in virtual there is some bug with 0ing empty space, wget fails (try again in existing windows10-dev box)
* check the rest of the `package.ps1` script, there were more errors following
* after shutdown packer console says:
```
virtualbox-iso: Error uploading guest additions: Error uploading file to $env:TEMP\winrmcp-56a548af-0f3f-99e5-f731-e73094cc79bf.tmp:
Couldn't create shell: http error: 500 - <s:Envelope xml:lang="en-US" xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:x="http://schemas.xmlsoap.org/ws/2004/09/transfer"
xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing" xmlns:n="http://schemas.xmlsoap.org/ws/2004/09/enumeration"
xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd"><commit_msg>found problems during windir/log removal<commit_after># Creating Windows 10 base image automatically

Based on: http://www.hurryupandwait.io/blog/creating-windows-base-images-for-virtualbox-and-hyper-v-using-packer-boxstarter-and-vagrant
His packer templates: https://github.com/mwrock/packer-templates
Problem: no Windows 10 image

## How to run it?

```
packer build -force vbox-win10ent.json
```

Or with different ISO:
```
packer build -force -var 'iso_url=file:///c:/work/iso-images/Windows10.iso' -var 'iso_checksum=d083c55ecb86158e3419032f4ed651e93e37c347' vbox-win10ent.json
```

Current problems:
* In `provision.ps1` when removing `$env:windir\logs` failures occur because some logs are used by
another processes, permission problems or directories are not empty -- obviously something is
working in this dir:
```
    virtualbox-iso: +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    virtualbox-iso: + CategoryInfo          : PermissionDenied: (C:\Users\vagran...mp\rvw5hshh.dll:FileInfo) [Remove-Item], Unauthoriz
    virtualbox-iso: edAccessException
    virtualbox-iso: + FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
    virtualbox-iso: Remove-Item : Cannot remove item C:\Windows\logs\CBS\CBS.log: The process cannot access the file 'CBS.log' because it
    virtualbox-iso: is being used by another process.
    virtualbox-iso: At C:\Windows\Temp\script.ps1:37 char:5
    virtualbox-iso: +                 Remove-Item $_ -Recurse -Force | Out-Null
    virtualbox-iso: +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    virtualbox-iso: + CategoryInfo          : WriteError: (CBS.log:FileInfo) [Remove-Item], IOException
    virtualbox-iso: + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
    virtualbox-iso: Remove-Item : Cannot remove item C:\Windows\logs\CBS: The directory is not empty.
    virtualbox-iso: At C:\Windows\Temp\script.ps1:37 char:5
    virtualbox-iso: +                 Remove-Item $_ -Recurse -Force | Out-Null
    virtualbox-iso: +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    virtualbox-iso: + CategoryInfo          : WriteError: (CBS:DirectoryInfo) [Remove-Item], IOException
    virtualbox-iso: + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
    virtualbox-iso: Remove-Item : Cannot remove item C:\Windows\logs\WindowsUpdate: The directory is not empty.
    virtualbox-iso: At C:\Windows\Temp\script.ps1:37 char:5
    virtualbox-iso: +                 Remove-Item $_ -Recurse -Force | Out-Null
    virtualbox-iso: +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    virtualbox-iso: + CategoryInfo          : WriteError: (WindowsUpdate:DirectoryInfo) [Remove-Item], IOException
    virtualbox-iso: + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
    virtualbox-iso: Remove-Item : Cannot remove item C:\Windows\logs: The directory is not empty.
    virtualbox-iso: At C:\Windows\Temp\script.ps1:37 char:5
    virtualbox-iso: +                 Remove-Item $_ -Recurse -Force | Out-Null
    virtualbox-iso: +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    virtualbox-iso: + CategoryInfo          : WriteError: (C:\Windows\logs:DirectoryInfo) [Remove-Item], IOException
    virtualbox-iso: + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
    virtualbox-iso: Remove-Item : Cannot remove item C:\Windows\winsxs\manifestcache: The directory is not empty.
    virtualbox-iso: At C:\Windows\Temp\script.ps1:37 char:5
    virtualbox-iso: +                 Remove-Item $_ -Recurse -Force | Out-Null
    virtualbox-iso: +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    virtualbox-iso: + CategoryInfo          : WriteError: (C:\Windows\winsxs\manifestcache:DirectoryInfo) [Remove-Item], IOException
    virtualbox-iso: + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
```
* check the rest of the `package.ps1` script, there were more errors following
* after shutdown packer console says:
```
virtualbox-iso: Error uploading guest additions: Error uploading file to $env:TEMP\winrmcp-56a548af-0f3f-99e5-f731-e73094cc79bf.tmp:
Couldn't create shell: http error: 500 - <s:Envelope xml:lang="en-US" xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:x="http://schemas.xmlsoap.org/ws/2004/09/transfer"
xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing" xmlns:n="http://schemas.xmlsoap.org/ws/2004/09/enumeration"
xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd">
{'fraction_non_alphanumeric': 0.1475436328377505, 'fraction_numerical': 0.034744667097608276, 'mean_word_length': 4.102225886232482, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 24}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3434298', 'n_tokens_mistral': 2130, 'n_tokens_neox': 1924, 'n_words': 395}