How to embed VBS in PB App

Just starting out? Need help? Post your questions and find answers here.
astonfr
New User
New User
Posts: 5
Joined: Sun Aug 03, 2008 8:04 am

How to embed VBS in PB App

Post by astonfr »

I'm trying to find a way to embed a vbs script and running it in memory.

This is an example code, but how can I make it execute without CSCRIPT.exe and without writing it on a .vbs file.

Are there any APIs that we can call that can process array of vbs?

Thanks

Code: Select all

'----------------------
' Title: System Information Script
' Author: Bradley Buskey
' Contact: deckyon@sturm.org
' Date: October 30, 2006
' Updated: March 29, 2007
' Purpose: Quickly show basic system information for an entered workstation ID
' Tested On: Currently verified to work on Windows XP and Windows Server 2003
'----------------------

On Error Resume Next
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002

Dim strComputer, objWMIService, propValue, objItem
Dim strUserName, strPassword, colItems, SWBemlocator

' This section querries for the workstation to be scanned.
strComputer = inputbox ("Workstation", "Enter the workstation ID to scan.",".")
UserName = ""
Password = ""
ImgDir = "C:\Scripts\images\"

'Sets up the connections and opjects to be used throughout the script.
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(strComputer,"root\CIMV2",strUserName,strPassword)

'This determines the current date and time of the PC being scanned.
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LocalTime", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem in colItems
    If objItem.Minute < 10 Then
        theMinutes = "0" & objItem.Minute
    Else
        theMinutes = objItem.Minute
    End If
    If objItem.Second < 10 Then
        theSeconds = "0" & objItem.Second
    Else
        theSeconds = objItem.Second
    End If
    DateTime = objItem.Month & "/" & objItem.Day & "/" & objItem.Year & " - " & objItem.Hour & ":" & theMinutes & ":" & theSeconds
Next

'Gets some ingomation about the Operating System including Service Pack level.
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem in colItems
    WKID = objItem.CSName
    WKOS = objItem.Caption
    ServicePack = objItem.ServicePackMajorVersion & "." & objItem.ServicePackMinorVersion
Next

'This section returns the Video card and current resolution.
Set colItems = objWMIService.ExecQuery("Select * from Win32_DisplayConfiguration",,48)
For Each objItem in colItems
    VideoCard = objItem.DeviceName
    Resolution = objItem.PelsWidth & " x " & objItem.PelsHeight & " x " & objItem.BitsPerPel & " bits"
Next

'This section returns the Video card memory.
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * from Win32_VideoController")
For Each objItem in colItems
    VideoMemory = objItem.AdapterRAM/1024/1024
Next

'This returns various system information including current logged on user, domain, memory, manufacture and model.
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
    UserName = objItem.UserName
    Domain = objItem.Domain
    TotalMemory = int((objItem.TotalPhysicalMemory/1024)/1024+1)
    Manufacturer = objItem.Manufacturer
    Model = objItem.Model
Next

'This determines the total hard drive space and free hard drive space.
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk Where Name='C:'",,48)
For Each objItem in colItems
    FreeHDSpace = Fix(((objItem.FreeSpace/1024)/1024)/1024)
    TotalHDSpace = Fix(((objItem.Size/1024)/1024)/1024)
Next

'This section returns the default printer and printer port.
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Printer where Default=True", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem in colItems
    Printer = objItem.Name
    PortName = objItem.PortName
Next

'This returns the CPU information.
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem in colItems
    CPUDesc = LTrim(objItem.Name)
Next

'This returns the current uptime (time since last reboot) of the system.
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOS in colOperatingSystems
    dtmBootup = objOS.LastBootUpTime
    dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
    dtmSystemUptime = DateDiff("h", dtmLastBootUpTime, Now)
    Uptime = dtmSystemUptime
Next
Function WMIDateStringToDate(dtmBootup)
    WMIDateStringToDate = CDate(Mid(dtmBootup, 5, 2) & "/" & Mid(dtmBootup, 7, 2) & "/" & Left(dtmBootup, 4) & " " & Mid (dtmBootup, 9, 2) & ":" & Mid(dtmBootup, 11, 2) & ":" & Mid(dtmBootup,13, 2))
End Function

'This sets up the Internet Explorer window in order to show the results.
Set objExplorer = WScript.CreateObject("InternetExplorer.Application", "IE_")
With objExplorer
    .Navigate "about:Blank"
    .Toolbar = 0
    .StatusBar = 0
    .Width = 800
    .Height = 600
    .Left = 75
    .Top = 0
    .Visible = 1
End With
Set fileOutput = objExplorer.Document

