Hi all,

It's been a long time since i was last logged in here. Comatose was probably glad to see the back of me and my non stop questioning ;-)

Well today i have a small question which i hope someone can help with...

Here is my question... im trying to copy a profile for the currently logged in user to specified location.

The location of the profile will presumable be,

"c:\documents and settings\" + %username%

and the destination will be,

x:\ProfileBackup\%computername%\%username%\

Here is what i thought ws right but isnt...

' /* Declare Variables */

Dim fso, src, dest
Set fso = CreateObject("Scripting.FileSystemObject")
src = "c:\documents and settings\%USERNAME%\"
dest = "x:\ProfileBackup\%computername%\%username%\"

If fso.FolderExists (src) Then
fso.CopyFolder (src), (dest)
End If

If Not fso.FolderExists (dest) Then
fso.CreateFolder (dest)
End If

Ideally what i was trying to do (badly) was copy a users profile to a network drive to a folder named by the computername and userprofile so that there would be a different back up for each machine they logonto.

However!!!

This may prove troublesome depending on network speeds and profile size etc.. so i was also hoping someone could help and add into the script the ability to copy a single folder "Favorites" from here instead and rem it out. or the ability to copy 2 or 3 folders at a time rather than the entire profile ;-)

I hope someone can help

Thanks in advance.

Phreak ;-)

Recommended Answers

All 7 Replies

Made a quick ammendment..... Still not right but better i think

' /* Declare Variables */

Dim fso, src, dest
dim wsh
set wsh = createobject("WScript.Shell")
login_name = wsh.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon User Name")

src = "C:\documents and settings\" & login_name & "\Favorites"
dest = "G:\ProfileBackup\%computername%\%username%\"

If fso.FolderExists "src" Then
fso.CopyFolder "src", "Dest"
End If

If Not fso.FolderExists "dest" Then
fso.CreateFolder "dest"
End If

update......

' /* Declare Variables */

Dim fso, src, dest
dim wsh
Set fso = CreateObject("Scripting.FileSystemObject")
set wsh = createobject("WScript.Shell")
login_name = wsh.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon User Name")

src = "C:\documents and settings\" & login_name & "\Favorites"
dest = "G:\ProfileBackup\%computername%\%username%\"

' /* Check If "Dest" exists, if not, create it */
if Not fso.FolderExists("dest") then
	fso.CreateFolder "dest"
End If

fso.CopyFolder src,"dest", 1

Still not working but i cant see where im going wrong.. any ideas???

Its working in my case....just made a slight modification:

fso.CopyFolder src, dest, 1

Removed the quotes around dest ....

The script only copies one file to the destination.

The script only copies one file to the destination.

Seriously... THIS THREAD was completed 2 YEARS ago !!!! the script works fine lol

2 Years... how did you not notice that?

:-)

*Just Smiles*

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.