Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista General Discussion > xCopy and Vista Profiles

Reply
Thread Tools Display Modes

xCopy and Vista Profiles

 
 
Broonie
Guest
Posts: n/a

 
      04-01-2009
Hi There,

I'm having some problems with xCopy files to profiles on Vista
machines. I realise robocopy is the copy util to use with vista but
I'm copying via a logon script with a mixed vista and XP environment.
That is also why i'm using "documents and settings" rather than
"users" in the path.

The following command copies the file over properly without any
prompts.

xcopy "\\servername\share\filename" "C:\users\%username%\appdata
\roaming\directory\"

However, the following command gives me an invalid path message

xcopy "\\servername\share\filename" "C:\Documents and Settings\
%username%\Application Data\directory\"

If I add the file name as below, the file copies but it also asks me
if the destination is a file or directory

xcopy "\\servername\share\filename" "C:\Documents and Settings\
%username%\Application Data\directory\filename"

Can anyone explain this strange behaviour?


 
Reply With Quote
 
 
 
 
Gene E. Bloch
Guest
Posts: n/a

 
      04-01-2009
On Wed, 1 Apr 2009 15:43:28 -0700 (PDT), Broonie wrote:

> Hi There,
>
> I'm having some problems with xCopy files to profiles on Vista
> machines. I realise robocopy is the copy util to use with vista but
> I'm copying via a logon script with a mixed vista and XP environment.
> That is also why i'm using "documents and settings" rather than
> "users" in the path.
>
> The following command copies the file over properly without any
> prompts.
>
> xcopy "\\servername\share\filename" "C:\users\%username%\appdata
> \roaming\directory\"
>
> However, the following command gives me an invalid path message
>
> xcopy "\\servername\share\filename" "C:\Documents and Settings\
> %username%\Application Data\directory\"
>
> If I add the file name as below, the file copies but it also asks me
> if the destination is a file or directory
>
> xcopy "\\servername\share\filename" "C:\Documents and Settings\
> %username%\Application Data\directory\filename"
>
> Can anyone explain this strange behaviour?


I can't, but I wonder, can you figure out from the environment which system
the script is running in?

Then you could use an "if" to select one of two xcopy commands.

I think of something like
if exist "C:\Users" then
.... (code for Vista)
else
.... (code for XP)
endif

I haven't used batch files in years, especially in the XP-Vista world, so
even if the idea is workable, my syntax above can be incorrect :-)

Looking at the environment for something that might be unique to Vista, I
see the variable %PUBLIC%. That might be a possible thing to test on:

if %public% EQ "%public%" then you're in XP...

HTH,
Gino

--
Gene E. Bloch letters0x40blochg0x2Ecom
 
Reply With Quote
 
Broonie
Guest
Posts: n/a

 
      04-02-2009
On Apr 2, 12:18*pm, "Gene E. Bloch" <not...@other.invalid> wrote:
> On Wed, 1 Apr 2009 15:43:28 -0700 (PDT), Broonie wrote:
> > Hi There,

>
> > I'm having some problems with xCopy files to profiles on Vista
> > machines. I realise robocopy is the copy util to use with vista but
> > I'm copying via a logon script with a mixed vista and XP environment.
> > That is also why i'm using "documents and settings" rather than
> > "users" in the path.

>
> > The following command copies the file over properly without any
> > prompts.

>
> > xcopy "\\servername\share\filename" "C:\users\%username%\appdata
> > \roaming\directory\"

>
> > However, the following command gives me an invalid path message

>
> > xcopy "\\servername\share\filename" "C:\Documents and Settings\
> > %username%\Application Data\directory\"

>
> > If I add the file name as below, the file copies but it also asks me
> > if the destination is a file or directory

>
> > xcopy "\\servername\share\filename" "C:\Documents and Settings\
> > %username%\Application Data\directory\filename"

>
> > Can anyone explain this strange behaviour?

