Windows 通过CMD使用PSexec运行UNC路径
我在下面得到了这段代码,它将使用cmd运行LS-PrePost-3.0-Win32_setup.exe。 我的psexec在c:\psexec中。我把批处理文件和exe文件放在同一个文件夹中Windows 通过CMD使用PSexec运行UNC路径,windows,batch-file,cmd,psexec,Windows,Batch File,Cmd,Psexec,我在下面得到了这段代码,它将使用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 编辑:我更改了Pse
c:\psexec\psexec -d \\%%M cmd /c start /wait "%~dp0LS-PrePost-3.0-Win32_setup.exe" /quiet /silent /norestart
我的代码似乎什么都不做。它执行代码,但exe文件没有运行远程PC
编辑:我更改了Psexec的目录。您可以尝试以下操作
c:\psexec\psexec \\%%M -d -c "%~dp0LS-PrePost-3.0-Win32_setup.exe" /quiet /silent /norestart
- 由于您没有等待(
),因此不需要启动/等待-d
- 由于启动的是可执行文件而不是内部命令,因此不需要
李>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).
可以使用pushd和popd通过psexec为UNC路径传递命令
psexec.exe //FQDN -d cmd /c "pushd \\UNCFOLDER\ && file2execute.exe && popd"
我使用CMD是因为中的文件位于共享文件夹中。我知道的是,您不能使用psexe从共享驱动器执行exe文件。你编辑过我的帖子吗above@RegieBaguio,您正在使用
%~dp0
解析到本地计算机中的路径,而不是远程计算机中的路径。远程计算机需要一个对远程文件系统有效的路径。