Vbscript 告诉脚本文本文件所在位置的变量在哪里?
我有这个脚本,但我一辈子都不知道如何使用它。在powershell中,我只需将文件的位置设置为Vbscript 告诉脚本文本文件所在位置的变量在哪里?,vbscript,Vbscript,我有这个脚本,但我一辈子都不知道如何使用它。在powershell中,我只需将文件的位置设置为 `$location = get-content (c:\folder\servers.txt)` 但我不知道如何通过VBscript读取文本文件。 我只想在服务器列表上安装一个应用程序:( 这是我得到的错误 test.vbs(6,9)Microsoft VBScript运行时错误:需要对象:“objMasterVariablesFile” strUser = "" strPassword =
`$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
strUser=“”
strPassword=“”
strMSI=“”
'从文本文件加载和读取
当objMasterVariablesFile.AtEndOfStream为True时执行此操作
strLine=objMasterVariablesFile.ReadLine
在行首找到“跳过如果”,以允许注释行
如果inStr(1,strLine,“”),则
其他的
servername=strLine
'在此处安装代码
常量wbemImpersonationLevelDelegate=4
设置objWbemLocator=CreateObject(“WbemScripting.SWbemLocator”)
设置objConnection=objwbemLocator.ConnectServer_
(服务器名,“root\cimv2”,strUser,strPassword)
objConnection.Security\uu.ImpersonationLevel=WBEMpersonationLevelDelegate
设置objSoftware=objConnection.Get(“Win32_产品”)
errReturn=objSoftware.Install(strMSI,,True)
如果结束
环
发布新问题之前,请在此进行基本搜索。在这种情况下,快速搜索[vbscript]阅读文本文件
(包括括号)将显示许多相关帖子,这些帖子将为您解答此问题。谢谢。(第一个提示:您必须实际打开该文件,然后才能开始阅读。)事实上,第一个搜索结果的两个答案显示了如何从文本文件中读取,并附有完整的代码。)谢谢Ken。。我会的