我正在尝试重新调整并保留一个数组,以便它将删除数组中的任何空白行。但我得到一个错误
类型不匹配
在 redim 所在的行上。我需要先设置数组的 lbound 和 ubound 吗?
option Explicit
Const ForReading = 1
Const ForAppending = 8
Const ForWriting = 2
Dim objFSO, objUsersFile, arrFileLines, a, strDN, objUser, arrMemberOf, regex, group, strData, strObject, objRootDSE, objConnection, ADLogFile
Dim objCommand, WshShell, TriStateTrue, strDNSDomain, objRecordSet, workdir, strUsers, strDateAndTime, strDayOfMonth, strMonth, strYear, strDate, strTime
Dim strOU, strFlag, Args, strfile, objFile, strAddRemoveUser, strAdminsGroup, strUserDN, ADSuccessLogFile, strUser, strGroup, objGroup
Dim strType, strPreventMDriveDelete, strAddRemove, wshNetwork, strDomainName, strPreventWin7Upgrade, strWin7Advert
Dim ADFailedLogFile, strMachine, objComputer, strMachineDN, objMachine, strPackageCode, strAppInstall, strNTName, k
Dim arrFileLine()
Set objFSO = CreateObject("Scripting.FileSystemObject")
set WshShell = WScript.CreateObject ("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set Args = WScript.Arguments
strType = "User"
strAddRemove = "Add"
strOU = "EU"
strAdminsGroup = strOU & "-SYS-MGRT-DESKTOP"
'set date for use in file names
strDayOfMonth = Right("0" & Day(Date()),2)
strMonth = Right("0" & Month(Date()),2)
strYear = Right (Year(Date()),4)
strDate = strDayOfMonth & "-" & strMonth & "-" & strYear
strTime = replace(Time(),":",".")
strDateAndTime = strDate & "-" & strTime
Workdir = "C:\script\admin"
Set ADSuccessLogFile = objFSO.OpenTextFile(workdir & "\Logs\Success" & strDateAndTime & ".txt", ForAppending,True)
Set ADFailedLogFile = objFSO.OpenTextFile(workdir & "\Logs\Failed" & strDateAndTime & ".txt", ForAppending,True)
strDNSDomain = objRootDSE.get("defaultNamingContext")
strFile = Args.item(0)
If right (strFile,3) = "txt" Then
Set objFile = objFSO.OpenTextFile(strFile, 1)
k = 0
Do Until objFile.AtEndOfStream
strUser = Trim(objFile.ReadLine)
If (strUser <> "") Then
ReDim Preserve arrFileLines(k)
arrFileLines(k) = strUser
k = k + 1
End If
Loop
objFile.Close
Else
ReDim arrFileLines(0)
arrFileLines(0) = strFile
End If
for each struser in arrfilelines
wscript.echo struser
next