September 08 2010 07:59:25
Navigation
· Home
· Online Store
· Course Outlines (PDF Files)
· Sample Videos
· Contact Info
· Web Links
· Articles (Sample Code)

Other Videos
· WordPress (CMS)
· Joomla (CMS)
· Sharepoint

Other
· FAQ
· Search
Contribute to This Site
· Submit Link
· Get Benefitted Sites
No Competition
One of our so-called competitors offers under 6 hours of video training for a whopping $219 (choke, gasp, spew - you could hire a private tutor for that price). Did I mention that they ship their training on VHS tapes (remember those?). Check out our 'Course Outlines' link above. We offer a 2-days of training (15 hours) for $54 (2 CDs at $29 each). You watch our videos from a CD/ROM on your computer. We also include real-world lab/assignments in each course.
Articles: Write HTML for Browser
Write HTML for Browser
'=========================================================
' Name: WriteHTMLBrowser.vbs 
' Author: Neal Walters 
' http://VBScript-Training.com 
'=========================================================
' 
'  Show two ways to Read a file 
'    1) use the ReadAll method to read all text in one "big gulp" 
'    2) use the ReadLine method in a loop 
'       and loop until AtEndOfStream is true 
'
'  This program also shows how to "filter" and only show lines
'  in the source file that match a keyword (see "searchstring"). 
' 
'
'==========================================================================
option explicit 
dim myfilename, fso, oshell, forReading, forWriting 
dim path, program, fullProgName, myTextStream, ynCreate
dim obj

set fso = CreateObject("Scripting.FileSystemObject") 
set oshell = CreateObject("Wscript.Shell")  

myfilename = "c:\myhtml.html" 

forReading = 1: forWriting = 2: ynCreate = 1 
set myTextStream = fso.OpenTextFile(myfilename,forWriting,ynCreate)

myTextStream.Write "<h1>Processes</H1>" 
myTextStream.Write "<h2>From WMI - Windows Management Instrumentation</h2>" 

myTextStream.Write "<table border=1 cellspacing=2 cellpadding=3>" & vbcrlf 

   myTextStream.Write "<tr>" & vbcrlf 
 
   myTextStream.Write "<th>Process Name</td>" & vbcrlf 
   myTextStream.Write "<th>PeakWorkingSetSize</td>" & vbcrlf 
   myTextStream.Write "<th>Priority</td>" & vbcrlf 

   myTextStream.Write "</tr>" & vbcrlf 

for each obj in GetObject("WinMgmts:").instancesOf("Win32_Process") 
  
   myTextStream.Write "<tr>" & vbcrlf 
 
   myTextStream.Write "<td>" & obj.Caption & "</td>" & vbcrlf 
   myTextStream.Write "<td>" & obj.PeakWorkingSetSize & "</td>" & vbcrlf 
   myTextStream.Write "<td>" & obj.Priority & "</td>" & vbcrlf 

   myTextStream.Write "</tr>" & vbcrlf 
   
next 

myTextStream.Write "</table>" & vbcrlf 



myTextStream.Close 

'path = "C:\Program Files\Internet Explorer"
program = "IEXPLORE" 
'FullProgname = path & "\" & program 
'WScript.Echo FullProgname 
'OShell.Run (program)
OShell.Run (program & " " & myfilename)

'=========================================================
' Name: WriteHTMLBrowserFSO.vbs 
' 
' Author: Neal Walters 
' http://VBScript-Training.com 
'=========================================================
'  Show two ways to Read a file 
'    1) use the ReadAll method to read all text in one "big gulp" 
'    2) use the ReadLine method in a loop 
'       and loop until AtEndOfStream is true 
'
'  This program also shows how to "filter" and only show lines
'  in the source file that match a keyword (see "searchstring"). 
'=========================================================
option explicit 
dim myfilename, myfoldername, fso, oshell, forReading, forWriting 
dim path, program, fullProgName, myTextStream, ynCreate
dim file, mycolor 

Set fso = CreateObject("Scripting.FileSystemObject") 
Set oshell = CreateObject("Wscript.Shell")  

myfilename = "ReportFiles.html" 
myfoldername = "c:\Camtasia Studio\VBScript-Training2" 

If Not fso.FolderExists(myfoldername) Then 
   WScript.Echo "Folder does not exist: " & myfoldername 
   WScript.quit  
End If 

