provision error: del : Cannot remove item C:\Windows\Temp\WinRM_Elevated_Shell.log

88 views
Skip to first unread message

Rui Lopes

unread,
Jul 14, 2016, 2:21:30 PM7/14/16
to Vagrant
For some reason I'm getting the following error:

==> test: del : Cannot remove item C:\Windows\Temp\WinRM_Elevated_Shell.log: The process cannot access the file
==> test: 'C:\Windows\Temp\WinRM_Elevated_Shell.log' because it is being used by another process.
==> test: At C:\tmp\vagrant-elevated-shell.ps1:19 char:3
==> test: +   del $out_file
==> test: +   ~~~~~~~~~~~~~
==> test:     + CategoryInfo          : WriteError: (C:\Windows\Temp\WinRM_Elevated_Shell.log:FileInfo) [Remove-Item], IOExcepti
==> test:    on
==> test:     + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand

My Vagrantfile has something like:

    config.vm.provision "shell", inline: "c:/tmp/provision/install-a.ps1", name: "Install a"
    config.vm.provision "shell", inline: "c:/tmp/provision/install-b.ps1", name: "Install b"

The error happens when its trying to run the second provision script.

Looking at https://github.com/mitchellh/vagrant/blob/master/plugins/communicators/winrm/scripts/elevated_shell.ps1.erb it seems that the scheduled task that is created by the first provision script is somehow still running... is that it? if so how can that happen when elevated_shell.ps1.erb is checking (while (!($registered_task.state -eq 3))) is still running? Maybe that check is not enough? Maybe it should really wait for the task to close the log file?

TIA!

PS Host and Guest is Windows 10 64-bit. Vagrant is 1.8.4. VirtualBox is 5.0.24r108355.

Rui Lopes

unread,
Jul 14, 2016, 2:56:56 PM7/14/16
to Vagrant
That was it! I've modified the elevated_shell.ps1.erb to https://github.com/mitchellh/vagrant/pull/7584 :-)

Reply all
Reply to author
Forward
0 new messages