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.


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   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
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.
Answered 05/05/2011 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity