| | |
Copy Folder with %Computername% and %Username% prefix
![]() |
•
•
Join Date: Feb 2005
Posts: 43
Reputation:
Solved Threads: 0
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...
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 ;-)
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...
vb Syntax (Toggle Plain Text)
' /* 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
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 1:29 pm. Reason: We have code tags to help make the code readable...
•
•
Join Date: Feb 2005
Posts: 43
Reputation:
Solved Threads: 0
Made a quick ammendment..... Still not right but better i think
vb Syntax (Toggle Plain Text)
' /* 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
Last edited by WaltP; Jan 16th, 2007 at 1:30 pm. Reason: Code tags added
•
•
Join Date: Feb 2005
Posts: 43
Reputation:
Solved Threads: 0
update......
vb Syntax (Toggle Plain Text)
' /* 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
Last edited by WaltP; Jan 16th, 2007 at 1:31 pm. Reason: Code tags added -- your turn
Its working in my case....just made a slight modification:
Removed the quotes around dest ....
visualbasic Syntax (Toggle Plain Text)
fso.CopyFolder src, dest, 1
Removed the quotes around dest ....
I don't accept change; I don't deserve to live.
Sacrifice is a painful, pure and beautiful thing.
Dammit, Jones, What the Hell Are Knoll Pointers?!
Sacrifice is a painful, pure and beautiful thing.
Dammit, Jones, What the Hell Are Knoll Pointers?!
![]() |
Similar Threads
- Virus Of Death - Help Needed! (Viruses, Spyware and other Nasties)
- Deleting stupid porn hijack (Viruses, Spyware and other Nasties)
- Copy Files and Folders to CDs (Windows tips 'n' tweaks)
- Hijacked browser - how to get rid of.... (Viruses, Spyware and other Nasties)
- A new trojan ? (Web Browsers)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Fill textboxes from listbox selection from Access db
- Next Thread: Portability
Views: 5944 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 access activex add ado application banned basic beep bmp box c++ calculator click client code coffeehouse college column convert copy creative database designer desktop dissertations dissertationthesis edit error excel file filter flex form hardware header ide image implements inboxinvb installation installer interaction keypress listview looping machine macro mail match memory messagebox microsoft number open pause pdf picture pos prime print program programmer prompt query random range range-objects readfile registration remotesqlserverdatabase report reports retrieve save score search sites spectateswamp sql string struct subroutine table textbox time timer variable variables vb vb6 vb6.0 vba vista visual visualbasic web window windows






