VBScript won't automatically expand the %USERNAME% variable, that's a CMD.EXE/Command Prompt feature. You could use the ExpandEnvironmentStrings method: http://msdn2.microsoft.com/en-us/library/dy8116cf.aspx
But the 'Documents and Settings' folder might be on D:\, so you should use %USERPROFILE%. But the user's Application Data folder could be redirected somewhere else, so even better would be %APPDATA%.
Another way would be to use WSH's SpecialFolders property:
Set objShell = WScript.CreateObject("WScript.Shell") AppData = objShell.SpecialFolders("AppData") objFSO.CopyFile "\\Server\Share\LinkConfig\Config.ini" , AppData & "\LinkConfig\", OverwriteExisting
"Michael Martis" <Michael Martis[ at ]discussions.microsoft.com> wrote in message news:61290DBD-B995-4274-BF83-3D1893D6A486[ at ]microsoft.com...
[Quoted Text] >I need to copy a config file to each user's Documents and Setting/Local > Settings. This is what I have so far, > > Const OverwriteExisting = TRUE > > Set objFSO = CreateObject("Scripting.FileSystemObject") > objFSO.CopyFile "\\Server\Share\LinkConfig\Config.ini" , "C:\Documents and > Settings\%USERNAME%\Application Data\LinkConfig\", OverwriteExisting > > My main problem is getting the file to copy to the logged in user's > profile. > > Any help would be greatly appreciated!! >
|