Copy Folder with %Computername% and %Username% prefix

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2005
Posts: 43
Reputation: Phreak is an unknown quantity at this point 
Solved Threads: 0
Phreak Phreak is offline Offline
Light Poster

Copy Folder with %Computername% and %Username% prefix

 
0
  #1
Jan 16th, 2007
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...
  1. ' /* Declare Variables */
  2.  
  3. Dim fso, src, dest
  4. Set fso = CreateObject("Scripting.FileSystemObject")
  5. src = "c:\documents and settings\%USERNAME%\"
  6. dest = "x:\ProfileBackup\%computername%\%username%\"
  7.  
  8. If fso.FolderExists (src) Then
  9. fso.CopyFolder (src), (dest)
  10. End If
  11.  
  12. If Not fso.FolderExists (dest) Then
  13. fso.CreateFolder (dest)
  14. 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 ;-)
Last edited by WaltP; Jan 16th, 2007 at 2:29 pm. Reason: We have code tags to help make the code readable...
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 43
Reputation: Phreak is an unknown quantity at this point 
Solved Threads: 0
Phreak Phreak is offline Offline
Light Poster

Re: Copy Folder with %Computername% and %Username% prefix

 
0
  #2
Jan 16th, 2007
Made a quick ammendment..... Still not right but better i think
  1. ' /* Declare Variables */
  2.  
  3. Dim fso, src, dest
  4. dim wsh
  5. set wsh = createobject("WScript.Shell")
  6. login_name = wsh.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon User Name")
  7.  
  8. src = "C:\documents and settings\" & login_name & "\Favorites"
  9. dest = "G:\ProfileBackup\%computername%\%username%\"
  10.  
  11. If fso.FolderExists "src" Then
  12. fso.CopyFolder "src", "Dest"
  13. End If
  14.  
  15. If Not fso.FolderExists "dest" Then
  16. fso.CreateFolder "dest"
  17. End If
Last edited by WaltP; Jan 16th, 2007 at 2:30 pm. Reason: Code tags added
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 43
Reputation: Phreak is an unknown quantity at this point 
Solved Threads: 0
Phreak Phreak is offline Offline
Light Poster

Re: Copy Folder with %Computername% and %Username% prefix

 
0
  #3
Jan 16th, 2007
update......
  1. ' /* Declare Variables */
  2.  
  3. Dim fso, src, dest
  4. dim wsh
  5. Set fso = CreateObject("Scripting.FileSystemObject")
  6. set wsh = createobject("WScript.Shell")
  7. login_name = wsh.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon User Name")
  8.  
  9. src = "C:\documents and settings\" & login_name & "\Favorites"
  10. dest = "G:\ProfileBackup\%computername%\%username%\"
  11.  
  12. ' /* Check If "Dest" exists, if not, create it */
  13. if Not fso.FolderExists("dest") then
  14. fso.CreateFolder "dest"
  15. End If
  16.  
  17. fso.CopyFolder src,"dest", 1
Last edited by WaltP; Jan 16th, 2007 at 2:31 pm. Reason: Code tags added -- your turn
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 43
Reputation: Phreak is an unknown quantity at this point 
Solved Threads: 0
Phreak Phreak is offline Offline
Light Poster

Re: Copy Folder with %Computername% and %Username% prefix

 
0
  #4
Jan 16th, 2007
Still not working but i cant see where im going wrong.. any ideas???
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,629
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 468
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Copy Folder with %Computername% and %Username% prefix

 
0
  #5
Jan 16th, 2007
Its working in my case....just made a slight modification:
visualbasic Syntax (Toggle Plain Text)
  1. fso.CopyFolder src, dest, 1

Removed the quotes around dest ....
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1
Reputation: techkp is an unknown quantity at this point 
Solved Threads: 0
techkp techkp is offline Offline
Newbie Poster

Re: Copy Folder with %Computername% and %Username% prefix

 
0
  #6
Dec 10th, 2008
The script only copies one file to the destination.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 43
Reputation: Phreak is an unknown quantity at this point 
Solved Threads: 0
Phreak Phreak is offline Offline
Light Poster

Re: Copy Folder with %Computername% and %Username% prefix

 
0
  #7
Dec 29th, 2008
Originally Posted by techkp View Post
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?

:-)
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Copy Folder with %Computername% and %Username% prefix

 
0
  #8
Dec 29th, 2008
*Just Smiles*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC