Hello Forum
I've been assigned the tasks of creating code to copy files from one folder to another.
To start I call a value from the enviro settings "Username"
This allows me to target the current user and profile.
Next, I'm looking for the Userprofile path, from there I'm trying to copy the files from the old profile to the new username profile.
Please take a look at the following code and feel free to provide any feeback or direction i shoudl take this.
Thank to all on the furom for past solutions.
script to locate current user profile and locate older profile to copy files into target folder.
Dim Username
Dim UserProfile
Dim Source1
Dim Source2
Dim Shell
Dim CompName
Set Shell = WScript.CreateObject("WScript.Shell")
CompName = Shell.ExpandEnvironmentStrings("%COMPUTERNAME%")
Username = shell.ExpandEnvironmentStrings("%Username%")
UserProfile = shell.ExpandEnvironmentStrings("%UserProfile%")
set fso = Wscript.CreateObject("Scripting.FilesystemObject")
Source1 = "C:\"
Source2 = "C:\documents and settings\"
if not Fso.FolderExists(Source1 & Username) then
fso.CreateFolder(Source1 & Username)
end if
if fso.FolderExists(source2 & Userprofile) then
fso.CopyFolder source2 & Userprofile, Source1 & Username
end if
I've been assigned the tasks of creating code to copy files from one folder to another.
To start I call a value from the enviro settings "Username"
This allows me to target the current user and profile.
Next, I'm looking for the Userprofile path, from there I'm trying to copy the files from the old profile to the new username profile.
Please take a look at the following code and feel free to provide any feeback or direction i shoudl take this.
Thank to all on the furom for past solutions.
script to locate current user profile and locate older profile to copy files into target folder.
Dim Username
Dim UserProfile
Dim Source1
Dim Source2
Dim Shell
Dim CompName
Set Shell = WScript.CreateObject("WScript.Shell")
CompName = Shell.ExpandEnvironmentStrings("%COMPUTERNAME%")
Username = shell.ExpandEnvironmentStrings("%Username%")
UserProfile = shell.ExpandEnvironmentStrings("%UserProfile%")
set fso = Wscript.CreateObject("Scripting.FilesystemObject")
Source1 = "C:\"
Source2 = "C:\documents and settings\"
if not Fso.FolderExists(Source1 & Username) then
fso.CreateFolder(Source1 & Username)
end if
if fso.FolderExists(source2 & Userprofile) then
fso.CopyFolder source2 & Userprofile, Source1 & Username
end if