在远程服务器上运行batch file

我有一个batch file停止服务,并从d:\驱动器删除文件。 我想在20台服务器上执行此操作。 有没有比手动login每个服务器,复制和运行batch file更快的方法?

你可以尝试使用PsExec 。 如果batch file出现在同一位置的所有机器上,那么你可以在文本文件中提及机器列表,并将其作为参数提供给它。例如,

psexec @<machines_list_file> <location to batch file on remote machines> 

如果你没有在远程机器上,你需要复制batch file,然后使用它执行,

 psexec @<machines_list_file> -c <location to batch file in current machine> 

我可以build议写一个本地脚本:

  1. 使用net start/start \ server远程启动/停止服务。
  2. 删除\\server\d$\...上的文件\\server\d$\...

您可以遍历服务器名称列表并运行这两个命令。