windows 在远程机器上安装软件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/995050/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 12:38:17  来源:igfitidea点击:

Install software on a remote machine?

windowsvbscript

提问by Galilyou

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!

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

回答by Tester101

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.

** 此脚本未经测试。

回答by Dan F

Can you use psexec?

你可以使用psexec吗?

Or, it seems you can use the Install method of the WMI Win32_Product class. See technetfor more info. There's some more info in this serverwatch articletoo

或者,您似乎可以使用 WMI Win32_Product 类的 Install 方法。见的TechNet的更多信息。有这样一些详细信息serverwatch文章

回答by Helen

TechNet has a sample script: Install Software on a Remote Computer.

TechNet 有一个示例脚本:在远程计算机上安装软件

回答by Brady Holt

Write some VbScript around the commands outlined here: "Remote Unattended MSI Installation with PsExec" - http://www.geekytidbits.com/unattended-msi-installation-psexec/

围绕此处列出的命令编写一些 VbScript:“使用 PsExec 进行远程无人值守 MSI 安装” - http://www.geekytidbits.com/unattended-msi-installation-psexec/