Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy File problem

Status
Not open for further replies.
Joined
Oct 8, 2002
Messages
62
Location
US
im new to script writing, i have to copy a file that is on a network share to the desktop when a user logs on. I tried writing it as a cmd file but it works in some of my locations and not all???? so i want to try a logon script vbs. having trouble with following script. I also need it to beable replace the current file with an updated file on the server with the same name.



Const OverwriteExisting = True

Set objFSO = CreateObject("Scripting.FileSystemObject")

objFSO.CopyFile = "file on network share","c:\Documents and Settings\%username%\Desktop",OverwriteExisting

 
Try something like this:
set sh = CreateObject("WScript.Shell")
strDesktop = sh.SpecialFolders("Desktop") & "\"
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile = "\\server\share\file", strDesktop, OverwriteExisting


Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Ok i tried that but im getting this error

Line: 5
Char: 72
Error: Expected end of statment
Code: 899A9491
Source: Microsoft VBScript compilation error
 
Can you post your script, with line numbers ?
 
Sorry long day.


1 set sh = CreateObject("WScript.Shell")
2 strDesktop = sh.SpecialFolders("Desktop") & "\"
3 Const OverwriteExisting = True
4 Set objFSO = CreateObject("Scripting.FileSystemObject")
5 objFSO.CopyFile = "\\file-server\drive e\RDP NexGen Config\NextGen.RDP" , strDesktop, OverwriteExistingConst OverwriteExisting = True


 
My previous post, with line numbers:[ol]
[li]set sh = CreateObject("WScript.Shell")[/li]
[li]strDesktop = sh.SpecialFolders("Desktop") & "\"[/li]
[li]Const OverwriteExisting = True[/li]
[li]Set objFSO = CreateObject("Scripting.FileSystemObject")[/li]
[li]objFSO.CopyFile = "\\server\share\file", strDesktop, OverwriteExisting[/li][/ol]

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
ok thats what i did and i got that error

Line: 5
Char: 72
Error: Expected end of statment
Code: 899A9491
Source: Microsoft VBScript compilation error

i plugged in my network info what else should i add????
 
Can you post your script, with line numbers ?
 
Hello all,

I think in line 5 it was meant without the "="
Code:
objFSO.CopyFile "\\server\share\file", strDesktop, OverwriteExisting
- tsuji
 
Good catch tsuji.
Sorry for the typo iNfAmOuSeNiGmA

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
I think i figured it out it was a mistype on line 5

i'll this tommorow thanks guys for all your help

once again tek-tips is right there to save the day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top