这看起来像是一个垃圾问题,但我对 VbScript 的完全无知让我没有机会尝试解决它。简而言之,我的一位系统管理员朋友要求我为他编写一个脚本,允许他输入远程计算机名称、域凭据以及将安装在指定远程计算机上的 MSI 包。
我知道这很愚蠢,我的意思是,来吧!没有人可以直接登录SO并索要蛋糕,人们应该询问如何将蛋糕煮熟。我知道,但请原谅我绝对的懒惰并帮助!
这将打开简单的输入框以获取所需的信息。 *注意:仅检查输入以确保其不为空,输入无效数据将导致脚本失败。
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)
** 该脚本未经测试。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)