1

I have a script that is meant to retrieve some files from a users old profile on a server and copy it to there new one, but the users do not have access rights for the folders/files in question when connecting through the server.

Is there a way passing a username/password with the following functions? Thanks.

objFSO.FolderExists(folder_path)
objFSO.CopyFolder(folder_path)
objFSO.CopyFile(folder_path)
David Gard
  • 11,225
  • 36
  • 115
  • 227
  • 1
    VBA is visual basic for applications, the code used in the Microsoft Office family of applications. Are you using VBA or VBScript? – Fionnuala May 31 '12 at 11:49
  • Apologies, it is VBS. However, the question has been seccessfully answered below, but thanks for you time. – David Gard May 31 '12 at 14:14

1 Answers1

4

You have to map the share to a driveletter first, then

persistent = false
set objNetwork = WScript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "driveletter:", "\\server\sharename", persistent, "username", "password"

Then use the normal filesystemobject to do the copying, using the driveletter or not. Once authenticated this way it's possible to do other operations with these credentials.

peter
  • 41,770
  • 5
  • 64
  • 108