bpeikes
bpeikes

Reputation: 3695

Installing .msi remotely without powershell?

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. Turn off services on remote machines
  2. Uninstall software on several remote machines
  3. Install .msi files several remote machines

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

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

Upvotes: 1

Views: 532

Answers (1)

Stein Åsmul
Stein Åsmul

Reputation: 42136

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

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):

Here is a script to install software remotely:

' 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)

Here is a script to stop services:

' 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

Here is a screen shot from VbsEdit's script library:

VbsEdit Search Samples

Upvotes: 1

Related Questions