;***************************************************************************
;** Get-Process or Get-Service then Convert to HTML
;**
;** Purpose: Retrieves information about all the processes running on the computer and
;** creates and display an HTML table
;**
;** Inputs: PowerShell Command with Set-Content
;** Outputs: Results in a WIL Dialog
;** Reference:
;** REQUIRES WinBatch 2013A or newer
;**
;** Developers: Deana Falk 2013.05.28 Initial
;** Stan Littlefield 2013.05.29 Added HTML formatting
;***************************************************************************
If Version( )< '2013A'
Pause('Notice', 'Need 2013A or Newer Version of WinBatch')
Exit
EndIf
;***************************************************************************
;** Get-Process
;***************************************************************************
PSCmd = `Get-Process | ConvertTo-Html -head $a | Set-Content `
;***************************************************************************
;** Get-Service
;***************************************************************************
;PSCmd = `Get-Service | Select-Object Status, Name, DisplayName | ConvertTo-Html -head $a | Set-Content `
strHTMLFile = DirScript():"ProcessList.html" ; Output file
if FileExist( strHTMLFile ) then FileDelete( strHTMLFile )
; Powershell Code
cScript = '$a = "<style>"':@CRLF
cScript = cScript:'$a = $a + "BODY{background-color:peachpuff;}"':@CRLF
cScript = cScript:'$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"':@CRLF
cScript = cScript:'$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"':@CRLF
cScript = cScript:'$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:palegoldenrod}"':@CRLF
cScript = cScript:'$a = $a + "</style>"':@CRLF
cScript = cScript : PSCmd : strHTMLFile
BoxOpen("Please Wait","Processing... ")
ObjectClrOption("use", "System.Management.Automation,version=1.0.0.0,publicKeyToken=31bf3856ad364e35,culture=neutral")
objAutoPs = ObjectClrNew("System.Management.Automation.PowerShell")
oPshell = objAutoPs.Create()
oScope = ObjectType("BOOL",@TRUE)
oPshell.AddScript(cScript,oScope)
objAsync = oPshell.BeginInvoke()
oPShell.EndInvoke(objAsync)
oPshell.Dispose()
oPshell=0
BoxShut()
If !FileExist( strHTMLFile )
Display(2, "File Not Created", strHTMLFile )
Exit
Endif
MyDialogFormat=`WWWDLGED,6.2`
MyDialogCaption=`Process List`
MyDialogX=002
MyDialogY=059
MyDialogWidth=766
MyDialogHeight=353
MyDialogNumControls=003
MyDialogProcedure=`DEFAULT`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0
MyDialog001=`231,333,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`499,333,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`033,023,696,298,COMCONTROL,"ComControl_1",DEFAULT,"`:strHTMLFile:`",DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ButtonPushed=Dialog("MyDialog")
Exit
XML
<?xml version="1.0"?>
<books>
<book id="bk001">
<author>Writer</author>
<title>The First Book</title>
<genre>Fiction</genre>
<price>44.95</price>
<pub_date>2000-10-01</pub_date>
<review>An amazing story of nothing.</review>
</book>
<book id="bk002">
<author>Poet</author>
<title>The Poet's First Poem</title>
<genre>Poem</genre>
<price>24.95</price>
<review>Least poetic poems
</book>
</books>
HTML
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>