# Access to path denied when building Windows Package

**URL:** https://discourse.chef.io/t/access-to-path-denied-when-building-windows-package/18607
**Category:** Habitat Help
**Created:** [December 13, 2018, 4:10pm UTC](https://discourse.chef.io/t/access-to-path-denied-when-building-windows-package/18607 "2018-12-13T16:10:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![michael](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/michael/32/1345_2.png) [@michael](https://discourse.chef.io/u/michael)
#### Post date: [December 13, 2018, 4:10pm UTC](https://discourse.chef.io/t/access-to-path-denied-when-building-windows-package/18607/1 "2018-12-13T16:10:32Z")

</div>

When I build a windows package in a windows docker container, it fails to build due to permissions issues. I’m using Matt Wrock’s windows-service-example.

```auto
   hab-studio: Creating Studio at C:\
? Importing origin key from standard input
? Imported public origin key mhedgpeth-20181213041908.
? Importing origin key from standard input
? Imported secret origin key mhedgpeth-20181213041908.
   hab-studio: Entering Studio at C:\
** The Habitat Supervisor has been started in the background.
** Use 'hab svc start' and 'hab svc stop' to start and stop services.
** Use the 'Get-SupervisorLog' command to stream the Supervisor log.
** Use the 'Stop-Supervisor' to terminate the Supervisor.

[HAB-STUDIO] Habitat:\src> build
   : Loading C:\src\plan.ps1
   windows-service-sample: Plan loaded
   windows-service-sample: Validating plan metadata
   windows-service-sample: hab-plan-build.ps1 setup
   windows-service-sample: Using HAB_BIN=C:\hab\pkgs\core\hab-studio\0.70.0\20181205200050\bin\hab\hab.exe for installs,
 signing, and hashing
   windows-service-sample: Resolving scaffolding dependencies
   windows-service-sample: Setting up environment
   windows-service-sample: Populating runtime environment from dependencies
   windows-service-sample: Populating buildtime environment from dependencies
   windows-service-sample: Layering runtime environment on top of system environment
   windows-service-sample: Layering buildtime environment on top of system environment
   windows-service-sample: Setting env:PATH=C:\hab\pkgs\mhedgpeth\windows-service-sample\0.2.0\20181213090252\bin;C:\hab
\pkgs\core\hab-studio\0.70.0\20181205200050\bin\powershell;C:\hab\pkgs\core\hab-studio\0.70.0\20181205200050\bin\hab;C:\
hab\pkgs\core\hab-studio\0.70.0\20181205200050\bin\7zip;C:\hab\pkgs\core\hab-studio\0.70.0\20181205200050\bin;C:\Windows
\system32;C:\Windows;C:\hab\bin
   windows-service-sample: Clean the cache
   windows-service-sample: Setting env:LIB=
   windows-service-sample: Setting env:INCLUDE=
   windows-service-sample: Preparing to build
   windows-service-sample: Building
Copy-Item : Access to the path 'C:\Documents and Settings' is denied.
At C:\src\plan.ps1:10 char:3
+ Copy-Item $PLAN_CONTEXT/../* $HAB_CACHE_SRC_PATH/$pkg_dirname -recu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.CopyItemCommand

```

---

<div class="post-metadata">

### Author: ![Matt\_Wrock](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/matt_wrock/32/3394_2.png) [@Matt\_Wrock](https://discourse.chef.io/u/Matt_Wrock)
#### Post date: [December 13, 2018, 5:12pm UTC](https://discourse.chef.io/t/access-to-path-denied-when-building-windows-package/18607/2 "2018-12-13T17:12:52Z")

</div>

Hi Michael!

I’m betting that when you entered the studio, you entered from the `habitat` directory and not the root of the `windows-service-sample` repo. That would mean that the actual C# project is not mounted and when the first line of the build function attempts to copy the project into the build cache, its actually trying to copy `c:\*` which can cause all kinds of issues including what you are seeing. Make sure to run `hab studio enter -D` from the git repo root and then see if that works for you.

---

<div class="post-metadata">

### Author: ![michael](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/michael/32/1345_2.png) [@michael](https://discourse.chef.io/u/michael)
#### Post date: [December 13, 2018, 5:30pm UTC](https://discourse.chef.io/t/access-to-path-denied-when-building-windows-package/18607/3 "2018-12-13T17:30:49Z")

</div>

That’s right Matt, thanks!