>
> I can't, but I wonder, can you figure out from the environment which system
> the script is running in?
>
> Then you could use an "if" to select one of two xcopy commands.
>
> I think of something like
> if exist "C:\Users" then
> ... (code for Vista)
> else
> ... (code for XP)
> endif
>
> I haven't used batch files in years, especially in the XP-Vista world, so
> even if the idea is workable, my syntax above can be incorrect :-)
>
> Looking at the environment for something that might be unique to Vista, I
> see the variable %PUBLIC%. That might be a possible thing to test on:
>
> if %public% EQ "%public%" then you're in XP...
>
> HTH,
> Gino
>
> --
> Gene E. Bloch * * *letters0x40blochg0x2Ecom


Yeah, I could do that but surely the standard syntax should work as
"documents and settings" is linked to "users" by the junction in vista?
 
Reply With Quote
 
Kerry Brown
Guest
Posts: n/a

 
      04-02-2009

"Broonie" <> wrote in message
news:37d2df37-f01a-4c68-bc74-...
> Hi There,
>
> I'm having some problems with xCopy files to profiles on Vista
> machines. I realise robocopy is the copy util to use with vista but
> I'm copying via a logon script with a mixed vista and XP environment.
> That is also why i'm using "documents and settings" rather than
> "users" in the path.
>
> The following command copies the file over properly without any
> prompts.
>
> xcopy "\\servername\share\filename" "C:\users\%username%\appdata
> \roaming\directory\"
>
> However, the following command gives me an invalid path message
>
> xcopy "\\servername\share\filename" "C:\Documents and Settings\
> %username%\Application Data\directory\"
>
> If I add the file name as below, the file copies but it also asks me
> if the destination is a file or directory
>
> xcopy "\\servername\share\filename" "C:\Documents and Settings\
> %username%\Application Data\directory\filename"
>
> Can anyone explain this strange behaviour?
>
>


Try this:

xcopy "\\servername\share\filename" "%APPDATA%\directory"

--
Kerry Brown
MS-MVP - Windows Desktop Experience: Systems Administration
http://www.vistahelp.ca/phpBB2/




 
Reply With Quote
 
Synapse Syndrome [KGB]
Guest
Posts: n/a

 
      04-02-2009
Broonie <> wrote:
>
> Hi There,
>
> I'm having some problems with xCopy files to profiles on Vista
> machines. I realise robocopy is the copy util to use with vista but
> I'm copying via a logon script with a mixed vista and XP environment.
> That is also why i'm using "documents and settings" rather than
> "users" in the path.
>
> The following command copies the file over properly without any
> prompts.
>
> xcopy "\\servername\share\filename" "C:\users\%username%\appdata
> \roaming\directory\"
>
> However, the following command gives me an invalid path message
>
> xcopy "\\servername\share\filename" "C:\Documents and Settings\
> %username%\Application Data\directory\"
>
> If I add the file name as below, the file copies but it also asks me
> if the destination is a file or directory
>
> xcopy "\\servername\share\filename" "C:\Documents and Settings\
> %username%\Application Data\directory\filename"
>
> Can anyone explain this strange behaviour?



You should be using better environmental variables.

Instead of...

xcopy "\\servername\share\filename" "C:\users\%username%\appdata\foo\bar\"

or


xcopy "\\servername\share\filename" "C:\Documents and
Settings\%username%\Application Data\foo bar\"

....you could just use...

xcopy "\\servername\share\filename" %appdata%\foo\bar\


There is also %userprofile%

Try...

echo %userprofile%

and

echo %appdata%

....to familiarise yourself with the variables.

ss.


 
Reply With Quote
 
Synapse Syndrome [KGB]
Guest
Posts: n/a

 
      04-02-2009
Broonie <> wrote:
>
> Hi There,
>
> I'm having some problems with xCopy files to profiles on Vista
> machines. I realise robocopy is the copy util to use with vista but
> I'm copying via a logon script with a mixed vista and XP environment.
> That is also why i'm using "documents and settings" rather than
> "users" in the path.
>
> The following command copies the file over properly without any
> prompts.
>
> xcopy "\\servername\share\filename" "C:\users\%username%\appdata
> \roaming\directory\"
>
> However, the following command gives me an invalid path message
>
> xcopy "\\servername\share\filename" "C:\Documents and Settings\
> %username%\Application Data\directory\"
>
> If I add the file name as below, the file copies but it also asks me
> if the destination is a file or directory
>
> xcopy "\\servername\share\filename" "C:\Documents and Settings\
> %username%\Application Data\directory\filename"
>
> Can anyone explain this strange behaviour?


BTW, you can always add Robocopy to XP, from the Windows Server 2003
Rescource Kit. There is also an updated version, that you can use with XP,
that gets installed along with the Robocopy GUI. This is the preferred
version, for me, as it can correctly keep original folder timestamps.

http://technet.microsoft.com/en-us/m...spotlight.aspx

ss.


 
Reply With Quote
 
Broonie
Guest
Posts: n/a

 
      04-02-2009
On Apr 2, 2:09*pm, "Synapse Syndrome [KGB]"
<syna...@NOSPAMsyndrome.me.uk> wrote:
> Broonie <brooni...@hotmail.com> wrote:
>
> > Hi There,

>
> > I'm having some problems with xCopy files to profiles on Vista
> > machines. I realise robocopy is the copy util to use with vista but
> > I'm copying via a logon script with a mixed vista and XP environment.
> > That is also why i'm using "documents and settings" rather than
> > "users" in the path.

>
> > The following command copies the file over properly without any
> > prompts.

>
> > xcopy "\\servername\share\filename" "C:\users\%username%\appdata
> > \roaming\directory\"

>
> > However, the following command gives me an invalid path message

>
> > xcopy "\\servername\share\filename" "C:\Documents and Settings\
> > %username%\Application Data\directory\"

>
> > If I add the file name as below, the file copies but it also asks me
> > if the destination is a file or directory

>
> > xcopy "\\servername\share\filename" "C:\Documents and Settings\
> > %username%\Application Data\directory\filename"

>
> > Can anyone explain this strange behaviour?

>
> You should be using better environmental variables.
>
> Instead of...
>
> xcopy "\\servername\share\filename" "C:\users\%username%\appdata\foo\bar\"
>
> or
>
> xcopy "\\servername\share\filename" "C:\Documents and
> Settings\%username%\Application Data\foo bar\"
>
> ...you could just use...
>
> xcopy "\\servername\share\filename" %appdata%\foo\bar\
>
> There is also %userprofile%
>
> Try...
>
> echo %userprofile%
>
> and
>
> echo %appdata%
>
> ...to familiarise yourself with the variables.
>
> ss.

I've tried using %appdata% (and %userprofile%) in the destination but
we have "My Documents"/"Documents" mapped to network shares so when
xCopy does a copy using these environment variables it thinks the
destination is NetworkDriveLetter:\C:\Users\username\AppData\Roam ing
which is obviously incorrect.
 
Reply With Quote
 
Synapse Syndrome [KGB]
Guest
Posts: n/a

 
      04-02-2009
Broonie <> wrote:
>
>>
>>> Hi There,

>>
>>> I'm having some problems with xCopy files to profiles on Vista
>>> machines. I realise robocopy is the copy util to use with vista but
>>> I'm copying via a logon script with a mixed vista and XP environment.
>>> That is also why i'm using "documents and settings" rather than
>>> "users" in the path.

>>
>>> The following command copies the file over properly without any
>>> prompts.

>>
>>> xcopy "\\servername\share\filename" "C:\users\%username%\appdata
>>> \roaming\directory\"

>>
>>> However, the following command gives me an invalid path message

>>
>>> xcopy "\\servername\share\filename" "C:\Documents and Settings\
>>> %username%\Application Data\directory\"

>>
>>> If I add the file name as below, the file copies but it also asks me
>>> if the destination is a file or directory

>>
>>> xcopy "\\servername\share\filename" "C:\Documents and Settings\
>>> %username%\Application Data\directory\filename"

>>
>>> Can anyone explain this strange behaviour?

>>
>> You should be using better environmental variables.
>>
>> Instead of...
>>
>> xcopy "\\servername\share\filename"
>> "C:\users\%username%\appdata\foo\bar\"
>> or
>>
>> xcopy "\\servername\share\filename" "C:\Documents and
>> Settings\%username%\Application Data\foo bar\"
>>
>> ...you could just use...
>>
>> xcopy "\\servername\share\filename" %appdata%\foo\bar\
>>
>> There is also %userprofile%
>>
>> Try...
>>
>> echo %userprofile%
>>
>> and
>>
>> echo %appdata%
>>
>> ...to familiarise yourself with the variables.
>>

