变量告诉脚本文本文件所在的位置在哪里?

时间:2014-05-12 23:10:49

标签: vbscript

我有这个脚本,但无法弄清楚我的生活如何使用它。在powershell中,我只想将文件的位置设置为

  `$location = get-content (c:\folder\servers.txt)`

但我无法弄清楚如何通过VBscript读取文本文件。 我想要做的就是在服务器列表上安装一个应用程序:(

这是我得到的错误

test.vbs(6,9)Microsoft VBScript运行时错误:所需对象:' objMasterVariablesFile'

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

    'load and read from a text file
    Do While objMasterVariablesFile.AtEndOfStream <> True

        strLine = objMasterVariablesFile.ReadLine

        'skip if ' found at start of line, to allow for comment lines
        If inStr(1, strLine, "'") Then

        Else

            servername = strLine

            'install code here
            Const wbemImpersonationLevelDelegate = 4

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

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

        End If

    Loop

0 个答案:

没有答案