如何给在批处理脚本,将文件复制到网络位置的凭据? [英] How to give credentials in a batch script that copies files to a network location?

查看:1726
本文介绍了如何给在批处理脚本,将文件复制到网络位置的凭据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该环境是Windows Web服务器2008,而我只是想一个完整的文件夹复制到网络位置(一个管理的备份网络文件夹)。这里是我的.bat文件,文件夹和我的.bat文件运行:

 复制名为* .bak \\\\ networklocation \\ *。BAK
暂停

然而 \\\\ networklocation 需要用户名的 X 和密码,因此运行脚本给:

 登录失败:未知的用户名或密码错误。

我不能想出一个办法来提供我的凭据。我试图创建计划任务和修改安全选项,但是这似乎只允许您使用相关凭证到机器(即我的用户名尝试把的 X 并不能找到它)。

我如何与所有正确的权限运行该脚本?

解决方案:

  NET USE \\\\ networklocation \\ sharefolder密码/ USER:用户名
复制\\ *。BAK \\\\ networklocation \\ sharefolder \\ *。BAK


解决方案

尝试在你的脚本中使用 NET USE 命令首先映射的共享,因为你可以提供它证书。然后,你的复制命令应该使用这些凭据。

  NET USE \\\\<网络-地点> \\<有的股> \\密码/ USER:用户名

The environment is Windows Web Server 2008, and I'm just trying to copy a folder full of files to a network location (a managed backup network folder). Here is my .bat file, running in the folder with my .bat files:

copy *.bak \\networklocation\*.bak
pause

however \\networklocation requires username x and password y, so running the script gives:

Logon failure: unknown user name or bad password.

I can't figure out a way to supply my credentials. I tried creating a scheduled task and modifying the security options, but this only seems to allow you to use credentials relevant to the machine (i.e. I try putting in username x and it can't find it).

How do I run this script with all the right permissions?

Solution:

net use \\networklocation\sharefolder password /USER:username
copy \*.bak \\networklocation\sharefolder\*.bak

解决方案

Try using the net use command in your script to map the share first, because you can provide it credentials. Then, your copy command should use those credentials.

net use \\<network-location>\<some-share>\ password /USER:username

这篇关于如何给在批处理脚本,将文件复制到网络位置的凭据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