> I've tried using %appdata% (and %userprofile%) in the destination but
> we have "My Documents"/"Documents" mapped to network shares so when
> xCopy does a copy using these environment variables it thinks the
> destination is NetworkDriveLetter:\C:\Users\username\AppData\Roam ing
> which is obviously incorrect.


Ah, sorry I did not check what I posted, as what you are doing is a bit
weird. You have to use those sort of environmental variables on the local
source, as they are local variables. Only %username% would be useful in a
remote location.

It's more usual to have scripts running on the central *server*, pulling
data off the workstations. so the UNC paths should be on the destination
side.

If you really have to do it that way around, the only thing I can think of
is to execute the command on the remote location using Sysinternal's PSEXEC,
but it is a bit crazy.

eg.

<after having installed psexec.exe into the local C:\windows\system32
directories, or adding to a folder in your PATH>...

psexec \\servername xcopy "\\servername\share\filename" %appdata%\foo\bar\

ss.


 
Reply With Quote
 
Synapse Syndrome [KGB]
Guest
Posts: n/a

 
      04-02-2009
Synapse Syndrome [KGB] <> wrote:
>
>>>
>>>> Hi There,
>>>
>>>> I'm having some problems with xCopy files to profiles on Vista
>>>> machines. I realise robocopy is the copy util to use with vista but
>>>> I'm copying via a logon script with a mixed vista and XP environment.
>>>> That is also why i'm using "documents and settings" rather than
>>>> "users" in the path.
>>>
>>>> The following command copies the file over properly without any
>>>> prompts.
>>>
>>>> xcopy "\\servername\share\filename" "C:\users\%username%\appdata
>>>> \roaming\directory\"
>>>
>>>> However, the following command gives me an invalid path message
>>>
>>>> xcopy "\\servername\share\filename" "C:\Documents and Settings\
>>>> %username%\Application Data\directory\"
>>>
>>>> If I add the file name as below, the file copies but it also asks me
>>>> if the destination is a file or directory
>>>
>>>> xcopy "\\servername\share\filename" "C:\Documents and Settings\
>>>> %username%\Application Data\directory\filename"
>>>
>>>> Can anyone explain this strange behaviour?
>>>
>>> You should be using better environmental variables.
>>>
>>> Instead of...
>>>
>>> xcopy "\\servername\share\filename"
>>> "C:\users\%username%\appdata\foo\bar\"
>>> or
>>>
>>> xcopy "\\servername\share\filename" "C:\Documents and
>>> Settings\%username%\Application Data\foo bar\"
>>>
>>> ...you could just use...
>>>
>>> xcopy "\\servername\share\filename" %appdata%\foo\bar\
>>>
>>> There is also %userprofile%
>>>
>>> Try...
>>>
>>> echo %userprofile%
>>>
>>> and
>>>
>>> echo %appdata%
>>>
>>> ...to familiarise yourself with the variables.
>>>

>> I've tried using %appdata% (and %userprofile%) in the destination but
>> we have "My Documents"/"Documents" mapped to network shares so when
>> xCopy does a copy using these environment variables it thinks the
>> destination is NetworkDriveLetter:\C:\Users\username\AppData\Roam ing
>> which is obviously incorrect.

>
> Ah, sorry I did not check what I posted, as what you are doing is a bit
> weird. You have to use those sort of environmental variables on the
> local source, as they are local variables. Only %username% would be
> useful in a remote location.
>
> It's more usual to have scripts running on the central *server*, pulling
> data off the workstations. so the UNC paths should be on the destination
> side.
>
> If you really have to do it that way around, the only thing I can think
> of is to execute the command on the remote location using Sysinternal's
> PSEXEC, but it is a bit crazy.
>
> eg.
>
> <after having installed psexec.exe into the local C:\windows\system32
> directories, or adding to a folder in your PATH>...
>
> psexec \\servername xcopy "\\servername\share\filename" %appdata%\foo\bar\
>


I just thought of a couple of other ways as well, but they are also weird
kludges, for the backwards source/locations you are doing...

You could also make a mapped network drive, and use that drive letter
instead, or you could do the same with the PUSHD command.

ss.


 
Reply With Quote
 