'This is the code for the web page to be displayed.
fileOutput.Open
fileOutput.WriteLn "<html>"
fileOutput.WriteLn "    <head>"
fileOutput.WriteLn "        <title>System Information for '" & WKID & "' </title>"
fileOutput.WriteLn "    </head>"
fileOutput.WriteLn "    <body bgcolor='#FFFFFF' text='#000000' link='#0000FF' vlink='000099' alink='#00FF00'>"
fileOutput.WriteLn "        <center>"
fileOutput.WriteLn "            <h3>Workstaion/Server Information for " & WKID & "</h3>"
fileOutput.WriteLn "            <table border='0' cellspacing='1' cellpadding='1' width='95%'>"
fileOutput.WriteLn "                <tr><td background='" & ImgDir & "blue_spacer.gif'>"
fileOutput.WriteLn "                    <table border='0' cellspacing='0' cellpadding='0' width='100%'>"
fileOutput.WriteLn "                        <tr><td>"
fileOutput.WriteLn "                            <table border='0' cellspacing='0' cellpadding='0' width='100%'>"
fileOutput.WriteLn "                                <tr>"
fileOutput.WriteLn "                                    <td width='5%' align='left' valign='middle' background='" & ImgDir & "blue_spacer.gif'><img src='" & ImgDir & "write.gif'></td>"
fileOutput.WriteLn "                                    <td width='95%' align='left' valign='middle' background='" & ImgDir & "blue_spacer.gif'> <font color='#FFFFFF' size='5'>WKInfo - </font><font color='#FFFFFF' size='3'>General information on the Workstation.</font></td>"
fileOutput.WriteLn "                                </tr>"
fileOutput.WriteLn "                                <tr><td colspan='2' bgcolor='#FFFFFF'>"
fileOutput.WriteLn "                                    <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Last Scanned</i></b></TD></TR>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Date/Time</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & DateTime & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>System Uptime</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Uptime & " hours</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Information</i></b></TD></TR>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Workstation ID</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & WKID & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Domain</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Domain & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>UserName</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & UserName & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General OS Information</i></b></TD></TR>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Operating System</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & WKOS & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Service Pack</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & ServicePack & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Computer Information</i></b></TD></TR>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Manufacturer</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Manufacturer & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Model</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Model & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Hardware Information</i></b></TD></TR>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>CPU</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & CPUDesc & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Memory</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & TotalMemory & " MB</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Total HD Space</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & TotalHDSpace & " GB</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Free HD Space</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & FreeHDSpace & " GB</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Video Card Information</i></b></TD></TR>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Video Card</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & VideoCard & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Resolution</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Resolution & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Memory</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & VideoMemory & " MB</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Default Printer Information</i></b></TD></TR>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Printer</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Printer & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Port Name</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & PortName & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Shared Directories</i></b></TD></TR>"
'This sextion lists all the current shares enabled on the PC.
fileOutput.WriteLn "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>"
fileOutput.WriteLn "                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
fileOutput.WriteLn "                                                <TR><TD width='30%' align='center' bgcolor='#e0e0e0'><b>Name</b></td><TD width='40%' align='center' bgcolor='#e0e0e0'><b>Path</b><TD width='40%' align='center' bgcolor='#e0e0e0'><b>Description</b></td><tr>"
Set colShares = objWMIService.ExecQuery("Select * from Win32_Share")
For each objShare in colShares
    fileOutput.WriteLn "                                                <TR><TD width='30%' align='left' bgcolor='#f0f0f0'><i>" & objShare.Name & "</i></TD><td bgcolor=#f0f0f0 align=left><i>" & objShare.Path & "</i></TD><td bgcolor=#f0f0f0 align=left><i>" & objShare.Caption & "</i></td></tr>"
Next
fileOutput.WriteLn "                                            </table>"
fileOutput.WriteLn "                                        </td></tr>"
'This section lists all the current services and their status.
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Current Service Information</i></b></TD></TR>"
fileOutput.WriteLn "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>"
fileOutput.WriteLn "                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
fileOutput.WriteLn "                                                <TR><TD width='70%' align='center' bgcolor='#e0e0e0'><b>Service Name</b></td><TD width='30%' align='center' bgcolor='#e0e0e0'><b>Service State</b></td><tr>"
Set colRunningServices = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objService in colRunningServices
fileOutput.WriteLn "                                            <TR><TD align='left' bgcolor='#f0f0f0'>" & objService.DisplayName & "</TD><td bgcolor=#f0f0f0 align=center><i>" & objService.State & "</i></td></tr>"
Next
fileOutput.WriteLn "                                            </table>"
fileOutput.WriteLn "                                        </td></tr>"
'This section lists all the current running processes and some information.
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Current Process Information</i></b></TD></TR>"
fileOutput.WriteLn "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>"
fileOutput.WriteLn "                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
fileOutput.WriteLn "                                                <TR><TD width='10%' align='center' bgcolor='#e0e0e0'><b>PID</b></td><TD width='35%' align='center' bgcolor='#e0e0e0'><b>Process Name</b></td><TD width='40%' align='center' bgcolor='#e0e0e0'><b>Owner</b></td><TD width='15%' align='center' bgcolor='#e0e0e0'><b>Memory</b></td></tr>"
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process")
For Each objProcess in colProcessList
colProperties = objProcess.GetOwner(strNameOfUser,strUserDomain)
fileOutput.WriteLn "                                                <TR><TD align='center' bgcolor='#f0f0f0'>" & objProcess.Handle & "</td><TD align='center' bgcolor='#f0f0f0'>" & objProcess.Name & "</td><TD align='center' bgcolor='#f0f0f0'>" & strUserDomain & "\" & strNameOfUser & "</td><TD align='center' bgcolor='#f0f0f0'>" & objProcess.WorkingSetSize/1024 & " kb</td><tr>"
Next
fileOutput.WriteLn "                                            </table>"
fileOutput.WriteLn "                                        </td></tr>"
'This section lists all the currently installed software on the machine.
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Installed Software</i></b></TD></TR>"
fileOutput.WriteLn "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>"
Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product")
For Each objSoftware in colSoftware
    fileOutput.WriteLn"                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
    fileOutput.WriteLn"                                                <tr><td align=left bgcolor='#e0e0e0'><b>Caption:</b></td><td colspan=2 bgcolor=#f0f0f0>" & objSoftware.Caption & "</td></tr>"
    fileOutput.WriteLn"                                                <tr><td align=left bgcolor='#e0e0e0'><b>Install Location:</b></td><td colspan=2 bgcolor=#f0f0f0>" & objSoftware.InstallLocation & "</td></tr>"
    fileOutput.WriteLn"                                                <tr><td width=30% align=center bgcolor='#e0e0e0'><b>Name</b></td><td width=30% align=center bgcolor='#e0e0e0'><b>Vendor</b></td><td width=30% align=center bgcolor='#e0e0e0'><b>Version</b></td></tr>"
    fileOutput.WriteLn"                                                <tr><td align=center bgcolor=#f0f0f0>" & objSoftware.Name & "</td><td align=center bgcolor=#f0f0f0>" & objSoftware.Vendor & "</td><td align=center bgcolor=#f0f0f0>" & objSoftware.Version & "</td></tr>"
    fileOutput.WriteLn"                                                <tr height=2><td height=10 align=center bgcolor=midnightblue colspan=3></td></tr>"
    fileOutput.WriteLn"                                            </table>"
Next
fileOutput.WriteLn "                                        </td></tr>"
fileOutput.WriteLn "                                    </table>"
fileOutput.WriteLn "                                </td></tr>"
fileOutput.WriteLn "                            </table>"
fileOutput.WriteLn "                        </td></tr>"
fileOutput.WriteLn "                    </table>"
fileOutput.WriteLn "                </td></tr>"
fileOutput.WriteLn "            </table>"
fileOutput.WriteLn "            <p><small>© 2005-2007, Bradley Buskey</small></p>"
fileOutput.WriteLn "        </center>"
fileOutput.WriteLn "    </body>"
fileOutput.WriteLn "<html>"
fileOutput.close
WScript.Quit 
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

