如何使用 PsExec 在远程计算机上安装软件

如何使用 PsExec 在远程计算机上安装软件

以下是一些详细信息

  1. 远程 PC 可能没有管理员用户。
  2. 软件位于所有用户都可以访问的网络共享上。
  3. PsExec 位于管理计算机上

我尝试过这样做,但收到“无效目录”或“系统找不到指定的路径”

psexec \\REMOTEPC1 -w "C:\temp\installRF" "setup.exe /unattended=true /quiet=true /allowShutdown=false /add="FaxUtil,FaxCtrl" /rightFaxServer="faxserver1" /log:whyme"

答案1

远程安装应用程序时需要考虑的一些事项:

1) 安装是否需要用户交互?
2) 您使用哪个用户安装软件?
3) 您用于安装软件的同一用户是否具有驱动器映射和/或读取网络存储数据的权限?


考虑到这一点,我建议采用以下方法。1

. 创建一个脚本,将整个安装文件夹复制到本地系统
2. 使用系统帐户在本地启动安装程序

我之前用 powershell 构建了一些代码,下面是您可能感兴趣的相关代码行:

    $computername=read-host "type in a computername"
    mkdir \\$computername\c$\MyAppInst
    copy-item  "X:\Software\App1\setup.exe"  "\\$computername\c$\MyAppInst"
    start-process "psexec.exe" -args "-accepteula -s -d -i 0 \\$ComputerName wscript.exe C:\MyAppInst\install.vbs" -passthru

我之前构建了自己的 vbscript 包装器来启动应用程序安装,因为我认为 psexec 无法正确处理所有的安装开关。

就我而言,我们需要远程运行 USMT(scanstate)备份。这是我们使用的 vb 代码(抓取了识别公司的信息)。我喜欢在 vb 中使用双引号的转义字符(即 chr(34)),以便于排除故障。我将所有内容放入变量中的另一个重要原因是,我可以 wscript.echo 该变量并准确查看正在运行的内容。

Set objShell = WScript.CreateObject("WScript.Shell")
fileExecutablePath=chr(34) & "C:\Desktop Tools\USMTv2\scanstate.exe" & chr(34)

fileExecutableSwitches=" " & chr(34) & "\\server\migration_data\" & objShell.Environment("PROCESS").Item("COMPUTERNAME") & chr(34) & " /c /localonly /ue:MYDOMAIN\* /ue:" & objShell.Environment("PROCESS").Item("COMPUTERNAME") & "\*" & " /uel:7 /config:" & chr(34) & "C:\Desktop Tools\USMTv2\config.xml" & chr(34) & " /i:" & chr(34) & "C:\Desktop Tools\USMTv2\migapp-CompanyAppsOnly.xml" & chr(34) & " /i:" & chr(34) & "C:\Desktop Tools\USMTv2\migdocs-Company.xml" & chr(34) & " /l:" & chr(34) & "\\server\migration_data\" & objShell.Environment("PROCESS").Item("COMPUTERNAME") & "\" & objShell.Environment("PROCESS").Item("COMPUTERNAME") & "_usmtBACKUP.log" & chr(34) & " /v:13 /targetWindows7"

return=objShell.Run(fileExecutablePath & fileExecutableSwitches, 0, true)

wscript.echo "Your local data has been backed up. This data will be transferred to your new computer. Anything you now save locally will not be transferred."

相关内容