Broonie
Guest
Posts: n/a

 
      04-02-2009
On Apr 2, 2:50*pm, "Synapse Syndrome [KGB]"
<syna...@NOSPAMsyndrome.me.uk> wrote:
> Broonie <brooni...@gmail.com> wrote:
>
> >>> Hi There,

>
> >>> I'm having some problems with xCopy files to profiles on Vista
> >>> machines. I realise robocopy is the copy util to use with vista but
> >>> I'm copying via a logon script with a mixed vista and XP environment.
> >>> That is also why i'm using "documents and settings" rather than
> >>> "users" in the path.

>
> >>> The following command copies the file over properly without any
> >>> prompts.

>
> >>> xcopy "\\servername\share\filename" "C:\users\%username%\appdata
> >>> \roaming\directory\"

>
> >>> However, the following command gives me an invalid path message

>
> >>> xcopy "\\servername\share\filename" "C:\Documents and Settings\
> >>> %username%\Application Data\directory\"

>
> >>> If I add the file name as below, the file copies but it also asks me
> >>> if the destination is a file or directory

>
> >>> xcopy "\\servername\share\filename" "C:\Documents and Settings\
> >>> %username%\Application Data\directory\filename"

>
> >>> Can anyone explain this strange behaviour?

>
> >> You should be using better environmental variables.

>
> >> Instead of...

>
> >> xcopy "\\servername\share\filename"
> >> "C:\users\%username%\appdata\foo\bar\"
> >> or

>
> >> xcopy "\\servername\share\filename" "C:\Documents and
> >> Settings\%username%\Application Data\foo bar\"

>
> >> ...you could just use...

>
> >> xcopy "\\servername\share\filename" %appdata%\foo\bar\

>
> >> There is also %userprofile%

>
> >> Try...

>
> >> echo %userprofile%

>
> >> and

>
> >> echo %appdata%

>
> >> ...to familiarise yourself with the variables.

>
> > I've tried using %appdata% (and %userprofile%) in the destination but
> > we have "My Documents"/"Documents" mapped to network shares so when
> > xCopy does a copy using these environment variables it thinks the
> > destination is NetworkDriveLetter:\C:\Users\username\AppData\Roam ing
> > which is obviously incorrect.

>
> Ah, sorry I did not check what I posted, as what you are doing is a bit
> weird. *You have to use those sort of environmental variables on the local
> source, as they are local variables. *Only %username% would be useful in a
> remote location.
>
> It's more usual to have scripts running on the central *server*, pulling
> data off the workstations. so the UNC paths should be on the destination
> side.
>
> If you really have to do it that way around, the only thing I can think of
> is to execute the command on the remote location using Sysinternal's PSEXEC,
> but it is a bit crazy.
>
> eg.
>
> <after having installed psexec.exe into the local C:\windows\system32
> directories, or adding to a folder in your PATH>...
>
> psexec \\servername xcopy "\\servername\share\filename" %appdata%\foo\bar\
>
> ss.


It's just a logon script I am running. There's nothing really that
strange in that is there? It basically says that if you find a
particular file on a local system then do a xCopy of another couple of
files from the server to the local machine that is logging on. I'm
pretty sure this method is used quite widely so that is why i'm
confused xCopy can't handle the changes in directory stucture within
Vista.

It's also very strange that xCopy see %appdata% as NetworkDriveLetter:
\C:\user\username\appadata\roaming as opposed to just C:\user\username
\appadata\roaming as it's only My Documents/Documents that we have
mapped to a network drive and not the entire profile. In fact when I
do SET at the command line to see all my environment variables %appdata
% actually says C:\Users\username\AppData\Roaming as should be the
case.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
robocopy or xcopy ? Vistje Windows Vista General Discussion 1 09-10-2008 01:21 PM
Migrating Vista local user profiles to domain profiles Michael Windows Vista General Discussion 1 12-25-2007 09:19 PM
xcopy in vista not copying the files Santel Windows Vista General Discussion 2 11-20-2007 07:19 AM
no xcopy in vista home premium Rycho Windows Vista File Management 3 11-15-2007 03:53 PM
XCOPY fails in Vista Ashpoint Windows Vista General Discussion 12 08-23-2007 05:13 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59