how can I make it execute without CSCRIPT.exe and without writing it on a .vbs file.
not at all!

VBS is a Script-Language by Microsoft, you have to use a Microsoft-Engine Runtime to use it legally.

if you want to embed some script into a PB application, there are various Script-Languages out there, supported by Includes or Libs.
oh... and have a nice day.
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

Kaeru Gaman wrote:
how can I make it execute without CSCRIPT.exe and without writing it on a .vbs file.
not at all!

VBS is a Script-Language by Microsoft, you have to use a Microsoft-Engine Runtime to use it legally.

if you want to embed some script into a PB application, there are various Script-Languages out there, supported by Includes or Libs.
That's not exactly correct, if I remember correctly you can run VBScripts via
a COM interface without having to execute C/WScript.exe...
I haven't used COM yet, but you might take a look at the Comate library that
you can find in the Annoucement forum.
Windows 7 & PureBasic 4.4
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

Try the ScriptControl lib (author Thomas 'ts-soft' Schulz), you can find it here:

http://www.purearea.net/pb/english/index.htm

Its as easier as doing this:

Code: Select all

xDummy$ = (your vbs code here) 
SCtr_SetLanguage("VBScript")
SCtr_SetTimeOut(20000)
SCtr_AddCode(xDummy$)
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

The download is here: http://www.purearea.net/pb/download/use ... ontrol.zip
use the source or recompile the lib with tailbite!
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Post by chi »

again! nice lib ts... thx
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

You can also run vbscript in the webgadget. This is q quick HACK to test your code. You probably need to edit the script a bit. :wink:

Code: Select all


;-program notes
;-initialize
;-
enumeration
  #WIN
  #WEB
endEnumeration

global winW = 660, winH = 480, counter = -1

declare openMainWindow()
declare navigationCallback(id, url.s)
declare.s userInterfacePage1()

;-program entry
openMainWindow()

;-program event handler
repeat
  event = waitWindowEvent()
  select event
    case #PB_EVENT_SIZEWINDOW
       winW = windowWidth(#WIN)
       winH = windowHeight(#WIN)
       resizeGadget(#WEB, 0, 0, winW, winH)
    case #PB_EVENT_CLOSEWINDOW
      ;-program exit
      ;-
      end
  endSelect
forever

procedure openMainWindow()
  if openWindow(#WIN, 0, 0, winW, winH, "program template", $CF0001)
    webGadget(#WEB, 0, 0, winW, winH, "")
    ;load the html
    setGadgetItemText(#WEB, #PB_WEB_HTMLCODE, userInterfacePage1())
    ;callback to monitor navigation
    setGadgetAttribute(#WEB, #PB_WEB_NAVIGATIONCALLBACK, @navigationCallback())
  endIf
endProcedure

procedure navigationCallback(id, url.s)
  url = lcase(url)
  if findString(url, "???????", 1)
    ;handle event...

    ;block drag-drop
    procedureReturn 0
  endIf
  procedureReturn 1
endProcedure

procedure.s userInterfacePage1()
  ;html
	s.s + "<script language = 'vbscript'>" + chr(13)
	s + "// Title: System Information Script " + chr(13)
	s + "// Author: Bradley Buskey " + chr(13)
	s + "// Contact: deckyon@sturm.org " + chr(13)
	s + "// Date: October 30, 2006 " + chr(13)
	s + "// Updated: March 29, 2007 " + chr(13)
	s + "// Purpose: Quickly show basic system information for an entered workstation ID " + chr(13)
	s + "// Tested On: Currently verified to work on Windows XP and Windows Server 2003 " + chr(13)
	s + "//---------------------- " + chr(13)
	s + "" + chr(13)
	s + "On Error Resume Next " + chr(13)
	s + "Const HKEY_CURRENT_USER = &H80000001 " + chr(13)
	s + "Const HKEY_LOCAL_MACHINE = &H80000002 " + chr(13)
	s + "" + chr(13)
	s + "Dim strComputer, objWMIService, propValue, objItem " + chr(13)
	s + "Dim strUserName, strPassword, colItems, SWBemlocator " + chr(13)
	s + "" + chr(13)
	s + "// This section querries for the workstation to be scanned. " + chr(13)
	s + "strComputer = inputbox (" + chr(34) + "Workstation" + chr(34) + ", " + chr(34) + "Enter the workstation ID to scan." + chr(34) + "," + chr(34) + "." + chr(34) + ") " + chr(13)
	s + "UserName = " + chr(34) + "" + chr(34) + " " + chr(13)
	s + "Password = " + chr(34) + "" + chr(34) + " " + chr(13)
	s + "ImgDir = " + chr(34) + "C:\Scripts\images\" + chr(34) + " " + chr(13)
	s + "" + chr(13)
	s + "//Sets up the connections and opjects to be used throughout the script. " + chr(13)
	s + "Set SWBemlocator = CreateObject(" + chr(34) + "WbemScripting.SWbemLocator" + chr(34) + ") " + chr(13)
	s + "Set objWMIService = SWBemlocator.ConnectServer(strComputer," + chr(34) + "root\CIMV2" + chr(34) + ",strUserName,strPassword) " + chr(13)
	s + "" + chr(13)
	s + "//This determines the current date and time of the PC being scanned. " + chr(13)
	s + "Set colItems = objWMIService.ExecQuery(" + chr(34) + "SELECT * FROM Win32_LocalTime" + chr(34) + ", " + chr(34) + "WQL" + chr(34) + ", wbemFlagReturnImmediately + wbemFlagForwardOnly) " + chr(13)
	s + "For Each objItem in colItems " + chr(13)
	s + "    If objItem.Minute < 10 Then " + chr(13)
	s + "        theMinutes = " + chr(34) + "0" + chr(34) + " & objItem.Minute " + chr(13)
	s + "    Else " + chr(13)
	s + "        theMinutes = objItem.Minute " + chr(13)
	s + "    End If " + chr(13)
	s + "    If objItem.Second < 10 Then " + chr(13)
	s + "        theSeconds = " + chr(34) + "0" + chr(34) + " & objItem.Second " + chr(13)
	s + "    Else " + chr(13)
	s + "        theSeconds = objItem.Second " + chr(13)
	s + "    End If " + chr(13)
	s + "    DateTime = objItem.Month & " + chr(34) + "/" + chr(34) + " & objItem.Day & " + chr(34) + "/" + chr(34) + " & objItem.Year & " + chr(34) + " - " + chr(34) + " & objItem.Hour & " + chr(34) + ":" + chr(34) + " & theMinutes & " + chr(34) + ":" + chr(34) + " & theSeconds " + chr(13)
	s + "Next " + chr(13)
	s + "" + chr(13)
	s + "//Gets some ingomation about the Operating System including Service Pack level. " + chr(13)
	s + "Set colItems = objWMIService.ExecQuery(" + chr(34) + "Select * from Win32_OperatingSystem" + chr(34) + ",,48) " + chr(13)
	s + "For Each objItem in colItems " + chr(13)
	s + "    WKID = objItem.CSName " + chr(13)
	s + "    WKOS = objItem.Caption " + chr(13)
	s + "    ServicePack = objItem.ServicePackMajorVersion & " + chr(34) + "." + chr(34) + " & objItem.ServicePackMinorVersion " + chr(13)
	s + "Next " + chr(13)
	s + "" + chr(13)
	s + "//This section returns the Video card and current resolution. " + chr(13)
	s + "Set colItems = objWMIService.ExecQuery(" + chr(34) + "Select * from Win32_DisplayConfiguration" + chr(34) + ",,48) " + chr(13)
	s + "For Each objItem in colItems " + chr(13)
	s + "    VideoCard = objItem.DeviceName " + chr(13)
	s + "    Resolution = objItem.PelsWidth & " + chr(34) + " x " + chr(34) + " & objItem.PelsHeight & " + chr(34) + " x " + chr(34) + " & objItem.BitsPerPel & " + chr(34) + " bits" + chr(34) + " " + chr(13)
	s + "Next " + chr(13)
	s + "" + chr(13)
	s + "//This section returns the Video card memory. " + chr(13)
	s + "Set objWMIService = GetObject(" + chr(34) + "winmgmts:\\" + chr(34) + " & strComputer & " + chr(34) + "\root\cimv2" + chr(34) + ") " + chr(13)
	s + "Set colItems = objWMIService.ExecQuery (" + chr(34) + "Select * from Win32_VideoController" + chr(34) + ") " + chr(13)
	s + "For Each objItem in colItems " + chr(13)
	s + "    VideoMemory = objItem.AdapterRAM/1024/1024 " + chr(13)
	s + "Next " + chr(13)
	s + "" + chr(13)
	s + "//This returns various system information including current logged on user, domain, memory, manufacture and model. " + chr(13)
	s + "Set colItems = objWMIService.ExecQuery(" + chr(34) + "Select * from Win32_ComputerSystem" + chr(34) + ",,48) " + chr(13)
	s + "For Each objItem in colItems " + chr(13)
	s + "    UserName = objItem.UserName " + chr(13)
	s + "    Domain = objItem.Domain " + chr(13)
	s + "    TotalMemory = int((objItem.TotalPhysicalMemory/1024)/1024+1) " + chr(13)
	s + "    Manufacturer = objItem.Manufacturer " + chr(13)
	s + "    Model = objItem.Model " + chr(13)
	s + "Next " + chr(13)
	s + "" + chr(13)
	s + "//This determines the total hard drive space and free hard drive space. " + chr(13)
	s + "Set colItems = objWMIService.ExecQuery(" + chr(34) + "Select * from Win32_LogicalDisk Where Name='C:'" + chr(34) + ",,48) " + chr(13)
	s + "For Each objItem in colItems " + chr(13)
	s + "    FreeHDSpace = Fix(((objItem.FreeSpace/1024)/1024)/1024) " + chr(13)
	s + "    TotalHDSpace = Fix(((objItem.Size/1024)/1024)/1024) " + chr(13)
	s + "Next " + chr(13)
	s + "" + chr(13)
	s + "//This section returns the default printer and printer port. " + chr(13)
	s + "Set colItems = objWMIService.ExecQuery(" + chr(34) + "SELECT * FROM Win32_Printer where Default=True" + chr(34) + ", " + chr(34) + "WQL" + chr(34) + ", wbemFlagReturnImmediately + wbemFlagForwardOnly) " + chr(13)
	s + "For Each objItem in colItems " + chr(13)
	s + "    Printer = objItem.Name " + chr(13)
	s + "    PortName = objItem.PortName " + chr(13)
	s + "Next " + chr(13)
	s + "" + chr(13)
	s + "//This returns the CPU information. " + chr(13)
	s + "Set colItems = objWMIService.ExecQuery(" + chr(34) + "SELECT * FROM Win32_Processor" + chr(34) + ", " + chr(34) + "WQL" + chr(34) + ", wbemFlagReturnImmediately + wbemFlagForwardOnly) " + chr(13)
	s + "For Each objItem in colItems " + chr(13)
	s + "    CPUDesc = LTrim(objItem.Name) " + chr(13)
	s + "Next " + chr(13)
	s + "" + chr(13)
	s + "//This returns the current uptime (time since last reboot) of the system. " + chr(13)
	s + "Set colOperatingSystems = objWMIService.ExecQuery (" + chr(34) + "Select * from Win32_OperatingSystem" + chr(34) + ") " + chr(13)
	s + "For Each objOS in colOperatingSystems " + chr(13)
	s + "    dtmBootup = objOS.LastBootUpTime " + chr(13)
	s + "    dtmLastBootupTime = WMIDateStringToDate(dtmBootup) " + chr(13)
	s + "    dtmSystemUptime = DateDiff(" + chr(34) + "h" + chr(34) + ", dtmLastBootUpTime, Now) " + chr(13)
	s + "    Uptime = dtmSystemUptime " + chr(13)
	s + "Next " + chr(13)
	s + "Function WMIDateStringToDate(dtmBootup) " + chr(13)
	s + "    WMIDateStringToDate = CDate(Mid(dtmBootup, 5, 2) & " + chr(34) + "/" + chr(34) + " & Mid(dtmBootup, 7, 2) & " + chr(34) + "/" + chr(34) + " & Left(dtmBootup, 4) & " + chr(34) + " " + chr(34) + " & Mid (dtmBootup, 9, 2) & " + chr(34) + ":" + chr(34) + " & Mid(dtmBootup, 11, 2) & " + chr(34) + ":" + chr(34) + " & Mid(dtmBootup,13, 2)) " + chr(13)
	s + "End Function " + chr(13)
	s + "" + chr(13)
	s + "//This sets up the Internet Explorer window in order to show the results. " + chr(13)
	s + "Set objExplorer = WScript.CreateObject(" + chr(34) + "InternetExplorer.Application" + chr(34) + ", " + chr(34) + "IE_" + chr(34) + ") " + chr(13)
	s + "With objExplorer " + chr(13)
	s + "    .Navigate " + chr(34) + "about:Blank" + chr(34) + " " + chr(13)
	s + "    .Toolbar = 0 " + chr(13)
	s + "    .StatusBar = 0 " + chr(13)
	s + "    .Width = 800 " + chr(13)
	s + "    .Height = 600 " + chr(13)
	s + "    .Left = 75 " + chr(13)
	s + "    .Top = 0 " + chr(13)
	s + "    .Visible = 1 " + chr(13)
	s + "End With " + chr(13)
	s + "Set fileOutput = objExplorer.Document " + chr(13)
	s + "" + chr(13)
	s + "//This is the code for the web page to be displayed. " + chr(13)
	s + "fileOutput.Open " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "<html>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "    <head>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "        <title>System Information for '" + chr(34) + " & WKID & " + chr(34) + "// </title>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "    </head>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "    <body bgcolor='#FFFFFF' text='#000000' link='#0000FF' vlink='000099' alink='#00FF00'>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "        <center>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "            <h3>Workstaion/Server Information for " + chr(34) + " & WKID & " + chr(34) + "</h3>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "            <table border='0' cellspacing='1' cellpadding='1' width='95%'>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                <tr><td background='" + chr(34) + " & ImgDir & " + chr(34) + "blue_spacer.gif'>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                    <table border='0' cellspacing='0' cellpadding='0' width='100%'>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                        <tr><td>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                            <table border='0' cellspacing='0' cellpadding='0' width='100%'>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                <tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                    <td width='5%' align='left' valign='middle' background='" + chr(34) + " & ImgDir & " + chr(34) + "blue_spacer.gif'><img src='" + chr(34) + " & ImgDir & " + chr(34) + "write.gif'></td>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                    <td width='95%' align='left' valign='middle' background='" + chr(34) + " & ImgDir & " + chr(34) + "blue_spacer.gif'> <font color='#FFFFFF' size='5'>WKInfo - </font><font color='#FFFFFF' size='3'>General information on the Workstation.</font></td>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                </tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                <tr><td colspan='2' bgcolor='#FFFFFF'>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                    <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Last Scanned</i></b></TD></TR>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Date/Time</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & DateTime & " + chr(34) + "</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>System Uptime</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & Uptime & " + chr(34) + " hours</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Information</i></b></TD></TR>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Workstation ID</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & WKID & " + chr(34) + "</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Domain</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & Domain & " + chr(34) + "</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>UserName</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & UserName & " + chr(34) + "</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General OS Information</i></b></TD></TR>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Operating System</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & WKOS & " + chr(34) + "</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Service Pack</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & ServicePack & " + chr(34) + "</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Computer Information</i></b></TD></TR>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Manufacturer</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & Manufacturer & " + chr(34) + "</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Model</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & Model & " + chr(34) + "</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Hardware Information</i></b></TD></TR>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>CPU</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & CPUDesc & " + chr(34) + "</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Memory</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & TotalMemory & " + chr(34) + " MB</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Total HD Space</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & TotalHDSpace & " + chr(34) + " GB</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Free HD Space</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & FreeHDSpace & " + chr(34) + " GB</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Video Card Information</i></b></TD></TR>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Video Card</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & VideoCard & " + chr(34) + "</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Resolution</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & Resolution & " + chr(34) + "</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Memory</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & VideoMemory & " + chr(34) + " MB</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Default Printer Information</i></b></TD></TR>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Printer</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & Printer & " + chr(34) + "</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Port Name</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & PortName & " + chr(34) + "</i></td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Shared Directories</i></b></TD></TR>" + chr(34) + " " + chr(13)
	s + "//This sextion lists all the current shares enabled on the PC. " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                                <TR><TD width='30%' align='center' bgcolor='#e0e0e0'><b>Name</b></td><TD width='40%' align='center' bgcolor='#e0e0e0'><b>Path</b><TD width='40%' align='center' bgcolor='#e0e0e0'><b>Description</b></td><tr>" + chr(34) + " " + chr(13)
	s + "Set colShares = objWMIService.ExecQuery(" + chr(34) + "Select * from Win32_Share" + chr(34) + ") " + chr(13)
	s + "For each objShare in colShares " + chr(13)
	s + "    fileOutput.WriteLn " + chr(34) + "                                                <TR><TD width='30%' align='left' bgcolor='#f0f0f0'><i>" + chr(34) + " & objShare.Name & " + chr(34) + "</i></TD><td bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & objShare.Path & " + chr(34) + "</i></TD><td bgcolor=#f0f0f0 align=left><i>" + chr(34) + " & objShare.Caption & " + chr(34) + "</i></td></tr>" + chr(34) + " " + chr(13)
	s + "Next " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                            </table>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        </td></tr>" + chr(34) + " " + chr(13)
	s + "//This section lists all the current services and their status. " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Current Service Information</i></b></TD></TR>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                                <TR><TD width='70%' align='center' bgcolor='#e0e0e0'><b>Service Name</b></td><TD width='30%' align='center' bgcolor='#e0e0e0'><b>Service State</b></td><tr>" + chr(34) + " " + chr(13)
	s + "Set colRunningServices = objWMIService.ExecQuery(" + chr(34) + "Select * from Win32_Service" + chr(34) + ") " + chr(13)
	s + "For Each objService in colRunningServices " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                            <TR><TD align='left' bgcolor='#f0f0f0'>" + chr(34) + " & objService.DisplayName & " + chr(34) + "</TD><td bgcolor=#f0f0f0 align=center><i>" + chr(34) + " & objService.State & " + chr(34) + "</i></td></tr>" + chr(34) + " " + chr(13)
	s + "Next " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                            </table>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        </td></tr>" + chr(34) + " " + chr(13)
	s + "//This section lists all the current running processes and some information. " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Current Process Information</i></b></TD></TR>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                                <TR><TD width='10%' align='center' bgcolor='#e0e0e0'><b>PID</b></td><TD width='35%' align='center' bgcolor='#e0e0e0'><b>Process Name</b></td><TD width='40%' align='center' bgcolor='#e0e0e0'><b>Owner</b></td><TD width='15%' align='center' bgcolor='#e0e0e0'><b>Memory</b></td></tr>" + chr(34) + " " + chr(13)
	s + "Set colProcessList = objWMIService.ExecQuery(" + chr(34) + "Select * from Win32_Process" + chr(34) + ") " + chr(13)
	s + "For Each objProcess in colProcessList " + chr(13)
	s + "colProperties = objProcess.GetOwner(strNameOfUser,strUserDomain) " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                                <TR><TD align='center' bgcolor='#f0f0f0'>" + chr(34) + " & objProcess.Handle & " + chr(34) + "</td><TD align='center' bgcolor='#f0f0f0'>" + chr(34) + " & objProcess.Name & " + chr(34) + "</td><TD align='center' bgcolor='#f0f0f0'>" + chr(34) + " & strUserDomain & " + chr(34) + "\" + chr(34) + " & strNameOfUser & " + chr(34) + "</td><TD align='center' bgcolor='#f0f0f0'>" + chr(34) + " & objProcess.WorkingSetSize/1024 & " + chr(34) + " kb</td><tr>" + chr(34) + " " + chr(13)
	s + "Next " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                            </table>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        </td></tr>" + chr(34) + " " + chr(13)
	s + "//This section lists all the currently installed software on the machine. " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Installed Software</i></b></TD></TR>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>" + chr(34) + " " + chr(13)
	s + "Set colSoftware = objWMIService.ExecQuery (" + chr(34) + "Select * from Win32_Product" + chr(34) + ") " + chr(13)
	s + "For Each objSoftware in colSoftware " + chr(13)
	s + "    fileOutput.WriteLn" + chr(34) + "                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>" + chr(34) + " " + chr(13)
	s + "    fileOutput.WriteLn" + chr(34) + "                                                <tr><td align=left bgcolor='#e0e0e0'><b>Caption:</b></td><td colspan=2 bgcolor=#f0f0f0>" + chr(34) + " & objSoftware.Caption & " + chr(34) + "</td></tr>" + chr(34) + " " + chr(13)
	s + "    fileOutput.WriteLn" + chr(34) + "                                                <tr><td align=left bgcolor='#e0e0e0'><b>Install Location:</b></td><td colspan=2 bgcolor=#f0f0f0>" + chr(34) + " & objSoftware.InstallLocation & " + chr(34) + "</td></tr>" + chr(34) + " " + chr(13)
	s + "    fileOutput.WriteLn" + chr(34) + "                                                <tr><td width=30% align=center bgcolor='#e0e0e0'><b>Name</b></td><td width=30% align=center bgcolor='#e0e0e0'><b>Vendor</b></td><td width=30% align=center bgcolor='#e0e0e0'><b>Version</b></td></tr>" + chr(34) + " " + chr(13)
	s + "    fileOutput.WriteLn" + chr(34) + "                                                <tr><td align=center bgcolor=#f0f0f0>" + chr(34) + " & objSoftware.Name & " + chr(34) + "</td><td align=center bgcolor=#f0f0f0>" + chr(34) + " & objSoftware.Vendor & " + chr(34) + "</td><td align=center bgcolor=#f0f0f0>" + chr(34) + " & objSoftware.Version & " + chr(34) + "</td></tr>" + chr(34) + " " + chr(13)
	s + "    fileOutput.WriteLn" + chr(34) + "                                                <tr height=2><td height=10 align=center bgcolor=midnightblue colspan=3></td></tr>" + chr(34) + " " + chr(13)
	s + "    fileOutput.WriteLn" + chr(34) + "                                            </table>" + chr(34) + " " + chr(13)
	s + "Next " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                        </td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                    </table>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                                </td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                            </table>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                        </td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                    </table>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "                </td></tr>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "            </table>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "            <p><small>© 2005-2007, Bradley Buskey</small></p>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "        </center>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "    </body>" + chr(34) + " " + chr(13)
	s + "fileOutput.WriteLn " + chr(34) + "<html>" + chr(34) + " " + chr(13)
	s + "fileOutput.close " + chr(13)
	s + "WScript.Quit" + chr(13)
	s + "</script>"
  procedureReturn s
endProcedure
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

The download is here: http://www.purearea.net/pb/download/use ... ontrol.zip
use the source or recompile the lib with tailbite!
Hello TsSoft.
Is it possible to use your source in includefile with the test or i must use the lib ??? :roll:
Because in include i have an error, i assume it's normal :oops:
ImageThe happiness is a road...
Not a destination
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Kwaï chang caïne wrote: Is it possible to use your source in includefile with the test or i must use the lib ??? :roll:
Because in include i have an error, i assume it's normal :oops:

Code: Select all

XIncludeFile "ScriptControl.pb" ; <-----
; some of testcode stolen from kiffi ;)

Procedure.s GetHtmlTitleVbs(URL$)

  Dummy$ = "Set myIE= CreateObject(" + Chr(34) + "InternetExplorer.Application" + Chr(34) + ")" + #CRLF$
  Dummy$ + "Do While myIE.Busy" + #CRLF$
  Dummy$ + "Loop" + #CRLF$
  Dummy$ + "myIE.Visible = 0" + #CRLF$
  Dummy$ + "myIE.Navigate " + Chr(34) + URL$ + Chr(34) + #CRLF$
  Dummy$ + "Do While myIE.ReadyState <> 4" + #CRLF$
  Dummy$ + "Loop" + #CRLF$
  Dummy$ + "Set oDoc = myIE.Document" + #CRLF$
  Dummy$ + "myTitle = oDoc.title" + #CRLF$
  Dummy$ + "Set oDoc = Nothing" + #CRLF$
  Dummy$ + "Set myIE = Nothing" + #CRLF$

  ProcedureReturn Dummy$

EndProcedure

ScriptControl_Init() ; < -----

SCtr_SetLanguage("VBScript")
SCtr_SetTimeOut(20000)
SCtr_AddCode(GetHtmlTitleVbs("http://www.purebasic.com"))
myTitle.s = SCtr_EvalStr("myTitle")
If myTitle
  MessageRequester("HTML-Title", myTitle)
EndIf

ScriptControl_End() ; <-----
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

Or...if you were using srods COMate, you could also do it sort of like this:

Code: Select all

XIncludeFile "COMate.pbi"
XIncludeFile "Utility.pbi"
XIncludeFile "VariantHelper_Include.pb"

Procedure.s UTCDateToDateString(UTCdate.s, UTC_true_false.i) 
;parse UTC time string YYYYMMDDHHMMSS.xxxxxx-xxx 
Year$ = Left(UTCdate, 4) 
Month$ = Mid(UTCdate, 5, 2) 
Day$ = Mid(UTCdate, 7, 2) 
Hour$ = Mid(UTCdate, 9, 2) 
Minute$ = Mid(UTCdate, 11, 2) 
Second$ = Mid(UTCdate,13, 2) 
;convert numeric month To text month To handle regional datetime display formats 

  Select Month$
    Case "01"
      MonthNames$ = "January"
    Case "02" 
      MonthNames$ = "February"
    Case "03" 
      MonthNames$ = "March"
    Case "04"
      MonthNames$ = "April"
    Case "05" 
      MonthNames$ = "May"
    Case "06" 
      MonthNames$ = "June"
    Case "07"
      MonthNames$ = "July"
    Case "08"
      MonthNames$ = "August"
    Case "09"
      MonthNames$ = "September"
    Case "10"
      MonthNames$ = "October"
    Case "11"
      MonthNames$ = "November"
    Case "12"
      MonthNames$ = "December"
  EndSelect
  UTC_Offsetx.i = Val(Mid(UTCdate, 23))
  UTC_Offsety.i = UTC_Offsetx / 60
    
  If Mid(UTCdate, 22,1) = "-"
  UTC_Offset$ = "- " + Str(UTC_Offsety) + " Hrs"
  EndIf
  
  If Mid(UTCdate, 22,1) = "+"
  UTC_Offset$ = "+ " + Str(UTC_Offsety) + " Hrs"
  EndIf
;generate date string

If UTC_true_false = 0
Date_Out$ = MonthNames$ + "  " + Day$ + ", " + Year$ + "    " + Hour$ + ":" + Minute$ + ":" + Second$
EndIf
If UTC_true_false = 1
Date_Out$ = MonthNames$ + "  " + Day$ + ", " + Year$ + "    " + Hour$ + ":" + Minute$ + ":" + Second$ + "  UTC Offset  : " + UTC_Offset$
EndIf
;return date string 
ProcedureReturn Date_Out$
  
EndProcedure

Procedure.i Ini_Write(INIFile.s,Section.s,Key.s,string.s)
  result.i=WritePrivateProfileString_(@Section,@Key,@string,@INIFile)
  If result<>0 : result=1 : EndIf
  ProcedureReturn result
EndProcedure

Procedure.s GetDEP() 
  
  Lib = OpenLibrary(#PB_Any, "kernel32.dll")
  
  If Lib 
    
    *Mem_Func = GetFunction(Lib, "GetSystemDEPPolicy") 
    If *Mem_Func 
    Result_DEP = CallFunctionFast(*Mem_Func) 
    EndIf
    
    Select Result_DEP
      Case 0
      DEP_Pol$ = "Always Off"
      Case 1
      DEP_Pol$ = "Always On"
      Case 2
      DEP_Pol$ = "Opt In"
      Case 3
      DEP_Pol$ = "Opt Out"
      Default
      DEP_Pol$ = "DEP Policy Unknown"
    EndSelect
    
    CloseLibrary(Lib) 
    
  EndIf 
  
  ProcedureReturn DEP_Pol$ 
  
EndProcedure

Procedure.s OS_Version()

Define.COMateObject objWMIService, Version
colOS.COMateEnumObject
strComputer.s = "." 

objWMIService = COMate_GetObject("winmgmts:\\" + strComputer + "\root\cimv2", "") 
If objWMIService 
  colOS = objWMIService\CreateEnumeration("ExecQuery('Select * from Win32_OperatingSystem')")
  Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "==================================", " [Operating_System_Info] ==============================================")
  If colOS 
    Version = colOS\GetNextObject() 
    While Version
      
      OS_Build$ = Version\GetStringProperty("BuildNumber")
      OS_BuildType$ = Version\GetStringProperty("BuildType")
      OS_SP_MajorVersion_Global$ = Str(Version\GetIntegerProperty("ServicePackMajorVersion"))
      OS_SP_MinorVersion$ = Str(Version\GetIntegerProperty("ServicePackMinorVersion"))
      OS_CSD_Version$ = Version\GetStringProperty("CSDVersion")
      OS_BootDevice$ = Version\GetStringProperty("BootDevice")
      ; **********time UTC in hours************
      time_z.l = Val(Mid(Version\GetStringProperty("CurrentTimeZone"), 2))
      
        If Left(Version\GetStringProperty("CurrentTimeZone"), 1) = "-"
          OS_CurrentTimeZone$ = "- " + Str(time_z / 60) + " Hrs"
        EndIf
  
        If Left(Version\GetStringProperty("CurrentTimeZone"), 1) = "+"
          OS_CurrentTimeZone$ = "+ " + Str(time_z / 60) + " Hrs"
        EndIf
      ;****************************************
      OS_EncryptionLevel$ = Str(Version\GetIntegerProperty("EncryptionLevel"))
      OS_InstallDate$ = UTCDateToDateString(Version\GetStringProperty("InstallDate"), 0)
      OS_LocalDateTime$ = UTCDateToDateString(Version\GetStringProperty("LocalDateTime"), 1)
      File_Gen_date_time$ = UTCDateToDateString(Version\GetStringProperty("LocalDateTime"), 0)
      OS_Language$ = OS_Languages(Version\GetIntegerProperty("OSLanguage"))
      OS_SerialNumber$ = Version\GetStringProperty("SerialNumber")
      OS_SystemDevice$ = Version\GetStringProperty("SystemDevice")
      OS_SystemDrive$ = Version\GetStringProperty("SystemDrive")
      OS_WindowsDirectory$ = Version\GetStringProperty("WindowsDirectory")
      OS_SystemDirectory$ = Version\GetStringProperty("SystemDirectory")
      OS_Version$ = Version\GetStringProperty("Version")
      OS_Caption_Global$ = Version\GetStringProperty("Caption")
      OS_CodeSet$ = Version\GetStringProperty("CodeSet")
      OS_CountryCode$ = Version\GetStringProperty("CountryCode")
      Ox_Debug.i = Version\GetIntegerProperty("Debug")
        If Ox_Debug = #True 
            OS_Debug$ = "Checked Build"
          Else
            OS_Debug$ = "Not Checked Build"
        EndIf
        If Left(OS_Version$,1) = "6"
          OS_VersionName$ = OS_SKU(Version\GetIntegerProperty("OperatingSystemSKU"))
        EndIf
      
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS Version", "  " + OS_Caption_Global$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS SKU", "  " + OS_VersionName$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS Build", "  " + OS_Build$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS Build Type", "  " + OS_BuildType$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS Debug", "  " + OS_Debug$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS Service Pack Major Version", "  " + OS_SP_MajorVersion_Global$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS Service Pack Minor Version", "  " + OS_SP_MinorVersion$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS Service Pack Version", "  " + OS_CSD_Version$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS Install Date", "  " + OS_InstallDate$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS UTC Offset from Local Time", "  " + OS_CurrentTimeZone$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS Local Date and Time", "  " + OS_LocalDateTime$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS System Device", "  " + OS_SystemDevice$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS Boot Device", "  " + OS_BootDevice$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS System Drive", "  " + OS_SystemDrive$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS Windows Directory", "  " + OS_WindowsDirectory$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS System Directory", "  " + OS_SystemDirectory$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS Language", "  " + OS_Language$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS Country Code", "  " + OS_CountryCode$)
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS Code Set", "  " + OS_CodeSet$)
      
        If (CPU_AddressWidth_Global$ = "32") And (FindString(OS_Caption_Global$, "XP", 1) > 0) And (OS_SP_MajorVersion_Global$ => "3")
          Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS DEP Policy", "  " + GetDEP())
        EndIf
        If (CPU_AddressWidth_Global$ = "32") And (FindString(OS_Caption_Global$, "Vista", 1) > 0) And (OS_SP_MajorVersion_Global$ => "1")
          Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS DEP Policy", "  " + GetDEP())
        EndIf
      
      Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "OS Encryption Level", "  " + OS_EncryptionLevel$)

      Version\Release() 
      Version = colOS\GetNextObject()
    Wend
    colOS\Release() 
  EndIf
  objWMIService\Release()
  Else
      MessageRequester("Error", "OSInfo")  
EndIf
Ini_Write("C:\Comp_Info.txt","Operating_System_Info", "============", "End [Operating_System_Info] ============" + #CRLF$)
EndProcedure
I think I included everything in the above just for the operating system alone, but if the utility.pbi is needed, (the OS_Languages is in the utility.pbi) I posted it already in this thread > http://www.purebasic.fr/english/viewtopic.php?t=36492 along with just about everything you could ever want to know about your computer system. The graphics card and everything else is in that other thread.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

That's works fine :D
Thanks a lot TsSoft for your quick and good answer 8)
ImageThe happiness is a road...
Not a destination
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Re:

Post by NoahPhense »

Ok, I have the ScriptControl installed/compiled via TailBite .. works great.

I'm looking over the examples. But I'm still not clear on how to let it start the execution of a vbs. I have a vbs and would like to embed it, like such (in one of the examples).

Code: Select all

DataSection
  userdomain_mssc:
  IncludeBinary "UserDomain.vbs"
  ;IncludeBinary "UserDomain.js"
  Data.b 0
EndDataSection

Procedure Domain()
  SCtr_SetLanguage("VBScript")
  SCtr_AddCode(PeekS(?userdomain_mssc))
  Domain.s = SCtr_EvalStr("Domain")
  If Not Domain
    Debug "Error"
  Else
    Debug Domain
  EndIf
EndProcedure

Domain()
All I need/want to do is, includebinary, then I would like to execute it.

- np
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: How to embed VBS in PB App

Post by srod »

(Updated to include some error trapping.)

Here is an example using COMatePLUS (for those who like to use late-binding) :

Code: Select all

;/////////////////////////////////////////////////////////////////////////////////
;***COMate***  COM automation through iDispatch.
;*===========
;*
;Script control demo.
;*
;*Note that whilst we include error trapping you can instead use an event-handler to catch all errors etc.
;/////////////////////////////////////////////////////////////////////////////////


IncludePath "..\"
XIncludeFile "COMatePLUS.pbi"

code$ = "a = 10" + #CRLF$
code$ + "b = 20" + #CRLF$
code$ + "result = a + b"

Define.COMateObject scriptObject, errorObject
scriptObject = COMate_CreateObject("MSScriptControl.ScriptControl.1") 
If scriptObject
  scriptObject\SetProperty("Language = 'VBScript'")
  If scriptObject\Invoke("AddCode('" + code$ + "')") = #S_OK
    result = scriptObject\GetIntegerProperty("Eval('result')")
    MessageRequester("Script demo", Chr(34) + code$ + Chr(34) + #LF$ + #LF$ + "Produced a result of : " + Str(result))
  Else
    errorObject = scriptObject\GetObjectProperty("Error")
    If errorObject  
      MessageRequester("Script demo - error reported!", Chr(34) + errorObject\GetStringProperty("Text") + Chr(34) + #LF$ + " produced the following error : " + #LF$ + #LF$ + errorObject\GetStringProperty("Description"))
      errorObject\Release()
    EndIf
  EndIf
  scriptObject\Release()
Else
  MessageRequester("COMate - Scripting demo", "Couldn't create the scripting object!")
EndIf
Last edited by srod on Thu May 13, 2010 1:01 pm, edited 3 times in total.
I may look like a mule, but I'm not a complete ass.
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Re: How to embed VBS in PB App

Post by NoahPhense »

Thanks srod, where do I get the latest version of the ComMatePlus?

- np
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: How to embed VBS in PB App

Post by srod »

NoahPhense wrote:Thanks srod, where do I get the latest version of the ComMatePlus?

- np
Hi,

I have just updated the code to include some error trapping. You can trap errors (e.g. syntax errors) either individually or using a #COMate_CatchAllEvents event handler.

See the nxSoftware site for the latest versions of COMatePLUS etc.
I may look like a mule, but I'm not a complete ass.
Post Reply