header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Odd reaction using Robocopy and Variables
Last Post 02 Sep 2010 01:38 PM by lizaoreo. 3 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
lizaoreoUser is Offline
New Member
New Member
Posts:7
Avatar

--
02 Sep 2010 12:08 PM
    Alright, the code examples are long, but I'm showing different results here.  I have no idea why it's doing what it's doing, but as you can see, I declare my source, destination, file exception, and directory exception variables with the $username variable implanted in it.  In this example, the first time I mistakenly forgot to assign anything to the $username variable, so it's blank.  When I run Robocopy using the variable references, it comes up right (note the source, destination, and excludes).  I then go back and properly assign the username to the $username variable and try again, but it goes all crazy when my username is in there.

    Any thoughts or suggestions are welcome.


    $source2 = "C:\old harddrive\documents and settings\$username\"
    $dest2 = "C:\users\$username\"
    $filexc2 = @("C:\old harddrive\documents and settings\$username\ntuser.dat")
    $direxc2 = @("C:\old harddrive\documents and settings\$username\cookies", "C:\old harddrive\documents and settings\$username\start menu", "C:\old harddrive\documents and settings\$username\local settings", "C:\old harddrive\documents and settings\$username\application data", "C:\old harddrive\documents and settings\$username\appdata")
    ____________________________________________________________________________________
    $source2
    $dest2
    $filexc2
    $direxc2
    C:\old harddrive\documents and settings\\
    C:\users\\
    C:\old harddrive\documents and settings\\ntuser.dat
    C:\old harddrive\documents and settings\\cookies
    C:\old harddrive\documents and settings\\start menu
    C:\old harddrive\documents and settings\\local settings
    C:\old harddrive\documents and settings\\application data
    C:\old harddrive\documents and settings\\appdata
    ____________________________________________________________________________________
    $Username = [Environment]::username
    ____________________________________________________________________________________
    ROBOCOPY $source2 $dest2 /COPYALL /E /xd $direxc2 /xf $filexc2 /R:0 /Z

    /log+:datatransfer.log /tee /FP /MT:8

     Log File : E:\New Lease Replacement Method\3. New Machine\datatransfer.log

    -------------------------------------------------------------------------------
       ROBOCOPY     ::     Robust File Copy for Windows                             
    -------------------------------------------------------------------------------

      Started : Thu Sep 02 14:45:15 2010

       Source : C:\old harddrive\documents and settings\
         Dest : C:\users\

        Files : *.*
           
    Exc Files : C:\old harddrive\documents and settings\\ntuser.dat
           
     Exc Dirs : C:\old harddrive\documents and settings\\cookies
            C:\old harddrive\documents and settings\\start menu
            C:\old harddrive\documents and settings\\local settings
            C:\old harddrive\documents and settings\\application data
            C:\old harddrive\documents and settings\\appdata
           
      Options : *.* /FP /TEE /S /E /COPYALL /Z /MT:8 /R:0 /W:30

    ------------------------------------------------------------------------------
    ____________________________________________________________________________________
    $source2 = "C:\old harddrive\documents and settings\$username\"
    $dest2 = "C:\users\$username\"
    $filexc2 = @("C:\old harddrive\documents and settings\$username\ntuser.dat")
    $direxc2 = @("C:\old harddrive\documents and settings\$username\cookies", "C:\old harddrive\documents and settings\$username\start menu", "C:\old harddrive\documents and settings\$username\local settings", "C:\old harddrive\documents and settings\$username\application data", "C:\old harddrive\documents and settings\$username\appdata")
    ____________________________________________________________________________________
    $source2
    $dest2
    $filexc2
    $direxc2
    C:\old harddrive\documents and settings\mmoore3\
    C:\users\mmoore3\
    C:\old harddrive\documents and settings\mmoore3\ntuser.dat
    C:\old harddrive\documents and settings\mmoore3\cookies
    C:\old harddrive\documents and settings\mmoore3\start menu
    C:\old harddrive\documents and settings\mmoore3\local settings
    C:\old harddrive\documents and settings\mmoore3\application data
    C:\old harddrive\documents and settings\mmoore3\appdata
    ____________________________________________________________________________________
    ROBOCOPY $source2 $dest2 /COPYALL /E /xd $direxc2 /xf $filexc2 /R:0 /Z

    /log+:datatransfer.log /tee /FP /MT:8

    -------------------------------------------------------------------------------
       ROBOCOPY     ::     Robust File Copy for Windows                             
    -------------------------------------------------------------------------------

      Started : Thu Sep 02 14:46:33 2010

       Source - C:\old harddrive\documents and settings\mmoore3" C:\users\mmoore3\ \COPYALL \E \xd C:\old\
         Dest - E:\New Lease Replacement Method\3. New Machine\harddrive\documents\

        Files : and
           
      Options : /COPY:DAT /R:1000000 /W:30
    ------------------------------------------------------------------------------
    ERROR : Invalid Parameter #4 : "settings\mmoore3\cookies C:\old"

    lizaoreoUser is Offline
    New Member
    New Member
    Posts:7
    Avatar

    --
    02 Sep 2010 12:19 PM
    And of course after I post I spot the issue.  \" was making it put a " in.  When I didn't have my username there the double "\\" made it read as a \.
    cameronoveUser is Offline
    Basic Member
    Basic Member
    Posts:332
    Avatar

    --
    02 Sep 2010 01:32 PM
    Surround your string with single quotes if you want to avoid that problem.
    lizaoreoUser is Offline
    New Member
    New Member
    Posts:7
    Avatar

    --
    02 Sep 2010 01:38 PM
    Actually tried that first, but it wouldn't read the value of the string.  IE.

    $test = clue
    $foo = 'C:\$test'
    $bar = "C:\$test"

    If I grabbed the value of $foo it would be "C:\$test", but the value of $bar would be "C:\clue".
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer