【问题标题】:Running a UNC path using PSexec through CMD通过 CMD 使用 PSexec 运行 UNC 路径
【发布时间】:2017-08-04 07:29:29
【问题描述】:

我在下面得到了这段代码,它将使用 cmd 运行 LS-PrePost-3.0-Win32_setup.exe。 我的 psexec 在 c:\psexec 中。我把我的批处理文件和exe文件放在同一个文件夹中。

c:\psexec\psexec -d \\%%M  cmd /c start /wait "%~dp0LS-PrePost-3.0-Win32_setup.exe" /quiet /silent /norestart

我的代码似乎什么也没做。它执行代码但exe文件没有运行远程PC。

编辑:我更改了 Psexec 的目录。

【问题讨论】:

    标签: windows batch-file cmd psexec


    【解决方案1】:

    你可以试试

    c:\psexec\psexec \\%%M -d -c "%~dp0LS-PrePost-3.0-Win32_setup.exe" /quiet /silent /norestart
    
    • 因为你不等待 (-d) 你不需要start /wait
    • 由于您启动的是可执行文件而不是内部命令,因此您不需要cmd /c
    • 该文件在远程机器上执行,因此,它必须在远程机器上可用。复制它 (-c)

    来自psexec帮助

     -c         Copy the specified program to the remote system for
                execution. If you omit this option the application
                must be in the system path on the remote system.
     -d         Don't wait for process to terminate (non-interactive).
     cmd        Name of application to execute.
     arguments  Arguments to pass (note that file paths must be
                absolute paths on the target system).
    

    【讨论】:

    • 我使用 CMD 因为文件位于共享文件夹中。我所知道的是您无法使用 psexe 从共享驱动器执行 exe 文件。编辑了我上面的帖子
    • @RegieBaguio,您正在使用 %~dp0 解析本地机器中的路径,而不是远程机器中的路径。远程机器需要一个对远程文件系统有效的路径。
    【解决方案2】:

    您可以使用 pushd 和 popd 将命令通过 psexec 传递给 UNC 路径。

        psexec.exe //FQDN -d cmd /c "pushd \\UNCFOLDER\ && file2execute.exe && popd"
    

    【讨论】:

      猜你喜欢
      • 2012-09-09
      • 1970-01-01
      • 2012-01-25
      • 2012-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多