Scripts Thread, File copying at logon. in Coding and Web Development; Hi there,
I am looking for a script to copy a folder + subfolders and files to a users profile. ...
-
31st January 2008, 04:42 PM #1
- Rep Power
- 0
File copying at logon.
Hi there,
I am looking for a script to copy a folder + subfolders and files to a users profile. I have been looking on the MS website, but as yet have not found one I think is suitable.
The closest I have come is the following:
Set oFSO = CreateObject("Scripting.FileSystemObject")
If oFSO.FileExists("C:\documents and settings\%username%\Application data") Then
oFSO.GetFile("C:\documents and settings\%username%\Application data\Macromedia").Attributes = 0 'In case it is read-only
oFSO.CopyFile "\\server\folder\file.exe", "c:\folder\", True
End If
However, it does not seem to work. The UNC path was changed for the real script! Has anyone got an idea of how I could make this work? Or perhaps a script they know will work?
Many thanks,
Bengaul.
-
-
IDG Tech News
-
31st January 2008, 05:30 PM #2 Just out of interest, what was this to fix?
The only reason I ask is that we had a problem with Flash not loading correctly and I had to write a similar script to correct it.
If I remember correctly I had to copy a folder to the "All Users" profile though.
-
-
31st January 2008, 06:15 PM #3
- Rep Power
- 0
Thanks for the reply,
GlennT, the script is in a similar vain to your problem. We use a website that uses a plugin for shockwave. This plugin only seems to want to install in a users profile, thus proving a problem as we do not allow kids admin rights to install, and if I install, it only installs in my profile. I have tried the all users, and default users profile, with no success. I thought perhaps this may be a quick way round...
jinnantonnix, thanks for your reply. I shall give it a go, and let you know.
Bengaul.
-
-
31st January 2008, 07:33 PM #4 
Originally Posted by
jinnantonnix
The %username% isn't going to work, that expansion is done by DOS not VBS. However, in VBS you can use:
Dim oShell
Dim UserName
Set oShell = Wscript.CreateObject("Wscript.Shell")
UserName = oShell.ExpandEnvironmentStrings("%USERNAME%")
WScript.Echo UserName
This will get you the username.
If you want to get the appdata folder (and the OP does!) then you can use the SpecialFolders:
Code:
Set oShell = CreateObject("WScript.Shell")
sAppDataDir = oShell.SpecialFolders("AppData")
Wscript.Echo sAppDataDir This copes with re-directed app data folders (which we use!) and also copes with the fact that sometimes you get things like c:\docs and settings\username.001\application data.
It also works for Vista (which changes the profile location). This may not matter but someone must be using Vista :-)
-
-
31st January 2008, 08:01 PM #5 The AutoIT route is also quite effective for this - I've used these macros a few times:
@AppDataDir path to current user's Application Data
@DesktopDir path to current user's Desktop
@MyDocumentsDir path to My Documents target
@FavoritesDir path to current user's Favorites
@ProgramsDir path to current user's Programs (folder on Start Menu)
@StartMenuDir path to current user's Start Menu
@StartupDir current user's Startup folder
@UserProfileDir Path to current user's Profile folder
-
-
1st February 2008, 11:08 AM #6
- Rep Power
- 0

Originally Posted by
srochford
If you want to get the appdata folder (and the OP does!) then you can use the SpecialFolders:
Code:
Set oShell = CreateObject("WScript.Shell")
sAppDataDir = oShell.SpecialFolders("AppData")
Wscript.Echo sAppDataDir This copes with re-directed app data folders (which we use!) and also copes with the fact that sometimes you get things like c:\docs and settings\username.001\application data.
It also works for Vista (which changes the profile location). This may not matter but someone must be using Vista :-)
So how do I attach this to what I have already?
Code:
Set oShell = CreateObject("WScript.Shell")
sAppDataDir = oShell.SpecialFolders("AppData")
Set oFSO = CreateObject("Scripting.FileSystemObject")
If oFSO.FileExists(appdata"\macromedia") Then
oFSO.GetFile("C:\documents and settings\%username%\Application data\Macromedia").Attributes = 0 'In case it is read-only
oFSO.CopyFile "\\server\folder\file.exe", "c:\folder\", True
End If
-
-
1st February 2008, 11:51 AM #7 
Originally Posted by
Bengaul
So how do I attach this to what I have already?
Code:
Set oShell = CreateObject("WScript.Shell")
sAppDataDir = oShell.SpecialFolders("AppData")
Set oFSO = CreateObject("Scripting.FileSystemObject")
If oFSO.FileExists(appdata & "\macromedia") Then
oFSO.GetFile("appdata & "\macromedia"").Attributes = 0 'In case it is read-only
oFSO.CopyFile "\\server\folder\file.exe", "c:\folder\", True
End If Im not sure what you are doing here tho:
oFSO.CopyFile "\\server\folder\file.exe", "c:\folder\", True
-
-
1st February 2008, 12:45 PM #8
- Rep Power
- 0

Originally Posted by
apeo
Im not sure what you are doing here tho:
oFSO.CopyFile "\\server\folder\file.exe", "c:\folder\", True
Ah, that is the path to the folder on the server where the folder to be copied is kept, the folder where it is meant to go, and overwrite TRUE. Although I am uncertain if this is the correct way to script it.
-
-
4th February 2008, 04:53 PM #9 
Originally Posted by
Bengaul
Ah, that is the path to the folder on the server where the folder to be copied is kept, the folder where it is meant to go, and overwrite TRUE. Although I am uncertain if this is the correct way to script it.

So you check to see if the Macromedia folder exist in Appdata and if it does you copy a file from the server to a folder on the c: drive and thats it? Seems odd to me to check for a folder then copy to another folder altogether. Sorry I should have been clearer when i said "Im not sure what you are doing here tho", i meant why are you coping the file to what seems to be a random location on the C: drive.
-
SHARE:
Similar Threads
-
By strawberry in forum Windows
Replies: 2
Last Post: 20th September 2007, 09:23 AM
-
By Kwyjibo in forum Scripts
Replies: 15
Last Post: 9th May 2007, 03:30 PM
-
By witch in forum General Chat
Replies: 7
Last Post: 29th December 2006, 06:43 PM
-
By tosca925 in forum Scripts
Replies: 4
Last Post: 23rd March 2006, 07:27 AM
-
By browolf in forum Windows
Replies: 1
Last Post: 18th October 2005, 04:26 PM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules