我在下面得到了这个代码,它将使用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的目录。
答案 0 :(得分:1)
您可以尝试使用类似
的内容-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).
帮助
WARNING|wrapper|17-03-14 13:17:04|YAJSW: yajsw-stable-12.08
WARNING|wrapper|17-03-14 13:17:04|OS : Windows 7/6.1/x86
WARNING|wrapper|17-03-14 13:17:04|JVM : Sun Microsystems Inc./1.6.0_45/C:\Program Files (x86)\Java\jre1.6.0_45/32
INFO|wrapper|17-03-14 13:17:04|started process with pid 38440
INFO|wrapper|17-03-14 13:17:05|Shutting down Wrapper
WARNING|wrapper|17-03-14 13:17:47|YAJSW: yajsw-stable-12.08
WARNING|wrapper|17-03-14 13:17:47|OS : Windows 7/6.1/x86
WARNING|wrapper|17-03-14 13:17:47|JVM : Sun Microsystems Inc./1.6.0_37/C:\Program Files (x86)\Java\jdk1.6.0_37\jre/32
INFO|wrapper|17-03-14 13:17:47|start delay: 0
INFO|wrapper|17-03-14 13:17:47|Win service: before service init
INFO|wrapper|17-03-14 13:17:47|+ ServiceMain callback
INFO|wrapper|17-03-14 13:17:47|reporting status 0
INFO|wrapper|17-03-14 13:17:47|reporting status 0
INFO|wrapper|17-03-14 13:17:47|onstart
INFO|wrapper|17-03-14 13:17:48|started process with pid 37524
INFO|wrapper|17-03-14 13:17:48|calling onStop
INFO|wrapper|17-03-14 13:17:48|Win service stop - timeout: 30000
INFO|wrapper|17-03-14 13:17:48|Win service wrapper.control -> stopping application
INFO|wrapper|17-03-14 13:17:48|Win service stop - after shutdown
INFO|wrapper|17-03-14 13:17:48|Win service stop - before notify
INFO|wrapper|17-03-14 13:17:48|Win service terminated
INFO|wrapper|17-03-14 13:17:48|reporting status 0
INFO|wrapper|17-03-14 13:17:48|Win service: terminated correctly
答案 1 :(得分:0)
您可以使用 pushd 和 popd 将命令通过 psexec 传递给 UNC 路径。
psexec.exe //FQDN -d cmd /c "pushd \\UNCFOLDER\ && file2execute.exe && popd"