/build/static/layout/Breadcrumb_cap_w.png

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.


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

Answers (1)

Posted by: anonymous_9363 12 years ago
Red Belt
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.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