Home All Groups Group Topic Archive Search About

Trying to copy files\folders to UserProfile\Application Data



Author
1 Nov 2007 9:14 PM
Itencypt
I'm trying to write a script for an SMS job that will copy files\folders to a
users profile application data. How can I insure that the files\folders are
copied to any users profile in C:\Documents and Settings excluding the
default profiles (Administrator, All Users, Default User).

Author
2 Nov 2007 5:52 AM
neothwin
"Itencypt" wrote:

> I'm trying to write a script for an SMS job that will copy files\folders to a
> users profile application data. How can I insure that the files\folders are
> copied to any users profile in C:\Documents and Settings excluding the
> default profiles (Administrator, All Users, Default User).
>
pls run this in command prompt. if works, replace the source path and remove
"@echo".

for /f "usebackq delims=" %a in (`"dir "c:\Documents and Settings" /a /b |
findstr /v /i /c:"Administrator" /c:"default user" /c:"all user"
/c:"localservice" /c:"networkservice""`) do @echo xcopy d:\source\* /s
"c:\Documents and Settings\%a\Application Data\"
Author
2 Nov 2007 5:56 AM
neothwin
"Itencypt" wrote:

> I'm trying to write a script for an SMS job that will copy files\folders to a
> users profile application data. How can I insure that the files\folders are
> copied to any users profile in C:\Documents and Settings excluding the
> default profiles (Administrator, All Users, Default User).
>

for /f "usebackq delims=" %a in (`"dir "c:\Documents and Settings" /a /b |
findstr /v /i /c:"Administrator" /c:"default user" /c:"all user"
/c:"localservice" /c:"networkservice""`) do @echo xcopy d:\source\*
"c:\Documents and Settings\%a\Application Data\" /s
Author
2 Nov 2007 12:26 PM
Itencypt
Perhaps it will be easier for me if I provided what I have now that's not
working and hope someone can fix it.  Below is the part of the script that I
have that's not working including the variables that have been set.

---------------Code Begin-------------------------
Option Explicit
Dim ws, wn, fs, AllUsersProgramsMenu, AllUsersDesktop, AllUserStartMenu
Dim Progfiles, SystemRoot, UserProfile, UserDesktop, CurrentPath,
AllProfiles, DefaultUser
Dim WindowsDir, ComputerName, sDate, TempDir, objEnv, UIMODE, Proceed, Quotes
Dim colNamedArguments, ScriptVer, AppVersion, ApplicationName, InstallerName
Dim getprofilefolder, eachprofile, OSType
Set ws = WScript.CreateObject("WScript.Shell")
Set wn = WScript.CreateObject("WScript.Network")
Set fs = CreateObject("Scripting.FileSystemObject")
sDate   = Now
AllUsersProgramsMenu = ws.ExpandEnvironmentStrings("%ALLUSERSPROFILE%") &
"\Start Menu\Programs"
AllUsersDesktop      = ws.ExpandEnvironmentStrings("%ALLUSERSPROFILE%") &
"\Desktop"
AllUserStartMenu     = ws.ExpandEnvironmentStrings("%ALLUSERSPROFILE%") &
"\Start Menu\Programs"
Progfiles            = ws.ExpandEnvironmentStrings("%ProgramFiles%")
SystemRoot           = ws.ExpandEnvironmentStrings("%SystemRoot%")
UserProfile          = ws.ExpandEnvironmentStrings("%UserProfile%")
DocAndSet            = ws.ExpandEnvironmentStrings("C:\Documents and Settings")
DefaultUser             = ws.ExpandEnvironmentStrings("C:\Documents and
Settings\Default User")
UserDesktop          = ws.ExpandEnvironmentStrings("%USERPROFILE%") &
"\Desktop"
CurrentPath          = fs.GetFile(Wscript.ScriptFullName).ParentFolder & "\"
WindowsDir           = ws.ExpandEnvironmentStrings("%windir%") 
ComputerName         = UCase(ws.ExpandEnvironmentStrings("%COMPUTERNAME%"))
TempDir              = ws.ExpandEnvironmentStrings("%TEMP%") & "\"
Quotes               = CHR(34)

''Copy the Folder to each profile
AllProfiles          = ws.ExpandEnvironmentStrings("%SystemDrive%") &
"\Documents and Settings"
set getprofilefolder = fs.GetFolder(AllProfiles)
set eachprofile = getprofilefolder.Subfolders
For Each profilefolders in eachprofile
     fs.copyfolder CurrentPath & "FolderName", (profilefolders &
"\Application Data\FolderName")
    'fs.CopyFolder (CurrentPath &  "FolderName"), (DefaultUser & "\Application
Data\FolderName"), True
----------------------Code End------------------------------------

AddThis Social Bookmark Button