| | |
Copy Folder with %Computername% and %Username% prefix
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
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 2: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 2: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 2: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.
![]() |
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
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






