没有Powershell远程安装

没有Powershell远程安装

本文介绍了没有Powershell远程安装.msi吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个多服务器系统,需要在客户端站点上安装.我想编写一个可以执行以下操作的脚本:

We have a multi server system that we need to install at a client site. I would like to put together a script that can:

  1. 关闭远程计算机上的服务
  2. 在多台远程计算机上卸载软件
  3. 在多个远程计算机上安装.msi文件

我一直在努力与 psexec wmic 进行第2点和第3点.

I've struggled with psexec and wmic to do points #2 and #3.

似乎有一种不必使用 PowerShell 的简单方法.

It seems like there has to be an easier way without having to resort to PowerShell.

推荐答案

首先,请参见以下线程进行 WSH Remoting : 在Windows Server 2012 R2上进行远程安装 .

First, see this thread for WSH Remoting: Remote Install on Windows Server 2012 R2.

然后,您也许可以尝试使用 VBScript库,例如 VbsEdit (我不喜欢提出软件建议,但是我认为它是允许的,因为我没有隶属关系,并希望提出它来解决问题):

Then, you can perhaps you can try to use a VBScript library such as that available in VbsEdit (I don't like to make software recommendations, but I assume it is allowed since I am not affiliated and want to suggest it to solve the problem):

以下是用于远程安装软件的脚本:

' Install Software on a Remote Computer
Const wbemImpersonationLevelDelegate = 4

Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objConnection = objwbemLocator.ConnectServer _
    ("WebServer", "root\cimv2", "fabrikam\administrator", _
         "password", , "kerberos:WebServer")
objConnection.Security_.ImpersonationLevel = wbemImpersonationLevelDelegate

Set objSoftware = objConnection.Get("Win32_Product")
errReturn = objSoftware.Install("\\atl-dc-02\scripts\1561_lab.msi",,True)

以下是用于停止服务的脚本:

' Stop Services Running Under a Specific Account
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service Where StartName = '.\netsvc'")

For Each objService in colServices
    errReturnCode = objService.StopService()
Next


以下是VbsEdit的脚本库的屏幕截图:

这篇关于没有Powershell远程安装.msi吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 00:17