我无法将文件复制到远程计算机上。对于手动复制文件,我们登录到远程桌面,转到该单个文件夹,然后粘贴文件。 我们通过提供信息连接到远程桌面 计算机名称:targetserver.x.com 用户名:xyz 密码:xyz
我可以将文件复制到本地计算机 source folder =“\ Sourceserver \ Archive \ folder1” target folder =“C:\ Users \ TEMPPAHIR \ LearnVB \ folder1”
但无法连接到服务器以将文件复制到其上,就像无法复制一样 source folder =“\ Sourceserver \ Archive \ folder1” target folder =“\ Targetserver \ F \ folder1”
我尝试过以下代码
Option Explicit
'Get environment variables
Set objShell = CreateObject("WScript.Shell")
Set objSystemEnv = objShell.Environment("SYSTEM")
Set objNetwork = CreateObject("WScript.Network")
strEnvVarSinc = objSystemEnv("SINC_DATA")
strEnvVarPcData = objSystemEnv("PC_DATA")
strEnvVarArchive = objSystemEnv("ARCHIVE")
strComputerName = objNetwork.ComputerName
Set objSystemEnv = Nothing
Set objShell = Nothing
Set objNetwork = Nothing
'SINC_DATA_AREA
strSincPath = strEnvVarSinc & "\" & strArea
'PC_DATA_AREA
strPcDataPath = strEnvVarPcData & "\" & strArea
我现在能够最终在本地计算机上映射驱动器,但在将文件复制到它时出错 - 错误(18,1)Microsoft VBScript运行时错误:权限被拒绝。是因为某些防火墙还是其他一些问题?我可以通过输入我的用户名和密码手动连接相同的RD,然后将文件复制到RD上。 请帮忙!
Option Explicit
Dim objNet, sFile, objFSO, Arg, var, strInfo, strComputer, strDomain, objSWbemLocator, objSWbemServices
Dim colSwbemObjectSet, strUser, strPassword, objNetwork, objProcess
Dim SourceFolder, TargetFolder, objWMIService, strMachine, strAltUsername, strAltPwd
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNet = CreateObject("WScript.NetWork")
set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "T:" , "\\srv10219\F"
SourceFolder = "\\srv10218\Archive\BudgetPiecesStore\20151116_094107"
Wscript.echo "Source folder Name is : " & SourceFolder
TargetFolder = "\\srv10219\F\ICCdata\BudgetPiecesStore\"
Wscript.echo "Target folder Name is : " & TargetFolder
For Each sFile In objFSO.GetFolder(SourceFolder).Files
objFSO.GetFile(sFile).Copy TargetFolder & "\" & objFSO.GetFileName(sFile),True
WScript.Echo "Copying file : " & Chr(34) & objFSO.GetFileName(sFile) & Chr(34) & " to " & TargetFolder
Set objNet = Nothing
Next