none
VBS - Copy user Folders from a remote computer to local computer RRS feed

  • Question

  • HI

    I Am novice in VBS script.

    i need to restore desktop Favorites and a c:\specificFolder from a remote computer to a local computer in the same place.

    the remote computer it's something like this: \\input.desktop\c$\Users\%userprofile%

    it must be copied in localcompluter\users\%userprofile%\

    i already use inputdesktop in my script. i must to use it again cause i don't know the computer name in advance.

    i found script to copy profil but i don't know how adapt it to my script.

    Please can you help me ?

    Monday, November 28, 2016 8:49 AM

Answers

  • Keep in mind that the VBScript interpreter doesn't automatically expand environment variable references inside strings for you. To quote Raymond Chen: "Just because you stick something between percent signs doesn't mean that the magical percent sign fairies are going to swoop in and perform environment variable expansion."

    You can use the ExpandEnvironmentStrings method (WshShell object) if you want that. You can also retrieve an environment variable's value using the WshEnvironment object.


    -- Bill Stewart [Bill_Stewart]

    Monday, November 28, 2016 8:15 PM
    Moderator

All replies

  • Hi Saidou92,

    Do you have to use VB Script? Ed from The Scripting Guy has a great post on using PowerShell and copy-item for this.

    https://blogs.technet.microsoft.com/heyscriptingguy/2013/04/19/use-powershell-to-copy-files-and-folders-to-a-new-location/

    Hope this helps.


    Thanks, Tim. | Please remember to mark the replies as answers if they help. |


    • Edited by Tim Haintz Monday, November 28, 2016 10:29 AM
    Monday, November 28, 2016 10:29 AM
  • HI im thanks for thr response.

    i already have a VBS scritp i just want to integrate a desktop and favorites copy. i don't want to use Powershell

    i am looking for somhting like this:

      

    'copy folder1 shortcuts folder to desktop

    Dim strDesktopFolder
      Set objShell = WScript.CreateObject("WScript.Shell")
      strDesktopFolder = objShell.SpecialFolders("Desktop")
      
      Set objFolder = objShell.NameSpace(strDesktopFolder)

      objFolder.CopyHere "\\input.desktop\c$\Users\%userprofile%",

    Monday, November 28, 2016 12:37 PM
  • Keep in mind that the VBScript interpreter doesn't automatically expand environment variable references inside strings for you. To quote Raymond Chen: "Just because you stick something between percent signs doesn't mean that the magical percent sign fairies are going to swoop in and perform environment variable expansion."

    You can use the ExpandEnvironmentStrings method (WshShell object) if you want that. You can also retrieve an environment variable's value using the WshEnvironment object.


    -- Bill Stewart [Bill_Stewart]

    Monday, November 28, 2016 8:15 PM
    Moderator