title: Permission Denied on FileSystemObject.CopyFile even as Administrator
body: <p>So I'm new to Windows Deployments so I may be doing something basic wrong here.  I'm trying to copy a script to a folder in the windows directory during a windows deployment using MDT</p>
  
  <p>Basically what I'm going for is trying to copy a script to the %windir%\temp\deploymentscripts folder but I get permission denied even as admin.  I'll run through what I think I'm doing</p>
  
  <pre><code>First, elevate to admin
  Create %WinDir%\Temp\DeploymentScripts
  Copy DefaultShell.vbs to that directory (this is where I get permission denied
  Mount ntuser.dat to the registry
  Set DefaultShell.vbs to the Run Once for default users
  Unmount ntuser.dat
  </code></pre>
  
  <p>Here's the actual code</p>
  
  <pre><code>Option Explicit 
  
  If WScript.Arguments.length = 0 Then
  Dim wshShell : Set wshShell = CreateObject("Shell.Application")
  wshShell.ShellExecute "wscript.exe", """" &amp; _
  WScript.ScriptFullName &amp; """" &amp;_
   " RunAsAdministrator", , "runas", 1
  Else
  
  Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
  Dim objShell : Set objShell = WScript.CreateObject("WScript.Shell")
  Dim TempDir
  Dim ParentDir
  Dim FullPath
  TempDir = objShell.ExpandEnvironmentStrings("%WinDir%\Temp\DeploymentScripts")
  
  If Not (objFSO.FolderExists(TempDir)) Then
  objFSO.CreateFolder (TempDir)
  End If
  
  ParentDir = objFSO.GetParentFolderName(Wscript.ScriptFullName)
  FullPath = ParentDir &amp; "\DefaultShell.vbs"
  
  objFSO.CopyFile FullPath, TempDir, True
  
  objShell.run "reg load HKU\ZZZ C:\users\default\ntuser.dat"
  objShell.RegWrite "HKU\ZZZ\Software\Microsoft\Windows\RunOnce\DefaultShell", _
  "WScript.exe" &amp; " " &amp; FullPath, "REG_SZ"
  objShell.run "reg unload HKU\ZZZ"
  
  End If
  </code></pre>