【问题标题】:Run a bat script on a distant computer from my computer (Command Prompt)在远程计算机上从我的计算机运行 bat 脚本(命令提示符)
【发布时间】:2015-02-05 14:11:22
【问题描述】:

我在我的电脑上工作A。 我想在我的计算机 B (C:\Documents\script.bat) 上运行批处理 script.batB的admin session的密码是PASSWORD

这是我从计算机 B 执行批处理的命令:

start C:\Documents\script.bat

现在,我想用这个参数运行它:3.2.16 我已经尝试了这 3 个命令,但它显示“字符不正确”

start C:\Documents\script.bat "3.2.16"
start C:\Documents\script.bat '3.2.16'
start C:\Documents\script.bat 3.2.16

另外,我想从我的计算机 A 上运行它。 你能帮我吗 ?提前谢谢你。

【问题讨论】:

    标签: windows batch-file cmd command


    【解决方案1】:

    如果您想远程运行进程,则需要使用 Sysinternals psexecwmic。不同之处在于psexec 将其输出转移到调用它的计算机上;而wmic 在远程 PC 上显示一个窗口。

    如果你好奇的话,wmic 命令语法如下:

    wmic /node:remotePC /user:remotePC\user /password:password process call create 'cmd /c "c:\path\to\script.bat" "arg1" "arg2"'
    

    如果您需要查看script.bat的输出,请将输出远程重定向到一个文本文件,然后读取该文本文件。

    wmic /node:remotePC /user:remotePC\user /password:password process call create 'cmd /c blah ^>c:\output.txt'
    net use z: \\remotePC\c$ /user:remotePC\user password
    type z:\output.txt
    del z:\output.txt
    net use z: /delete
    

    ...例如。但是下载和使用psexec 可能更容易。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-25
      • 2014-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多