通过VBScript中访问的文件夹时传递一个用户名/密码(Pass a username/passw

2019-07-29 16:19发布

我有一个,就是从服务器上的用户的旧配置检索某些文件的脚本,并将其复制到那里新的,而是通过将服务器连接时,用户不必在为问题的文件夹/文件的访问权限。

有没有经过用户名/密码,具有如下功能的方法吗? 谢谢。

objFSO.FolderExists(folder_path)
objFSO.CopyFolder(folder_path)
objFSO.CopyFile(folder_path)

Answer 1:

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.



文章来源: Pass a username/password when accessing a folder via VBScript