Need Help with Copy File Script
I am trying to copy a file from a network path to a folder that exists on our field users desktops.
Can someone help me troubleshoot this code to see what is not working? I am not getting any errors when running it, it just doesn't seem to be working and I'm not fluent enough in vbscript to understand error-checking and see where it's breaking down...
Any help is appreciated.
I do not think it's a Share Permissions problem as any user in the company has access to this particular folder...
Can someone help me troubleshoot this code to see what is not working? I am not getting any errors when running it, it just doesn't seem to be working and I'm not fluent enough in vbscript to understand error-checking and see where it's breaking down...
Any help is appreciated.
Dim fso
Dim oFile1, objFolder, oFolder
Dim path
Dim WshShell
Dim colFolders
Dim sAllUsersDesktop
Dim strComputer
Dim sFolderName
strComputer = "."
Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
'SPECIFY THE PATH OF THE FOLDER IN WHICH SOURCE FILE(S) RESIDE
Set oFile1 = fso.GetFile("\\server\path\to\file\some.pdf")
'POPULATE VARIABLES
sAllUsersDesktop = WshShell.SpecialFolders("AllUsersDesktop")
sFolderName ="Clinical Templates\"
If fso.FolderExists(sAllUsersDesktop & sFolderName) Then
'COPY FILE TO USER FOLDER
fso.CopyFile oFile1, sDocsAndSettings & sFolderName ,True
End If
Set fso = Nothing
Set WSHShell = Nothing
I do not think it's a Share Permissions problem as any user in the company has access to this particular folder...
0 Comments
[ - ] Hide Comments

so that the conversation will remain readable.
Answer this question
or Comment on this question for clarity
Answers
I'm not fluent enough in vbscript to understand error-checkingWhat error-trapping? There isn't any!
EDIT:
Alter your MS Office installation so that the Microsoft Script Editor gets installed. Then, test your scripts by executing them from a command prompt and adding the 'run through the debugger' argument (//X) or add a 'Stop' statement somewhere in the code. Then, you can step through the code line-by-line, using the mouse to highlight variables whose content will then appear in a tooltip. If they're empty - as 'sDocsAndSettings' will be - you'll see straight away.
Also, always, always, ALWAYS have the line 'Option Explicit' as the first line of your scripts. That way, undeclared variables - like 'sDocsAndSettings' - will stop the script in its tracks.
Please log in to comment
Comments