Computing.Net > Forums > Programming > Copy files from network location

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Copy files from network location

Reply to Message Icon

Name: CSM
Date: October 27, 2007 at 20:11:33 Pacific
OS: XPSP2
CPU/Ram: Intel 2 ghz , 1gig mb
Product: Dell
Comment:

I am very new to VBS scripting and would like some help to create a vbs logon script to check and make sure that the file does not exsist on the local account/profile directory first and then copy some files from a network location to a local account/profile that is currently logon to a PC. I did some online research and found this script.

dim objFSO
set objFSO=CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("C:\Documents and Settings\%username%\") = False Then
objFSO.CopyFolder "\\server\share\*", "C:\Documents and Settings\%username%\"
objFSO.CopyFile "\\server\share\*.txt", "C:\Documents and Settings\%username%\"
End If

When doing a test run of the script, I get a windows script host msg of the folowing:

Error: path not found
Code: 800A004C

If some one can help me with this I would really appreciate it. Thanks!



Sponsored Link
Ads by Google

Response Number 1
Name: tonysathre
Date: October 28, 2007 at 10:09:40 Pacific
Reply:

You have to change this line:

"\\server\share\*"

to reflect your UNC path.

"Computer security." — Oxymoron


0

Response Number 2
Name: CSM
Date: October 29, 2007 at 05:27:21 Pacific
Reply:

I'd try changing it but got the same error. It looks like it is no able to find the path of C:\Documents and Settings\%username%. I tried using a test folder name 'test' instead of %username% and it worked so it seems that I need help on getting the correct UNC path for the logon user account/profile. What would be the correct UNC path to copy the files to a logon user?


0

Response Number 3
Name: tonysathre
Date: October 29, 2007 at 09:39:30 Pacific
Reply:

You need to use the ExpandEnvironmentStrings() function.

Set oShell = CreateObject( "WScript.Shell" )
username=oShell.ExpandEnvironmentStrings("%UserName%")
dim objFSO
set objFSO=CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("C:\Documents and Settings\username\") = False Then
objFSO.CopyFolder "\\server\share\*", "C:\Documents and Settings\username\"
objFSO.CopyFile "\\server\share\*.txt", "C:\Documents and Settings\username\"
End If

I do not know VBScript, but to me, this looks like it should work.

"Computer security." — Oxymoron


0

Response Number 4
Name: CSM
Date: October 29, 2007 at 12:35:54 Pacific
Reply:

Thanks, for getting back to me but I tried this and I am still getting the same error of path not found. It is telling me that the path on Line 6 is not found, which is;

objFSO.CopyFolder "\\server\share\*", "C:\Documents and Settings\username\"

Do you have any other ideas?


0

Response Number 5
Name: tonysathre
Date: October 29, 2007 at 13:48:29 Pacific
Reply:

Well since I don't know VBScript, I'm not going to waste your time with useless VBScripts. Here is a solution in batch.

@echo off
if not exist "C:\Documents and Settings\%username%" (
goto :_copy
) else (
goto :eof
)

:_copy
net use t: \\server\share /user:domain\user password
xcopy t:\*.txt "C:\Documents and Settings\%username%"

Replace the italicized text with your information
"Computer security." — Oxymoron


0

Related Posts

See More



Response Number 6
Name: Razor2.3
Date: October 29, 2007 at 18:36:03 Pacific
Reply:

Just build the path and store it in a string:
path=CreateObject("WScript.Shell").ExpandEnvironmentStrings("%UserProfile%\")
Then just refer to THAT as needed:
objFSO.CopyFolder "\\server\share\*", path


0

Response Number 7
Name: CSM
Date: October 30, 2007 at 09:24:04 Pacific
Reply:

Got it, thanks for all your help.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Copy files from network location

Copy files from mult. subfolders www.computing.net/answers/programming/copy-files-from-mult-subfolders/13105.html

script to copy files from a server www.computing.net/answers/programming/script-to-copy-files-from-a-server-/16825.html

Copying files from one driver hive to another www.computing.net/answers/programming/copying-files-from-one-driver-hive-to-another/18970.html