Here is an example of the Live Writer PlugIn from Steve Dunn. As you can see it does not add scrollbars or truncate lines within the control as could be expected.
The formatting is excellent for this example although the control is sluggish in Writer due to screen paints not be suppressed during the scroll. This seems to be an artifact of the control itself. Once the control is de-selected the scroll problems go away. Sometimes, when the control is highlighted, The insertion point gets stuck in the control and the UI becomes completely unresponsive.
I like the formatter an hope that it will improve with time.
Notice that the lines are rendered across the whole page outside of the controls area. The control needs to contain everything inside of a DIV and allow styling to turn on the scroll bars. This would allow the code to be viewed without annoying linewraps. It would also allow it to be copied and pasted without errors.
1 Option Explicit
2 Const ForReading = 1
3 Const ForAppending = 8
4 Const sLogFileName = "d:\log.txt"
5 Const sServerFileName = "d:\servers.txt"
6 'On Error Resume Next
7 Dim objDictionary, objFSO, objOU, objComputer, strComputer
8 Dim colNetcards, objWMIService, objNetcard, arrWINSServers
9 Dim i, objItem, sName, objTextFile, strNextLine
10
11 Set objDictionary = CreateObject("Scripting.Dictionary")
12 Set objFSO = CreateObject("Scripting.FileSystemObject")
13 Set objTextFile = objFSO.OpenTextFile(sServerFileName, ForReading)
14 i = 0
15 Do Until objTextFile.AtEndOfStream
16 strNextLine = objTextFile.Readline
17 objDictionary.Add i, strNextLine
18 i = i + 1
19 Loop
20 objTextFile.close
21
22 Dim oLogFile
23 Set oLogFile = objFSO.OpenTextFile(sLogFileName, ForAppending)
24 For Each objItem in objDictionary
25
26 StrComputer = objDictionary.Item(objItem)
27 WScript.Echo "Begin pinging:" & strComputer
28 If TestPing(strComputer) = False Then
29 WScript.Echo now() & " Couldn't reach " & strComputer
30 oLogFile.WriteLine now() & " Couldn't reach " & strComputer
31 Else
32 WScript.Echo "Ping successful!"
33 Set objWMIService = GetObject("winmgmts:\\" & strComputer& "\root\cimv2")
34 Set colNetCards = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = TRUE AND NOT Description LIKE '%ISCSI'")
35 For Each objNetCard In colNetcards
36 WScript.Echo objNetCard.Description
37 arrWINSServers = Array("Null", "Null")
38 'objNetCard.SetWINSServerSearchOrder(arrWINSServers)
39 Next
40 End If
41
42 Next
43
44 oLogFile.Writeline ""
45 oLogFile.Close
46 WScript.echo "Script Finished"
47
48 Function TestPing(sName)
49 TestPing = false
50 If sName = "" Then
51 WScript.Echo "Bad computer name string!"
52 else
53 Dim cPingResults, oPingResult
54 Set cPingResults = GetObject("winmgmts://./root/cimv2").ExecQuery("SELECT * FROM Win32_PingStatus WHERE Address = '" & sName & "'")
55 For Each oPingResult In cPingResults
56 If oPingResult.StatusCode = 0 Then
57 TestPing = True
58 End If
59 Next
60 End if
61 End Function
62
63
No comments:
Post a Comment