title: VB Script - Backup Win 7 Profiles
body: <p>I am trying to create a VBScript in order to backup Windows 7 profiles when replacing PC's.</p>
  
  <p>Currently I have: </p>
  
  <pre><code>Option Explicit
  
  Const SHARENAME = "c:\NHSITTemp"
  
  Dim fldr,subfldr
  Dim sUser
  Dim shl, fso
  
  Set shl = CreateObject("WScript.Shell")
  Set fso = CreateObject("Scripting.FilesystemObject")
  
  'this gets 'Documents and Settings'
  Set fldr = fso.GetFolder( _
                  Replace(shl.ExpandEnvironmentStrings("%USERPROFILE%"), _
                  shl.ExpandEnvironmentStrings("%USERNAME%"), _
                  ""))
  'for each folder in fldr
  For Each subfldr In fldr.SubFolders
    If fso.FolderExists(subfldr.Path &amp; "\Desktop") Then
      sUser = subfldr.Name
      if not fso.FolderExists(SHARENAME &amp; "\" &amp; sUser) Then
        Call fso.CreateFolder(SHARENAME &amp; "\" &amp; sUser)
      End If
      Call fso.CopyFolder(subfldr.Path &amp; "\Desktop", _
                          SHARENAME &amp; "\" &amp; sUser &amp; "\Desktop")
    End If
  Next
  
  Set fso = Nothing
  Set shl = Nothing
  WScript.Quit
  </code></pre>
  
  <p>This is generating errors on line 13 which I cannot figure out, any ideas?</p>