在远程机器上安装软件? [英] Install software on a remote machine?

查看:36
本文介绍了在远程机器上安装软件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是一个转储问题,但我对 VbScript 的完全无知使我没有机会尝试解决它.简而言之,我的一个系统管理员朋友让我给他写一个脚本,允许他输入远程机器名称、域凭据和将安装在指定远程机器上的 MSI 包.
我知道这很愚蠢,我的意思是,来吧!没有人可以登录 SO 并要求蛋糕,人们应该询问如何将蛋糕煮熟.我知道,但请原谅我绝对的懒惰和帮助!

This might seem like a dump question, but my complete ignorance with VbScript is giving me no chance to try to work it out. In short, a system administrator friend of mine, asked me to write him a script that should allow him to enter a remote machine name, a domain credentials, and an MSI package that will be installed on the specified remote machine.
I know this is silly, I mean, come on! No one can just log in to SO and ask for a cake, people should ask about how to get the cake cooked. I know, but please forgive my absolute laziness and help!

推荐答案

这将打开简单的输入框以获取所需信息.*注意:仅检查输入以确保其不为空,输入无效数据将导致脚本失败.

This will open simple input boxes to get the required information. *NOTE: Input is only checked to make sure it is not blank, entering invalid data will cause the script to fail.

strUser = ""
strPassword = ""
strMSI = ""
strComputer = ""

'Get user name, cannot be blank
Do While strUser = ""
    strUser = InputBox("Enter user name", "User Name")
Loop
'Get password, cannot be blank
Do While strPassword = ""
    strPassword = InputBox("Enter password", "Password")
Loop
'Get msi package path, cannot be blank
Do While strMSI = ""
    strMSI = InputBox("Enter the path to the msi package", "MSI package")
Loop
'Get destination computer, cannot be blank
Do While strComputer = ""
    strComputer = InputBox("Enter the destination computer name", "Computer")
Loop


Const wbemImpersonationLevelDelegate = 4

Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objConnection = objwbemLocator.ConnectServer _
    (strComputer, "root\cimv2", strUser, strPassword)
objConnection.Security_.ImpersonationLevel = wbemImpersonationLevelDelegate

Set objSoftware = objConnection.Get("Win32_Product")
errReturn = objSoftware.Install(strMSI,,True)

** 此脚本未经测试.

** This script is untested.

这篇关于在远程机器上安装软件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