Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 16 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Here is something I tried & I keep getting this error referencing the bolded line:error: Type mismatchcode: 800A000DSource: runtime errorany ideas why? Thanks
'designate path where excel sheet containing user names residesstrSheet = "xfiles109629$vbscriptsallwindowsservers.xls"'open the excel sheet & make it visibleSet objExcel = CreateObject("Excel.Application")Set objSpread = objExcel.Workbooks.Open(strSheet)objExcel.Visible = True'create log file for DNS querydim oFSO,oCS,oNCSset oFSO=CreateObject("Scripting.FileSystemObject")set oCS=oFSO.createtextfile("xfiles109629$vbscriptscompliantservers.txt")set oNCS=oFSO.createtextfile("xfiles109629$vbscriptsnoncompliantservers.txt")'loop through each item in the excel sheet & query dns servers.i = 1Do Until objExcel.Cells(i, 1).Value = "" strHost = objExcel.Cells(i,1)'On Error Resume NextSet objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!" & strhost & "rootcimv2")Set colNetCards = objWMIService.ExecQuery _ ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")For Each objNetCard in colNetCards 'wscript.echo objNetCard.DNSServerSearchOrder oCS.write strHost & objNetCard.DNSServerSearchOrder & vbcrlfNext i = i + 1 Loop'objExcel.Quit'oCS.close'oNCS.closeWscript.echo "Execution of script is complete"[end of code]
Here is something I tried & I keep getting this error referencing the bolded line:error: Type mismatchcode: 800A000DSource: runtime errorany ideas why? Thanks
'designate path where excel sheet containing user names residesstrSheet = "xfiles109629$vbscriptsallwindowsservers.xls"'open the excel sheet & make it visibleSet objExcel = CreateObject("Excel.Application")Set objSpread = objExcel.Workbooks.Open(strSheet)objExcel.Visible = True'create log file for DNS querydim oFSO,oCS,oNCSset oFSO=CreateObject("Scripting.FileSystemObject")set oCS=oFSO.createtextfile("xfiles109629$vbscriptscompliantservers.txt")set oNCS=oFSO.createtextfile("xfiles109629$vbscriptsnoncompliantservers.txt")'loop through each item in the excel sheet & query dns servers.i = 1Do Until objExcel.Cells(i, 1).Value = "" strHost = objExcel.Cells(i,1)'On Error Resume NextSet objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!" & strhost & "rootcimv2")Set colNetCards = objWMIService.ExecQuery _ ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")For Each objNetCard in colNetCards 'wscript.echo objNetCard.DNSServerSearchOrder oCS.write strHost & objNetCard.DNSServerSearchOrder & vbcrlfNext i = i + 1 Loop'objExcel.Quit'oCS.close'oNCS.closeWscript.echo "Execution of script is complete"[end of code]
This topic is 16 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.