1

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.

2
  • I suppose most sites have a deployment software such as SCCM (formerly SMS), IBM's Tivoli, CA Unicenter or similar. Perhaps this is even available there? Commented Nov 12, 2014 at 11:01
  • If these deployment tools are available, I would not recommend messing with scripts of any kind. If not, please see my other answer below. Commented Nov 12, 2014 at 11:22

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.