xcopy with credentials on remote machine [closed]

柔情痞子 提交于 2019-11-30 05:00:28
Loïc MICHEL

You just have to map a network drive:

net use Z: \\XXX.XXX.XXX.XXX\C$ password /user:domain\username 

If you want the drive to reconnect at next logon, add the option /persistent:yes

You can also try this. pass the username and password as arguments. After copy it deletes the mapping & disconnects.

SET username=%1
SET password=%2
net use "\\xxx.xxx.xxx.xxx\Some Folder" %password% /user:domain\%username%
:copy
copy "\\xxx.xxx.xxx.xxx\Some Folder\New.txt" "D:\new.txt"
IF ERRORLEVEL 0 goto disconnect
goto end
:disconnect 
net use "\\xxx.xxx.xxx.xxx\Some Folder" /delete
goto end
:end

try putting the IP in double quotes. It worked for me.

net use "\\xxx.xxx.xxx.xxx\Some Folder" password /user:domain\username

Keep me posted :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!