forReading = 1: forWriting = 2: ynCreate = 1 
Set myTextStream = fso.OpenTextFile(myfilename,forWriting,ynCreate)

myTextStream.Write "<H1>Files In <font color='red'>" & myfoldername & "</font></H1>" 

myTextStream.Write "<table border=1 cellspacing=2 cellpadding=3>" & vbcrlf 

   myTextStream.Write "<tr>" & vbcrlf 
 
   myTextStream.Write "<th>Filename</th>" & vbcrlf 
   myTextStream.Write "<th>Filesize</th>" & vbcrlf 
   myTextStream.Write "<th>DateCreated</th>" & vbcrlf 
   myTextStream.Write "<th>DateModified</th>" & vbcrlf 

   myTextStream.Write "</tr>" & VbCrLf 

for each file In fso.GetFolder(myfoldername).Files  
  
   myTextStream.Write "<tr>" & VbCrLf 
 
   myTextStream.Write "<td>" & file.Name & "</td>" & VbCrLf 
   'build syntax:  <font color='red'>  or <font color='green'> 
   
   If file.size > 500 Then 
      mycolor = "red" 
   Else 
      mycolor = "green" 
   End If 
   
   myTextStream.Write "<td><font color='" & mycolor & "'>" & file.size & "<font></td>" & vbcrlf 
   myTextStream.Write "<td>" & file.DateCreated & "</td>" & vbcrlf 
   myTextStream.Write "<td>" & file.DateLastModified & "</td>" & vbcrlf 

   myTextStream.Write "</tr>" & VbCrLf 
   
Next 

myTextStream.Write "</table>" & VbCrLf 

myTextStream.Close 

Dim fqfilename 
fqfilename = fso.GetFile(myfilename).path

WScript.Echo "fqfilename=" & fqfilename 


'WScript.Quit 

'path = "C:\Program Files\Internet Explorer"
program = "IEXPLORE" 
'FullProgname = path & "\" & program 
'WScript.Echo FullProgname 
'OShell.Run (program)
oshell.Run (program & " " & fqfilename)

'============================================================
' Name: WriteHTMLBrowserWMI.vbs  
' Author: Neal Walters 
' http://VBScript-Training.com 
'============================================================
'============================================================
option explicit 
dim myfilename, myfoldername, fso, oshell, forReading, forWriting 
dim path, program, fullProgName, myTextStream, ynCreate
dim obj

set fso = CreateObject("Scripting.FileSystemObject") 
set oshell = CreateObject("Wscript.Shell")  

myfilename = "ReportFiles.html" 
myfoldername = "C:\FSODEMO" 

forReading = 1: forWriting = 2: ynCreate = 1 
set myTextStream = fso.OpenTextFile(myfilename,forWriting,ynCreate)

myTextStream.Write "<h1>Files in" & myfoldername & "</H1>" 

myTextStream.Write "<table border=1 cellspacing=2 cellpadding=3>" & vbcrlf 

   myTextStream.Write "<tr>" & vbcrlf 
 
   myTextStream.Write "<th>Process Name</td>" & vbcrlf 
   myTextStream.Write "<th>PeakWorkingSetSize</td>" & vbcrlf 
   myTextStream.Write "<th>Priority</td>" & vbcrlf 

   myTextStream.Write "</tr>" & vbcrlf 

for each obj in GetObject("WinMgmts:").instancesOf("Win32_Process") 
  
   myTextStream.Write "<tr>" & vbcrlf 
 
   myTextStream.Write "<td>" & obj.Caption & "</td>" & vbcrlf 
   myTextStream.Write "<td>" & obj.PeakWorkingSetSize & "</td>" & vbcrlf 
   myTextStream.Write "<td>" & obj.Priority & "</td>" & vbcrlf 

   myTextStream.Write "</tr>" & vbcrlf 
   
next 

myTextStream.Write "</table>" & vbcrlf 



myTextStream.Close 

'path = "C:\Program Files\Internet Explorer"
program = "IEXPLORE" 
'FullProgname = path & "\" & program 
'WScript.Echo FullProgname 
'OShell.Run (program)
OShell.Run (program & " " & myfilename)

Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Order Now - View Products


Default Shipping:
Phone: 214-403-6006
Our Sites
Software Training
XML-Online-Training.com
Biztalk-Training.com
SharePoint-Training.com
DotNet-AddOns-Training.com
CMSTrainingVideos.com

Language
LanguageLovers.com
Render time: 0.22 seconds 432,183 unique visits