XCOPY 到远程服务器

发布于 2024-08-12 17:36:39 字数 427 浏览 3 评论 0原文

为了改进我的 ASP.NET 应用程序的部署/构建过程,我想制作一个 .bat

  • 构建当前解决方案
  • 来以发布模式xcopy 文件 远程服务器

通过命令行创建发布版本很容易。

但是如何将文件复制到远程服务器呢?

我想我必须将远程目标映射到网络驱动器(?)。但是,尽管我已为服务器上的文件夹启用了文件共享,但我无法连接到远程服务器。也许防火墙阻止了该请求?我应该打开哪个端口?或者还有其他解决方案吗?

编辑

感谢到目前为止的所有答案,但我可能需要有关如何在服务器上设置文件夹共享的分步指南。我共享了该文件夹,打开了端口 445,以便可以连接到服务器,但仍然无法从本地计算机连接到服务器,以便将网络路径映射到系统驱动器。

In order to improve the deployment / build process of my ASP.NET app, I would like to make a .bat that

  • builds the current solution in release mode
  • xcopy the files to a remote server

Creating a release build via command line is easy.

But how can I xcopy the files to the remote server?

I think I have to map the remote destination to a network drive (?). However I could not connect to the remote server, although I have enabled file sharing for the folder on the server. Maybe the firewall is blocking the request? Which port should I open? Or is there another solution?

EDIT

Thanks for all the answers so far, but I probably need a step by step guide on how to set up the folder sharing on the server. I shared the folder, I opened up port 445 so that I can connect to the server but still, I cant connect from my local machine to the server in order to map the network path to a system drive.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

笑梦风尘 2024-08-19 17:36:40

由于您正在部署 ASP.Net 站点,因此我假设您处于 Windows 环境中(这不是很聪明吗?:))。
所以 !忘记 .bat 并使用 POWERSHELL

无论如何,这不是你问题的重点......
要复制到远程文件夹,您应该有权在远程计算机上执行此操作。

检查本地计算机和远程计算机上是否有相同的帐户。
例如,如果您使用登录名“Pipo”登录域“Work”中的本地计算机,则必须授予此帐户写入远程计算机上的特殊文件夹的权限。

您可以通过右键单击文件夹、安全选项,然后选择正确的标识来实现此目的。

以下是分步指南:

http://support.microsoft.com/kb/301281< /a>

Since you are deploying a ASP.Net site, I am assuming that you are in a windows environnement (isn't smart ? :)).
SO ! Forget about .bat and go for POWERSHELL !

Anyway, this is not point of your question...
To copy to a remote folder you should have the rights to do so on the Remote computer.

Check if you have the same account on your local computer and on the remote one.
For instance, if you are logged on your local computer in the domain "Work" with the login "Pipo", you must give the rights to this account to write into your special folder on the remote computer.

You can achieve that with a right click on the folder, security options, and then selecting the correct identity.

Here is a step-by-step guide:

http://support.microsoft.com/kb/301281

榆西 2024-08-19 17:36:40

如果服务器位于您的本地网络上,我建议使用 robocopy 而不是 xcopy - 它有更多有用的选项和重试错误的功能。它可以很好地处理 UNC 名称(我相信 xcopy 也是如此)。我认为它可以在较新的 Windows 客户端上使用 - 如果它不在您的计算机上 Google 上 - 它可以在各种资源工具包下载中使用(我不知道 Microsoft 是否/何时开始将其包含在操作系统发行版中的详细信息,因为我已经它在我的实用工具包里已经很长时间了)。

如果服务器不是本地的,您可以编写命令行 FTP 客户端脚本来执行传输。如果您需要额外的灵活性或安全性,还有许多其他文件传输选项,包括 WinSCP

当然,无论哪种情况(本地或远程服务器),都需要正确设置服务器的权限和您的身份验证才能使其有机会工作。

If the server is on your local network, I'd suggest using robocopy instead of xcopy - it has many more useful options and capability to retry on errors. It handles UNC names just fine (as I believe xcopy does too). I think it's available on newer Windows clients - if it's not on your machine Google for it - it's available in various resource kit downloads (I don't know the details of if/when Microsoft started including it in the OS distribution because I've had it in my utility kit for a long, long time now).

If the server isn't local, you can script the command line FTP client to perform the transfer. If you need additional flexibility or security there are many other file transfer options, including WinSCP.

Of course in either case (local or remote server), the server's permissions and your authentication needs to be set up properly for this to have a chance to work.

相守太难 2024-08-19 17:36:40

您可以使用任何 UNC 路径:\\machine\sharedFolder。如果您不想设置共享文件夹,则可以使用 $ 符号引用计算机上的任何驱动器:\\machine\c$\program files\etc。如果您的计算机位于 Active Directory 中,或者您在目标计算机上有一个具有相同用户名和密码的本地用户,Windows 将无缝处理身份验证。

You can use any UNC path: \\machine\sharedFolder. If you don't want to set up a shared folder, you can reference any of the drives on the machine using a $ sign: \\machine\c$\program files\etc. If your machines are in Active Directory, or if you have a local user on the target machine with the same username AND password Windows will handle the authentication seamlessly.

还如梦归 2024-08-19 17:36:40

你尝试过释放它吗?

http://www.eworldui.net/unleashit/

它可以跨网络移动文件,运行预构建 bat 文件、文件屏蔽等...

我以前在 .net 1.1 项目中使用过它。

Have you tried unleash it?

http://www.eworldui.net/unleashit/

It can move files across networks, run pre build bat files, file masking, etc...

I used to use it before on .net 1.1 projects.

沉睡月亮 2024-08-19 17:36:40

我想你想要:

XCOPY c:\myproject\build\*.* \\server\\build\ /S /E

I think you want:

XCOPY c:\myproject\build\*.* \\server\\build\ /S /E
所谓喜欢 2024-08-19 17:36:40

以上所有似乎都是宏大的答案 - 您可以考虑使用 msbuild 脚本和 msbuild 社区任务来完成所有这些 - 他们可以压缩您的构建并将其 ftp 到远程服务器。

我刚刚为我们的一个网站设置了这个,花了几个小时来了解它,但它在发布中构建了该网站,更新了生产配置文件,删除了不必要的文件,然后进行了上传。

All of the above seem to be grand answers - you could look at using an msbuild script and the msbuild community tasks to do all of this - they can zip up your build and ftp it to a remote server.

I've just set this up for one of our sites, took a couple of hours to get my head around it, but it builds the site in release, updates the config files for production, removes unnecessary files and then does the upload.

梦年海沫深 2024-08-19 17:36:40

寻找了这么多答案后,这里是解决方案

"xcopy D:\\folder\\container \\\\servername\\folder\\container\\ \/E \/H \/Y"

after looking for so many answers here is the solution

"xcopy D:\\folder\\container \\\\servername\\folder\\container\\ \/E \/H \/Y"
无需解释 2024-08-19 17:36:39

可能值得通过 UNC 路径使用 XCOPY 移动文件

\\机器\文件夹

这将要求您能够从原始服务器访问文件夹。检查该文件夹是否已共享,并已授予相关的读/写权限。

It might be worth moving the files with XCOPY via a UNC path

\\machine\folder

That will require you to have access to folder from the originating server. Check that the folder has been shared and that the relevant read/write permissions have been granted.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文