RE: Simple Script??



Vinson, I had a typo in the path...Your script is AWESOME THANKS AGAIN!!!!

"Vinson" wrote:

Well, it is not the most elegant solution I have ever written, but the script
below should do the trick.

Since you only needed to copy a file to every profile, I did not include
full directory recursion in the routine. Instead, the script will simply
look at all of the sub directories below "c:\documents and settings," and
will then assemble a destination path to use in the copy statement further
down in the routine.

In the section labeled "File Copy Information," you will need to provide a
template, of sorts, for the routine to use. Understand that the only thing
changing, as the routine runs, is the name of the directory during the copy;
the rest is information will be static. You will provide prefix and suffix
information for the routine to wrap around the directory name that it
discovers. You will also need to provide a path to the file you want to
copy, and justs it's name, as seen below. The routine, as it appears below,
will copy a file called File.txt to the Start folder in every profile.

Note that the statement below which looks at file attributes (22) is
included so that hidden system folders like "LocalService" and
"NetworkService" would be skipped during the copy routine. Also, the folder
"All Users" has been excluded because that is not actually a user profile,
either. All other folders found are assumed to be profiles.

Lastly, this forum tends to word-wrap sample code sometimes, so I am not
sure what what the code will look like when it is finally posted. =D Just
cut the code below, and paste it into notepad, and save it as a file name
such as PROFILECOPY.VBS. Double-click to run it. Unless there is an error,
this code will run silently.

I hope this helps!


' // Begin Script Here

Dim objFileCopy, fso, f
Dim strFilePath, strDestination, strDirLocation, strFileName

' // File Copy Information
strSourceDir="c:\documents and settings" ' // Prefix to path
strDestination="start menu\programs\startup" ' // suffix to path
strFilePath="c:\sample\file.txt" ' // File name with
path
strFileName="file.txt" ' // File name
alone

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(strSourceDir)
Set objFileCopy = objFSO.GetFile(strFilePath)

If f.subfolders.count > 0 Then
For Each folder In f.subFolders
if folder.attributes = 22 Then
' // Skip folders which are hidden
else
if folder.name="All Users" then
' // Skip the All Users Folder
else
' // Copy file using the assembled path plus file name
objFileCopy.Copy (folder+"\"+strDestination+"\"+strFileName)
end if
end if
next

end if

' // End Script Here

Vinson



"bddbrl" wrote:

I am trying to create a VBS script that will copy a file to all the profiles
on a
computer has anyone attempted this before that could assist me with this.

.



Relevant Pages

  • Re: Automating set up?
    ... > I would like to know that their folder is automatically created, ... > up the mapping in a logon script unless there is a better way. ... My Documents will be a SUBDIRECTORY of the Profile directory here. ... Herb Martin> ...
    (microsoft.public.win2000.active_directory)
  • RE: Simple Script??
    ... Well, it is not the most elegant solution I have ever written, but the script ... Since you only needed to copy a file to every profile, ... full directory recursion in the routine. ... will copy a file called File.txt to the Start folder in every profile. ...
    (microsoft.public.windowsxp.security_admin)
  • Re: XPsp2 and WMP10 and default profiles - a solution
    ... This script needs to be referenced in the SysPrep.inf file, ... >> default user profile. ... >> and Windows Media Player 10 installed, XP always creates a Windows Media ... >> it ignores the default user profile folder and uses the Administrator ...
    (microsoft.public.windowsxp.setup_deployment)
  • Re: Set profile and homefolder path at logon?
    ... The profile folders are stored on server1. ... In each user's profile we have the profile path set to that server and their ... The same with the home folder - set to server1\username. ... What I was planning on doing was to set up a script which would copy those ...
    (microsoft.public.windows.server.scripting)
  • RE: Simple Script??
    ... But when i run it the script fails. ... Since you only needed to copy a file to every profile, ... full directory recursion in the routine. ... will copy a file called File.txt to the Start folder in every profile. ...
    (microsoft.public.windowsxp.security_admin)