DStelz
(Getting the hang of it)
2007-04-25 04:39 PM
Copy/Move Problem

I am trying to do a simple script for us to use if we need to replace a corrupt XP profile. For some reason the final copy doesn't work and returns an error code 3. I've broken it up and it works in parts, but when the whole thing is together it will not copy the folders to the directory. Here is the code:
 Code:
$SO=SETOPTION("Explicit", "ON")
$SO=SETOPTION("NoMacrosInStrings", "ON")
$SO=SETOPTION("NoVarsInStrings", "ON")
BREAK ON

DIM $userid
DIM $server
DIM $dir

"Enter user id:" Gets $userid
"Enter server name:" Gets $server

$dir = "\\" + $server + "\profiles$\" + $userid + "\"

Copy "\\" + $server + "\profiles$\" + $userid + "\Favorites\" "\\servername\apps$\kixtart\temp\Favorites\" /s
Copy "\\" + $server + "\profiles$\" + $userid + "\Desktop\" "\\servername\apps$\kixtart\temp\Desktop\"
Copy "\\" + $server + "\profiles$\" + $userid + "\application data\microsoft\outlook\*.*nk2" "\\servername\apps$\kixtart\temp\outlook\"
Copy "\\" + $server + "\profiles$\" + $userid + "\Application Data\Microsoft\Internet Explorer\Quick Launch\" "\\servername\apps$\kixtart\temp\quick\"
Move "\\" + $server + "\profiles$\" + $userid "\\" + $server + "\\profiles$\" + $userid + ".old"
Copy "\\servername\apps$\kixtart\temp\" $dir /s

It just copies certain folders to a temp folder, renames the profile and then copies the files from the temp folder to the new profiles directory.

If you have any questions, let me know.


Mart
(KiX Supporter)
2007-04-25 04:58 PM
Re: Copy/Move Problem

My guess is it has to do with privileges.

By default nobody but the profile owner has privileges to even access the folder where the profile is stored on the server.

As a side note: roaming profiles s#uck but that’s just my opinion


DStelz
(Getting the hang of it)
2007-04-25 08:39 PM
Re: Copy/Move Problem

I would think as a Domain Admin I would have rights. If I leave out the 2nd, 3rd, and 4th Copy lines, it works how it's supposed to.

Benny69
(MM club member)
2007-04-25 08:48 PM
Re: Copy/Move Problem

in your destination you have 'servername' for the servername is that really the server name?

Benny69
(MM club member)
2007-04-25 08:55 PM
Re: Copy/Move Problem

in the move command:
Move "\\" + $server + "\profiles$\" + $userid "\\" + $server + "\\profiles$\" + $userid + ".old"

you have a sorce but the destination needs to be seperated
Move "\\" + $server + "\profiles$\" + $userid + "" "\\" + $server + "\\profiles$\" + $userid + ".old" "DESTINATION"


DStelz
(Getting the hang of it)
2007-04-25 10:23 PM
Re: Copy/Move Problem

I'm not really moving it anywhere. I'm just renaming it.

If I do a "\\" + $server + "\profiles$\" + $userid "\\" + $server + "\\profiles$\" + $userid + ".old"

It actually renames dstelz to dstelz.old which is what I want it to do. Then when I want to copy the contents of the temp folder to basically a new folder called dstelz, it creates the folder, but it won't copy the data over.


Witto
(MM club member)
2007-04-25 10:32 PM
Re: Copy/Move Problem

I think the coloured hack is redundant:

Move "\\" + $server + "\profiles$\" + $userid "\\" + $server + "\\profiles$\" + $userid + ".old"


DStelz
(Getting the hang of it)
2007-04-25 11:00 PM
Re: Copy/Move Problem

Wow, I love wasting hours on syntax mistakes. Thanks Witto.

Benny69
(MM club member)
2007-04-26 01:14 AM
Re: Copy/Move Problem

good eye Witto, you da man

Mart
(KiX Supporter)
2007-04-26 10:16 AM
Re: Copy/Move Problem

 Originally Posted By: DStelz
I would think as a Domain Admin I would have rights. If I leave out the 2nd, 3rd, and 4th Copy lines, it works how it's supposed to.


That was my first thought when I started at my current job. We used roaming profiles then but now we all have local profiles. By default nobody but the profile owner has access to the folder so unless you or someone else changed the permissions even a domain admin cannot access the folder.