Circular menu

I have been looking for a way to create a circular menu for a site and found http://jsfiddle.net/xSajL/471/embedded/result/ which I have been fiddling with and now come up with http://jsfiddle.net/xSajL/501/embedded/result/ what do you think?

No idea who came up with the original idea all I have done is allow for text along the arc of each slice and provided an array to hold the slice information.

Automate RunAs Password Entry

Have you ever wanted to use the RunAs command to run an application under a specified account? I have and found it a bit annoying that it was a bit annoying not being able to specify the password.

Thankfully someone created the following script ()

Happy days!

How to add more processors to a Hyper-V guest OS

Ever wondered how to add more processors to a Hyper-V guest OS above the 4 processor limit in the settings?

Thank fully it is as easy as editing the configuration file for the VM.

http://www.youtube.com/watch?v=NQCMT-O6bMM

Set IBM Client Access DSN to Read Only

In a previous post I looked at recording the driver version of the ODBC driver used by the IBM client.

Since then I have expanded this a bit to log the ODBC driver version, the file version of the Client Access driver and check any DSNs and make them read only.

Here is the code to setup the database tables, views and stored procedures:

CREATE TABLE [dbo].[ODBC_Log](
	[MachineName] [varchar](20) NOT NULL,
	[Driver] [varchar](50) NOT NULL,
	[DriverVersion] [decimal](10, 5) NULL,
	[Logged] [datetime] NOT NULL,
	[FileVersion] [varchar](50) NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ODBC_Log] ADD  CONSTRAINT [DF_ODBC_Log_Logged]  DEFAULT (getdate()) FOR [Logged]
GO

CREATE TABLE [dbo].[DSN_Log](
	[MachineName] [varchar](20) NOT NULL,
	[DSNName] [varchar](50) NOT NULL,
	[DSNDriver] [varchar](50) NOT NULL,
	[DSNReadOnly] [bit] NOT NULL,
	[Logged] [datetime] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DSN_Log] ADD  CONSTRAINT [DF_DSN_Log_Logged]  DEFAULT (getdate()) FOR [Logged]
GO

Create View [dbo].[vw_OutDatedDrivers]
AS
SELECT 
	[MachineName]
	,[Driver]
	,[DriverVersion]
	,[Logged]
	,[FileVersion]
FROM 
	[dbo].[ODBC_Log]
where   
	(
		Driver = 'C:\Windows\System32\cwbodbc.dll' AND 
		(
			FileVersion <> '11.64.0.0' AND 
			FileVersion <> '11.0.0.0' AND 
			FileVersion <> ''
		)
	)
OR
	(
		Driver = 'C:\Windows\SysWOW64\cwbodbc.dll' AND 
		(
			FileVersion <> '11.0.0.0' AND 
			FileVersion <> ''
		)
	)
OR
	(
		(
			Driver <> 'C:\Windows\SysWOW64\cwbodbc.dll' AND 
			Driver <> 'C:\Windows\System32\cwbodbc.dll'
		) AND
		(
			DriverVersion > 0 AND 
			DriverVersion <> 3.51
		)
	)
GO

Create View [dbo].[vw_Current_ODBC_Driver]
AS
Select 
	MachineName, 
	Driver, 
	DriverVersion, 
	FileVersion,
	Logged
From (
	Select 
		MachineName, 
		Driver, 
		DriverVersion, 
		FileVersion,
		Logged, 
		RANK()Over(PARTITION BY MachineName, Driver ORDER BY Logged DESC) [Rank]
	From 
		dbo.ODBC_Log
) Results
Where [Rank] = 1
GO

Create View [dbo].[vw_Current_DSN]
AS
Select 
	MachineName, 
	DSNName, 
	DSNDriver, 
	DSNReadOnly,
	Logged
From (
	Select 
		MachineName, 
		DSNName, 
		DSNDriver, 
		DSNReadOnly,
		Logged, 
		RANK()Over(PARTITION BY MachineName, DSNName, DSNDriver ORDER BY Logged DESC) [Rank]
	From 
		dbo.DSN_Log
) Results
Where [Rank] = 1
GO

Create View [dbo].[vw_OutOfDate_ODBC_Driver]
AS
SELECT [MachineName]
      ,[Driver]
      ,[DriverVersion]
      ,[Logged]
  FROM [UserManagement].[dbo].[vw_Current_ODBC_Driver]
  Where DriverVersion between 0.001 and 3.5
GO

CREATE PROCEDURE [dbo].[p_ODBC_Log]
	@MachineName varchar(20), 
	@Driver varchar(50), 
	@DriverVersion decimal(10,5)
AS
BEGIN
	SET NOCOUNT ON;
	
	If Not Exists(Select * From vw_Current_ODBC_Driver Where MachineName = @MachineName And Driver = @Driver And DriverVersion = @DriverVersion)
	Begin
		INSERT INTO dbo.ODBC_Log(MachineName, Driver, DriverVersion)
		VALUES(@MachineName, @Driver, @DriverVersion)
	End

END
GO

CREATE PROCEDURE [dbo].[p_ODBC_FileLog]
	@MachineName varchar(20), 
	@Driver varchar(50), 
	@FileVersion varchar(50)
AS
BEGIN
	SET NOCOUNT ON;
	
	If Not Exists(Select * From vw_Current_ODBC_Driver Where MachineName = @MachineName And Driver = @Driver And FileVersion = @FileVersion)
	Begin
		INSERT INTO dbo.ODBC_Log(MachineName, Driver, FileVersion)
		VALUES(@MachineName, @Driver, @FileVersion)
	End

END
GO

CREATE PROCEDURE [dbo].[p_DSN_Log]
	@MachineName varchar(20), 
	@DSNName varchar(50), 
	@DSNDriver varchar(50), 
	@DSNReadOnly bit 
AS
BEGIN
	SET NOCOUNT ON;
	
	If Not Exists(Select * From vw_Current_DSN Where MachineName = @MachineName And DSNName = @DSNName And DSNDriver = @DSNDriver)
	Begin
		INSERT INTO dbo.DSN_Log(MachineName, DSNName, DSNDriver, DSNReadOnly)
		VALUES(@MachineName, @DSNName, @DSNDriver, @DSNReadOnly)
	End
	else
	Begin
		Update dbo.DSN_Log
		Set 
			DSNReadOnly = @DSNReadOnly, 
			Logged = GETDATE()
		Where MachineName = @MachineName 
		And DSNName = @DSNName 
		And DSNDriver = @DSNDriver
	End

END
GO

Here is the script:

Const HKEY_CURRENT_USER  = &H80000001
Const HKEY_LOCAL_MACHINE  = &H80000002

Const adDouble = 5 'http://www.w3schools.com/ado/met_comm_createparameter.asp
Const adVarChar = 200
Const adParamInput = 1
Const adBoolean = 11
Const ExpectedODBCVersionID = 3.51 'ODBC Version
Const Expected32BitVersion = "11.0.0.0" 'Equivilent to IBM Client Access V5R4 
Const Expected64BitVersion = "11.64.0.0" 'Equivilent to IBM Client Access V5R4 
Const strComputer = "." 'Local Machine
Const strConn = "Provider=sqloledb;packet size=4096;user id=[USERNAME];data source=[SQLSERVER]\[INSTANCE];persist security info=False;initial catalog=UserManagement;password=[PASSWORD]" 'Database connection

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 'WMI service for local machine

Set colComputers = objWMIService.ExecQuery("Select * from Win32_ComputerSystem") 'List of machine names for current machine
For Each objComputer in colComputers
	strMachineName = objComputer.Name
Next

Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") 'Registry for current machine

oReg.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\ODBC\ODBCINST.INI\Client Access ODBC Driver", "DriverODBCVer", dwValue_Client86 '32bit Client Access driver
oReg.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\ODBC\ODBCINST.INI\Client Access ODBC Driver (32-bit)", "DriverODBCVer", dwValue_Client '64bit Client Access driver
oReg.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\ODBC\ODBCINST.INI\iSeries Access ODBC Driver", "DriverODBCVer", dwValue_iSeries 'iSeries Access driver

oReg.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Wow6432Node\ODBC\ODBC.INI\Client Access ODBC Driver", "DriverODBCVer", dwValue_Client86_64 '32bit Client Access driver
oReg.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Wow6432Node\ODBC\ODBC.INI\Client Access ODBC Driver (32-bit)", "DriverODBCVer", dwValue_Client_64 '64bit Client Access driver
oReg.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Wow6432Node\ODBC\ODBC.INI\iSeries Access ODBC Driver", "DriverODBCVer", dwValue_iSeries_64 'iSeries Access driver

'Converts string values to Double for comparison and logging
ConvertToDouble dwValue_Client86
ConvertToDouble dwValue_Client
ConvertToDouble dwValue_iSeries

ConvertToDouble dwValue_Client86_64
ConvertToDouble dwValue_Client_64
ConvertToDouble dwValue_iSeries_64

'Inserts values into Database
InsertLog strMachineName, "Client Access ODBC Driver", dwValue_Client86
InsertLog strMachineName, "Client Access ODBC Driver (32-bit)", dwValue_Client
InsertLog strMachineName, "iSeries Access ODBC Driver", dwValue_iSeries

InsertLog strMachineName, "Client Access ODBC Driver - 64bit", dwValue_Client86_64
InsertLog strMachineName, "Client Access ODBC Driver (32-bit) - 64bit", dwValue_Client_64
InsertLog strMachineName, "iSeries Access ODBC Driver - 64bit", dwValue_iSeries_64

'Gets driver file version if ODBC driver exists
If dwValue_Client86 > 0 or dwValue_iSeries > 0 Then
	dwValue_System32 = GetVersion("C:\Windows\System32\cwbodbc.dll")
	InsertFileLog strMachineName, "C:\Windows\System32\cwbodbc.dll", dwValue_System32
End If
If dwValue_Client > 0 Then
	dwValue_SysWOW64 = GetVersion("C:\Windows\SysWOW64\cwbodbc.dll")
	InsertFileLog strMachineName, "C:\Windows\SysWOW64\cwbodbc.dll", dwValue_SysWOW64
End If

On Error Resume Next

'Gets a list of DSNs in the registry of the current user
CHECKDSN HKEY_LOCAL_MACHINE, "SOFTWARE\ODBC\ODBC.INI\"
CHECKDSN HKEY_CURRENT_USER, "SOFTWARE\ODBC\ODBC.INI\"
CHECKDSN HKEY_LOCAL_MACHINE, "SOFTWARE\Wow6432Node\ODBC\ODBC.INI\"
CHECKDSN HKEY_CURRENT_USER, "SOFTWARE\Wow6432Node\ODBC\ODBC.INI\"

'*******************************************************************************
'	Helper Methods
'*******************************************************************************
SUB CHECKDSN (HKEY, PATH)
	oReg.EnumValues HKEY, PATH & "ODBC DATA SOURCES", arrValueNames, arrValueTypes
	For i = 0 to Ubound(arrValueNames)
		strValueName = arrValueNames(i)
		oReg.GetStringValue HKEY, PATH & "ODBC DATA SOURCES", strValueName, strValue
		IF strValue = "Client Access ODBC Driver" OR _
			strValue = "Client Access ODBC Driver (32-bit)" OR _
			strValue = "iSeries Access ODBC Driver" THEN
			oReg.GetStringValue HKEY, PATH & strValueName, "ConnectionType", strDSNReadOnlyValue
			blnDSNReadOnly = FALSE
			IF strDSNReadOnlyValue = "1" OR strDSNReadOnlyValue = "2" THEN 
				blnDSNReadOnly = TRUE
			ELSE
				oReg.SetStringValue HKEY, PATH & strValueName, "ConnectionType", "2"
			END IF
			InsertDSNLog strMachineName, strValueName, strValue, blnDSNReadOnly
		END IF
	Next
END SUB

Sub ConvertToDouble(byref value)
	If isnull(value) or value = "" then 
		value = 0
	Else
		value = cdbl(value)
	End If
End Sub

Sub InsertLog(MachineName, DriverName, Version)
	'If Version = 0 Then Exit Sub
	Set objCommand = CreateObject("ADODB.Command")
	Set objParam = CreateObject("ADODB.Parameter")
	objCommand.ActiveConnection = strConn
	objCommand.commandtext = "p_ODBC_Log" 
	objCommand.CommandType = 4 'defines cmd type as stored proc
	Set objParm = objCommand.CreateParameter("@MachineName", adVarChar, adParamInput, 20,MachineName)          
	objCommand.Parameters.Append objParm
	Set objParm = objCommand.CreateParameter("@Driver", adVarChar, adParamInput, 50,DriverName)          
	objCommand.Parameters.Append objParm
	Set objParm = objCommand.CreateParameter("@DriverVersion", adDouble, adParamInput,,Version)          
	objCommand.Parameters.Append objParm
	objCommand.Execute
End Sub

Sub InsertFileLog(MachineName, DriverName, Version)
	'If Version = 0 Then Exit Sub
	Set objCommand = CreateObject("ADODB.Command")
	Set objParam = CreateObject("ADODB.Parameter")
	objCommand.ActiveConnection = strConn
	objCommand.commandtext = "p_ODBC_FileLog" 
	objCommand.CommandType = 4 'defines cmd type as stored proc
	Set objParm = objCommand.CreateParameter("@MachineName", adVarChar, adParamInput, 20,MachineName)          
	objCommand.Parameters.Append objParm
	Set objParm = objCommand.CreateParameter("@Driver", adVarChar, adParamInput, 50,DriverName)          
	objCommand.Parameters.Append objParm
	Set objParm = objCommand.CreateParameter("@FileVersion", adVarChar, adParamInput, 50,Version)          
	objCommand.Parameters.Append objParm
	objCommand.Execute
End Sub

Sub InsertDSNLog(MachineName, DSNName, DSNDriver, DSNReadOnly)
	'If Version = 0 Then Exit Sub
	Set objCommand = CreateObject("ADODB.Command")
	Set objParam = CreateObject("ADODB.Parameter")
	objCommand.ActiveConnection = strConn
	objCommand.commandtext = "p_DSN_Log"
	objCommand.CommandType = 4 'defines cmd type as stored proc
	Set objParm = objCommand.CreateParameter("@MachineName", adVarChar, adParamInput, 20,MachineName)          
	objCommand.Parameters.Append objParm
	Set objParm = objCommand.CreateParameter("@DSNName", adVarChar, adParamInput, 50,DSNName)          
	objCommand.Parameters.Append objParm
	Set objParm = objCommand.CreateParameter("@DSNDriver", adVarChar, adParamInput, 50,DSNDriver)          
	objCommand.Parameters.Append objParm
	Set objParm = objCommand.CreateParameter("@DSNReadOnly", adBoolean, adParamInput, ,DSNReadOnly)          
	objCommand.Parameters.Append objParm
	objCommand.Execute
End Sub

function GetVersion(Path)
	output = ""
	on error resume next
	output = CreateObject("Scripting.FileSystemObject").GetFileVersion(Path)
	GetVersion = output
end function

Turn on Remote Registry service on a remote PC

If you have ever needed to switch on remote registry access on a machine, try this.

Save the following as a file with a .BAT extension:

@echo off

set /p MachineID= Which machine do you wish to connect to? 

sc \\%MachineID% start "RemoteRegistry"

echo "Please edit the registry now (Remember to add the network machine using the File menu)."
REGEDIT
pause

sc \\%MachineID% stop "RemoteRegistry"
pause

Pretty PC Info/diagnostic script

In a previous post I showed you a script which generates a text file with the details for the current machine.

Below is a version that creates an HTML version of the file and provides a menu for locating specific areas of interest.

Copy the code and save it with a .VBS extension:

Const ForWriting = 2

strComputer = "."

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )

Set colItems = objWMIService.ExecQuery( "Select * from Win32_ComputerSystem" )
For Each objItem in colItems
	
	strComputer = objItem.Name
	
	'Set objOutput = objFSO.OpenTextFile("\\SERVER\SHARE$\" & strComputer & ".htm", ForWriting, True) 'SAVES FILE TO NETWORK LOCATION
	Set objOutput = objFSO.OpenTextFile(strComputer & ".htm", ForWriting, True) 'USED FOR TESTING
	
	objOutput.WriteLine "<!DOCTYPE html>"
	objOutput.WriteLine "<html>"
	objOutput.WriteLine "	<head>"
	objOutput.WriteLine "		<style type=""text/css"">"
	objOutput.WriteLine "			<!--"
	objOutput.WriteLine "			@import url(""style.css"");"
	objOutput.WriteLine "			-->"
	objOutput.WriteLine "		</style>"
	objOutput.WriteLine "	</head>"
	objOutput.WriteLine "	<body>"
	objOutput.WriteLine "		<h1>" & strComputer & " info</h1>"
	objOutput.WriteLine "		<div id=""menu"">"
	objOutput.WriteLine "			<a name=""Top"" />"
	objOutput.WriteLine "			<h2>Menu</h2>"
	objOutput.WriteLine "			<p id=""links"">"
	objOutput.WriteLine "				<ul><li><a href=""#UserInfo"">User Info</a></li>"
	objOutput.WriteLine "					<li><a href=""#SystemInfo"">System Info</a></li>"
	objOutput.WriteLine "					<li><a href=""#ProcessorInfo"">Processor Info</a></li>"
	objOutput.WriteLine "					<li><a href=""#MemoryInfo"">Memory Info</a></li>"
	objOutput.WriteLine "					<li><a href=""#DisplayInfo"">Display Info</a></li>"
	objOutput.WriteLine "					<li><a href=""#IPInfo"">IP Info</a></li>"
	objOutput.WriteLine "					<li><a href=""#DriveInfo"">Drive Info</a></li>"
	objOutput.WriteLine "					<li><a href=""#OSInfo"">OS Info</a></li>"
	objOutput.WriteLine "					<li><a href=""#PrinterInfo"">Printer Info</a></li>"
	objOutput.WriteLine "					<li><a href=""#StartUpInfo"">Start Up Info</a></li>"
	objOutput.WriteLine "					<li><a href=""#SoftwareInfo"">Software Info</a></li>"
	objOutput.WriteLine "					<li><a href=""#HotFixInfo"">Hot Fix Info</a></li>"
	objOutput.WriteLine "					<li><a href=""#ServiceInfo"">Service Info</a></li>"
	objOutput.WriteLine "					<li><a href=""#ProcessInfo"">Process Info</a></li>"
	objOutput.WriteLine "				</ul>"
	objOutput.WriteLine "			</p>"
	objOutput.WriteLine "		</div>"
	
	objOutput.WriteLine UserInfo()
	objOutput.WriteLine SystemInfo(strComputer)
	objOutput.WriteLine ProcessorInfo(strComputer)
	objOutput.WriteLine MemoryInfo(strComputer)
	objOutput.WriteLine DisplayInfo(strComputer)
	objOutput.WriteLine IPInfo(strComputer)
	objOutput.WriteLine DriveInfo(strComputer)
	objOutput.WriteLine OSInfo(strComputer)
	objOutput.WriteLine PrinterInfo(strComputer)
	objOutput.WriteLine StartUpInfo(strComputer)
	objOutput.WriteLine SoftwareInfo(strComputer)
	objOutput.WriteLine HotFixInfo(strComputer)
	objOutput.WriteLine ServiceInfo(strComputer)
	objOutput.WriteLine ProcessInfo(strComputer)
	
	objOutput.WriteLine "	</body>"
	objOutput.WriteLine "<html>"
		
	ObjOutput.Close
Next

Public Function UserInfo()

	dim output
	Set WshShell = WScript.CreateObject("WScript.Shell")

	output = output & "		<div id=""UserInfo"">" & VBCrLf
	output = output & "			<a name=""UserInfo"" />" & VBCrLf
	output = output & "			<p>" & VBCrLf
	output = output & "				<h2>User Info</h2>" & VBCrLf
	output = output & "				<table>" & VBCrLf
	output = output & "					<tr>" & VBCrLf
	output = output & "						<th>Current User</th>" & VBCrLf
	output = output & "						<td>" & WshShell.Environment("Process")("username") & "</td>" & VBCrLf
	output = output & "					</tr>" & VBCrLf
	output = output & "					<tr>" & VBCrLf
	output = output & "						<th>Computer Name</th>" & VBCrLf
	output = output & "						<td>" & WshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" ) & "</td>" & VBCrLf
	output = output & "					</tr>" & VBCrLf
	output = output & "					<tr>" & VBCrLf
	output = output & "						<th>Logon Server</th>" & VBCrLf
	output = output & "						<td>" & WshShell.ExpandEnvironmentStrings( "%LOGONSERVER%" ) & "</td>" & VBCrLf
	output = output & "					</tr>" & VBCrLf
	output = output & "					<tr>" & VBCrLf
	output = output & "						<th>User Domain</th>" & VBCrLf
	output = output & "						<td>" & WshShell.ExpandEnvironmentStrings( "%USERDOMAIN%" ) & "</td>" & VBCrLf
	output = output & "					</tr>" & VBCrLf
	output = output & "					<tr>" & VBCrLf
	output = output & "						<th>User Name</th>" & VBCrLf
	output = output & "						<td>" & WshShell.ExpandEnvironmentStrings( "%USERNAME%" ) & "</td>" & VBCrLf
	output = output & "					</tr>" & VBCrLf
	output = output & "				</table>" & VBCrLf
	output = output & "			</p>" & VBCrLf
	output = output & "			<a href=""#Top"">Back to top</a>" & VBCrLf
	output = output & "		</div>" & VBCrLf

	UserInfo = output

End Function

Public Function OSInfo(strComputer)

	dim output
	
	Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
	Set colSettings = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
	
	output = output & "		<div id=""OSInfo"">" & VBCrLf
	output = output & "			<a name=""OSInfo"" />" & VBCrLf
	output = output & "			<p>" & VBCrLf
	output = output & "				<h2>OS Info</h2>" & VBCrLf
	output = output & "				<table>" & VBCrLf
	
	For Each objOperatingSystem in colSettings 
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>OS Name</th>" & VBCrLf
		output = output & "						<td>" & objOperatingSystem.Name & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Version</th>" & VBCrLf
		output = output & "						<td>" & objOperatingSystem.Version & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Service Pack</th>" & VBCrLf
		output = output & "						<td>" & objOperatingSystem.ServicePackMajorVersion & "." & objOperatingSystem.ServicePackMinorVersion & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>OS Manufacturer</th>" & VBCrLf
		output = output & "						<td>" & objOperatingSystem.Manufacturer & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Windows Directory</th>" & VBCrLf
		output = output & "						<td>" & objOperatingSystem.WindowsDirectory & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Locale</th>" & VBCrLf
		output = output & "						<td>" & objOperatingSystem.Locale & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Available Physical Memory</th>" & VBCrLf
		output = output & "						<td>" & round((objOperatingSystem.FreePhysicalMemory) * .001 ) & " MB" & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Total Virtual Memory</th>" & VBCrLf
		output = output & "						<td>" & round((objOperatingSystem.TotalVirtualMemorySize) * .001 ) & " MB" & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Available Virtual Memory</th>" & VBCrLf
		output = output & "						<td>" & round((objOperatingSystem.FreeVirtualMemory) * .001 ) & " MB" & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Paging File</th>" & VBCrLf
		output = output & "						<td>" & round((objOperatingSystem.SizeStoredInPagingFiles) * .001 ) & " MB" & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
	Next
	
	const HKEY_LOCAL_MACHINE = &H80000002

	Set objShell = CreateObject("WScript.Shell")

	Set oReg=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
	strKeyPath = "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
	strValueName = "PROCESSOR_ARCHITECTURE"
	oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,OsType
	
	output = output & "					<tr>" & VBCrLf
	output = output & "						<th>System Type</th>" & VBCrLf
	
	If OsType = "x86" then
		output = output & "						<td>32-bit Operating System</td>" & VBCrLf
	elseif OsType = "AMD64" then
		output = output & "						<td>64-bit Operating System</td>" & VBCrLf
	end if
	
	output = output & "					</tr>"	 & VBCrLf
	output = output & "				</table>" & VBCrLf
	output = output & "			</p>" & VBCrLf
	output = output & "			<a href=""#Top"">Back to top</a>" & VBCrLf
	output = output & "		</div>" & VBCrLf
	
	OSInfo = output

End Function

Public Function IPInfo(strComputer)

	dim output
	
	output = output & "		<div id=""IPInfo"">" & VBCrLf
	output = output & "			<a name=""IPInfo"" />" & VBCrLf
	output = output & "			<p>" & VBCrLf
	output = output & "				<h2>IP Address Info</h2>" & VBCrLf
	output = output & "				<table>" & VBCrLf
	output = output & "					<tr>" & VBCrLf
	output = output & "						<th>Address</th>" & VBCrLf
	output = output & "					</tr>" & VBCrLf
	
	Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )
	Set colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE MACAddress > ''", "WQL", 48 )

	For Each objItem In colItems
		If IsArray( objItem.IPAddress ) Then
			For Each Address In objItem.IPAddress
				output = output & "					<tr>" & VBCrLf
				output = output & "						<td>" & Address & "</td>" & VBCrLf
				output = output & "					</tr>" & VBCrLf
			Next
		End If
	Next
	
	output = output & "				</table>" & VBCrLf
	output = output & "			</p>" & VBCrLf
	output = output & "			<a href=""#Top"">Back to top</a>" & VBCrLf
	output = output & "		</div>" & VBCrLf
	
	IPInfo = output

End Function

Public Function SystemInfo(strComputer)
	
	dim output
	
	output = output & "		<div id=""SystemInfo"">" & VBCrLf
	output = output & "			<a name=""SystemInfo"" />" & VBCrLf
	output = output & "			<p>" & VBCrLf
	output = output & "				<h2>System Info</h2>" & VBCrLf
	output = output & "				<table>" & VBCrLf
	
	Set SystemSet = GetObject("winmgmts://"& strComputerName ).InstancesOf("Win32_ComputerSystem")
	for each System in SystemSet
		output = output & "					<tr>"
		output = output & "						<th>Machine Name</th>" & VBCrLf
		output = output & "						<td>" & System.Name & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Logon</th>" & VBCrLf
		output = output & "						<td>" & System.username & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Model</th>" & VBCrLf
		output = output & "						<td>" & System.Model & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
	next
	
	Set colSMBIOS = objWMIService.ExecQuery("Select * from Win32_SystemEnclosure")
	For Each objSMBIOS in colSMBIOS
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Service Tag</th>" & VBCrLf
		output = output & "						<td>" & objSMBIOS.SerialNumber & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
	Next
	
	output = output & "				</table>" & VBCrLf
	output = output & "			</p>" & VBCrLf
	output = output & "			<a href=""#Top"">Back to top</a>" & VBCrLf
	output = output & "		</div>" & VBCrLf

	SystemInfo = output
	
End Function

Public Function DriveInfo(strComputer)
	
	dim output
	
	output = output & "		<div id=""DriveInfo"">" & VBCrLf
	output = output & "			<a name=""DriveInfo"" />" & VBCrLf
	output = output & "			<p>" & VBCrLf
	output = output & "				<h2>Drive Info</h2>" & VBCrLf
	output = output & "				<table>" & VBCrLf
	
	Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk Where DriveType = 3 OR DriveType = 4")
	
	intHDUs = 0
	
	output = output & "					<tr>" & VBCrLf
	output = output & "						<th>No.</th>" & VBCrLf
	output = output & "						<th>Letter</th>" & VBCrLf
	output = output & "						<th>Size (GB)</th>" & VBCrLf
	output = output & "						<th>Free (GB)</th>" & VBCrLf
	output = output & "						<th>Free (%)</th>" & VBCrLf
	output = output & "						<th>Compressed</th>" & VBCrLf
	output = output & "						<th>Description</th>" & VBCrLf
	output = output & "						<th>FileSystem</th>" & VBCrLf
	output = output & "						<th>Name</th>" & VBCrLf
	output = output & "						<th>ProviderName</th>" & VBCrLf
	output = output & "						<th>Status</th>" & VBCrLf
	output = output & "						<th>StatusInfo</th>" & VBCrLf
	output = output & "						<th>VolumeName</th>" & VBCrLf
	output = output & "						<th>VolumeSerialNumber</th>" & VBCrLf
	output = output & "					</tr>" & VBCrLf
	
	For Each objItem in colItems
		intHDUs = intHDUs + 1
		output = output & "					<tr>" & VBCrLf
		output = output & "						<td>" & intHDUs & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.DeviceID & "</td>" & VBCrLf
		output = output & "						<td class=""right"">" & Int( ( objItem.Size + 536870912 ) / 1073741824 ) & " GB" & "</td>" & VBCrLf
		output = output & "						<td class=""right"">" & Int( ( objItem.FreeSpace + 536870912 ) / 1073741824 ) & " GB" & "</td>" & VBCrLf
		output = output & "						<td class=""right"">" & Round(((cdbl(objItem.FreeSpace) / cdbl(objItem.Size)) * 100),1) & " %" & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.Compressed & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.Description & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.FileSystem & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.Name & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.ProviderName & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.Status & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.StatusInfo & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.VolumeName & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.VolumeSerialNumber & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
	Next
	
	output = output & "				</table>" & VBCrLf
	output = output & "			</p>" & VBCrLf
	output = output & "			<a href=""#Top"">Back to top</a>" & VBCrLf
	output = output & "		</div>" & VBCrLf

	DriveInfo = output
	
End Function

Public Function MemoryInfo(strComputer)
	
	dim output
	
	output = output & "		<div id=""MemoryInfo"">" & VBCrLf
	output = output & "			<a name=""MemoryInfo"" />" & VBCrLf
	output = output & "			<p>" & VBCrLf
	output = output & "				<h2>Memory Info</h2>" & VBCrLf
	output = output & "				<table>" & VBCrLf
	
	Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )

	Set colItems = objWMIService.ExecQuery( "Select * from Win32_MemoryDevice" )
	
	intMem = 0
	intMod = 0
	
	For Each objItem in colItems
		intMem = intMem + objItem.EndingAddress - objItem.StartingAddress
		intMod = intMod + 1
	Next
	
	output = output & "					<tr>" & VBCrLf
	output = output & "						<th>Memory Modules</th>" & VBCrLf
	output = output & "						<td>" & intMod & "</td>" & VBCrLf
	output = output & "					</tr>" & VBCrLf
	output = output & "					<tr>" & VBCrLf
	output = output & "						<th>Total Physical Memory</th>" & VBCrLf
	output = output & "						<td>" & Int( ( intMem + 1023 ) / 1024 ) & " MB"  & "</td>" & VBCrLf
	output = output & "					</tr>" & VBCrLf
	output = output & "				</table>" & VBCrLf
	output = output & "			</p>" & VBCrLf
	output = output & "			<a href=""#Top"">Back to top</a>" & VBCrLf
	output = output & "		</div>" & VBCrLf
	
	MemoryInfo = output

End Function 

Public Function DisplayInfo(strComputer)
	
	dim output
	
	output = output & "		<div id=""DisplayInfo"">" & VBCrLf
	output = output & "			<a name=""DisplayInfo"" />" & VBCrLf
	output = output & "			<p>" & VBCrLf
	output = output & "				<h2>Display Info</h2>" & VBCrLf
	output = output & "				<table>" & VBCrLf
	
	Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )

	Set colItems = objWMIService.ExecQuery( "Select * from Win32_VideoController" )
	
	For Each objItem in colItems
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Name</th>" & VBCrLf
		output = output & "						<td>" & objItem.Name & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Description</th>" & VBCrLf
		output = output & "						<td>" & objItem.Description & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Video Processor</th>" & VBCrLf
		output = output & "						<td>" & objItem.VideoProcessor & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Adapter RAM</th>" & VBCrLf
		output = output & "						<td>" & Int( ( objItem.AdapterRAM + 1048575 ) / 1048576 ) & " MB" & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Video Mode Description</th>" & VBCrLf
		output = output & "						<td>" & objItem.VideoModeDescription & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
	Next
	
	output = output & "				</table>" & VBCrLf
	output = output & "			</p>" & VBCrLf
	output = output & "			<a href=""#Top"">Back to top</a>" & VBCrLf
	output = output & "		</div>" & VBCrLf
	
	DisplayInfo = output

End Function 

Public Function ProcessorInfo(strComputer)
	
	dim output
	
	output = output & "		<div id=""ProcessorInfo"">" & VBCrLf
	output = output & "			<a name=""ProcessorInfo"" />" & VBCrLf
	output = output & "			<p>" & VBCrLf
	output = output & "				<h2>Processor Info</h2>" & VBCrLf
	output = output & "				<table>" & VBCrLf
	
	Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )
	
	Set colItems = objWMIService.ExecQuery( "Select * from Win32_Processor" )
	
	intCPUs = 0
	
	For Each objItem in colItems
		intCPUs = intCPUs + 1
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>No.</th>" & VBCrLf
		output = output & "						<td>" & intCPUs & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Name</th>" & VBCrLf
		output = output & "						<td>" & objItem.Name & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Manufacturer</th>" & VBCrLf
		output = output & "						<td>" & objItem.Manufacturer & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Description</th>" & VBCrLf
		output = output & "						<td>" & objItem.Description & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Current Clock Speed</th>" & VBCrLf
		output = output & "						<td>" & objItem.CurrentClockSpeed & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Maximum Clock Speed</th>" & VBCrLf
		output = output & "						<td>" & objItem.MaxClockSpeed & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>System Type</th>" & VBCrLf
		output = output & "						<td>" & objItem.Architecture & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Processor</th>" & VBCrLf
		output = output & "						<td>" & objItem.Description & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Windows</th>" & VBCrLf
		output = output & "						<td>" & objItem.AddressWidth   & "-bit" & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
		output = output & "					<tr>" & VBCrLf
		output = output & "						<th>Processor</th>" & VBCrLf
		output = output & "						<td>" & objItem.DataWidth & "-bit" & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
	Next
	
	output = output & "				</table>" & VBCrLf
	output = output & "			</p>" & VBCrLf
	output = output & "			<a href=""#Top"">Back to top</a>" & VBCrLf
	output = output & "		</div>" & VBCrLf
	
	ProcessorInfo = output
	
End Function 

Public Function SoftwareInfo(strComputer)
	
	dim output
	
	output = output & "		<div id=""SoftwareInfo"">" & VBCrLf
	output = output & "			<a name=""SoftwareInfo"" />" & VBCrLf
	output = output & "			<p>" & VBCrLf
	output = output & "				<h2>Software Info</h2>" & VBCrLf
	output = output & "				<table>" & VBCrLf

	Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
	Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product")
	
	output = output & "					<tr>" & VBCrLf
	output = output & "						<th>Name</th>" & VBCrLf
	output = output & "						<th>Installed</th>" & VBCrLf
	output = output & "						<th>Modified</th>" & VBCrLf
	output = output & "					</tr>" & VBCrLf
	
	For Each objSoftware in colSoftware
		output = output & "					<tr>" & VBCrLf
		output = output & "						<td>" & objSoftware.Caption & "</td>" & VBCrLf
		output = output & "						<td>" & objSoftware.installDate & "</td>" & VBCrLf
		output = output & "						<td>" & objSoftware.installDate2 & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
	Next
	
	output = output & "				</table>" & VBCrLf
	output = output & "			</p>" & VBCrLf
	output = output & "			<a href=""#Top"">Back to top</a>" & VBCrLf
	output = output & "		</div>" & VBCrLf
	
	SoftwareInfo = output

End Function

Public Function HotFixInfo(strComputer)
	
	dim output
	
	output = output & "		<div id=""HotfixInfo"">" & VBCrLf
	output = output & "			<a name=""HotfixInfo"" />" & VBCrLf
	output = output & "			<p>" & VBCrLf
	output = output & "				<h2>Hotfix Info</h2>" & VBCrLf
	output = output & "				<table>" & VBCrLf

	Set colQuickFixes = objWMIService.ExecQuery( "Select * from Win32_QuickFixEngineering" )
	
	output = output & "					<tr>" & VBCrLf
	output = output & "						<th>Description</th>" & VBCrLf
	output = output & "						<th>Hot Fix ID</th>" & VBCrLf
	output = output & "						<th>Installation Date</th>" & VBCrLf
	output = output & "						<th>Installed By</th>" & VBCrLf
	output = output & "					</tr>" & VBCrLf
	
	For Each objQuickFix in colQuickFixes
		output = output & "					<tr>" & VBCrLf
		output = output & "						<td>" & objQuickFix.Description & "</td>" & VBCrLf
		output = output & "						<td>" & objQuickFix.HotFixID & "</td>" & VBCrLf
		output = output & "						<td>" & objQuickFix.InstallDate & "</td>" & VBCrLf
		output = output & "						<td>" & objQuickFix.InstalledBy & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
	Next
	
	output = output & "				</table>" & VBCrLf
	output = output & "			</p>" & VBCrLf
	output = output & "			<a href=""#Top"">Back to top</a>" & VBCrLf
	output = output & "		</div>" & VBCrLf
	
	HotFixInfo = output

End Function

Public Function ProcessInfo(strComputer)
	
	dim output
	
	output = output & "		<div id=""ProcessInfo"">" & VBCrLf
	output = output & "			<a name=""ProcessInfo"" />" & VBCrLf
	output = output & "			<p>" & VBCrLf
	output = output & "				<h2>Process Info</h2>" & VBCrLf
	output = output & "				<table>" & VBCrLf

	Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )
	Set colItems = objWMIService.ExecQuery( "Select * from Win32_Process", , 48 )
	
	output = output & "					<tr>" & VBCrLf
	output = output & "						<th>Name</th>" & VBCrLf
	output = output & "						<th>Path</th>" & VBCrLf
	output = output & "					</tr>" & VBCrLf
	
	For Each objItem in colItems
		output = output & "					<tr>" & VBCrLf
		output = output & "						<td>" & objItem.Caption & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.ExecutablePath & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
	Next
	
	output = output & "				</table>" & VBCrLf
	output = output & "			</p>" & VBCrLf
	output = output & "			<a href=""#Top"">Back to top</a>" & VBCrLf
	output = output & "		</div>" & VBCrLf
	
	ProcessInfo = output

End Function

Public Function ServiceInfo(strComputer)
	
	dim output
	
	output = output & "		<div id=""ServiceInfo"">" & VBCrLf
	output = output & "			<a name=""ServiceInfo"" />" & VBCrLf
	output = output & "			<p>" & VBCrLf
	output = output & "				<h2>Service Info</h2>" & VBCrLf
	output = output & "				<table>" & VBCrLf

	Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )
	Set colItems = objWMIService.ExecQuery("Select * from Win32_Service",,48)
	
	output = output & "					<tr>" & VBCrLf
	output = output & "						<th>Name</th>" & VBCrLf
	output = output & "						<th>Display Name</th>" & VBCrLf
	output = output & "						<th>Path Name</th>" & VBCrLf
	output = output & "						<th>Start Mode</th>" & VBCrLf
	output = output & "						<th>State</th>" & VBCrLf
	output = output & "						<th>Login</th>" & VBCrLf
	output = output & "					</tr>" & VBCrLf
	
	For Each objItem in colItems
		output = output & "					<tr>" & VBCrLf
		output = output & "						<td>" & objItem.Name & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.DisplayName & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.PathName & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.StartMode & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.State & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.StartName & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
	Next
	
	output = output & "				</table>" & VBCrLf
	output = output & "			</p>" & VBCrLf
	output = output & "			<a href=""#Top"">Back to top</a>" & VBCrLf
	output = output & "		</div>" & VBCrLf
	
	ServiceInfo = output

End Function

Public Function PrinterInfo(strComputer)
	
	dim output
	
	output = output & "		<div id=""PrinterInfo"">" & VBCrLf
	output = output & "			<a name=""PrinterInfo"" />" & VBCrLf
	output = output & "			<p>" & VBCrLf
	output = output & "				<h2>Printer Info</h2>" & VBCrLf
	
	output = output & "				<table>" & VBCrLf

	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer",,48)
	
	output = output & "					<tr>" & VBCrLf
	output = output & "						<th>Printer Name</th>" & VBCrLf
	output = output & "						<th>Port Name</th>" & VBCrLf
	output = output & "						<th>Driver Name</th>" & VBCrLf
	output = output & "						<th>Server Name</th>" & VBCrLf
	output = output & "						<th>Share Name</th>" & VBCrLf
	output = output & "					</tr>" & VBCrLf

	For Each objItem in colItems
		output = output & "					<tr>" & VBCrLf
		output = output & "						<td>" & objItem.Name & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.PortName & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.DriverName & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.ServerName & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.ShareName & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
	Next
	
	output = output & "				</table>" & VBCrLf
	output = output & "			</p>" & VBCrLf
	output = output & "			<a href=""#Top"">Back to top</a>" & VBCrLf
	output = output & "		</div>" & VBCrLf
	
	PrinterInfo = output

End Function

Public Function StartUpInfo(strComputer)
	
	dim output
	
	output = output & "		<div id=""StartUpInfo"">" & VBCrLf
	output = output & "			<a name=""StartUpInfo"" />" & VBCrLf
	output = output & "			<p>" & VBCrLf
	output = output & "				<h2>Start Up Info</h2>" & VBCrLf
	
	output = output & "				<table>" & VBCrLf

	Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )
	Set colItems = objWMIService.ExecQuery( "Select * from Win32_StartupCommand", , 48 )
	
	output = output & "					<tr>" & VBCrLf
	output = output & "						<th>Name</th>" & VBCrLf
	output = output & "						<th>Command</th>" & VBCrLf
	output = output & "						<th>Location</th>" & VBCrLf
	output = output & "						<th>User</th>" & VBCrLf
	output = output & "					</tr>" & VBCrLf
	
	For Each objItem in colItems
		output = output & "					<tr>" & VBCrLf
		output = output & "						<td>" & objItem.Name & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.Command & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.Location & "</td>" & VBCrLf
		output = output & "						<td>" & objItem.User & "</td>" & VBCrLf
		output = output & "					</tr>" & VBCrLf
	Next
	
	output = output & "				</table>" & VBCrLf
	output = output & "			</p>" & VBCrLf
	output = output & "			<a href=""#Top"">Back to top</a>" & VBCrLf
	output = output & "		</div>" & VBCrLf
	
	StartUpInfo = output

End Function

Here is an example CSS stylesheet:

* {
	font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
	font-size: 10pt;
	}
h1 {
	font-size: 14pt;
	}
h2 {
	font-size: 11pt;
	}

#menu {
	position: fixed;
	right: 0;
	top: 25px;
	width: 10em;
	margin-top: -2.5em;
	background: #b9c9fe;
	padding: 2px;
}

#menu ul {
	background: #e8edff;
	list-style-type:none;
}

table
{
	font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
	font-size: 10px;
	margin: 0px 15em 0px 2em;
	text-align: left;
	border-collapse: collapse;
}
table th
{
	font-size: 13px;
	font-weight: normal;
	padding: 8px;
	background: #b9c9fe;
	border-top: 4px solid #aabcfe;
	border-bottom: 1px solid #fff;
	color: #039;
}
table td
{
	padding: 8px;
	background: #e8edff; 
	border-bottom: 1px solid #fff;
	color: #669;
	border-top: 1px solid transparent;
}
table tr:hover td
{
	background: #d0dafd;
	color: #339;
}

.right{
	text-align:right;
}

Create a self-signed wildcard certificate using OpenSSL on Windows

I needed to create a certificate to enable SSL on some of our internal sites and got a bit frustrated that my self signed cert kept on showing the warning about it not being trusted. The are plenty of ways to get round this, one of them being to add a rule to the GPO to trust the certificate.

My second issue was that my self-signed certificate generated from IIS used the server name and not the hostheader name I am using for my internal site, what I needed was a certificate with additional entries for alternatives names but why stop there when you can have a domain certificate or even better a wildcard certificate.

I decided to give OpenSSL another go to see if it would solve the problem and I came up with the script below.

Copy this script into Notepad and save with a .BAT extension, you will need to have OpenSSL installed, my instance is located at “c:\openssl-win32\” – yours may be different, for it to work.

REM : Moves to C drive
c:

REM : Opens openssl-win32 folder
cd c:\openssl-win32

REM : Generates a key
bin\openssl genrsa 2048 > wildcard.hostname.key

REM : Generates a certificate using the key
bin\openssl req -config "c:\openssl-win32\bin\openssl.cfg" -new -x509 -nodes -sha1 -days 3650 -key wildcard.hostname.key > wildcard.hostname.cert

REM : To export a INFO:
bin\openssl x509 -noout -fingerprint -text < wildcard.hostname.cert > wildcard.hostname.info

REM : To export a PEM:
type wildcard.hostname.cert wildcard.hostname.key > wildcard.hostname.pem

REM : To export a PFX:
bin\openssl pkcs12 -export -out wildcard.hostname.pfx -inkey wildcard.hostname.key -in wildcard.hostname.cert

REM : Import certificate
wildcard.hostname.pfx

REM : To check certificate:
certmgr.msc

SharePoint – Multiple versions of item on update after implementing a custom form

I came across this one the other when working on a Windows SharePoint Services (WSS) 3.0 site the other day.

I had a workflow that wouldn’t send the correct comments value when a list object was updated, It turned out that when the list item was being updated it would create two versions.

I figured out that this was due to a mix of modes for the fields on the EditForm.aspx for the list, which was a custom form I had implemented to allow for some additional custom fields.

If you have created a custom form make sure that on the New form all of the fields have the Control mode set to the correct value:

<td width="400px" valign="top" class="ms-formbody">
	<SharePoint:FormField runat="server" id="ff14{$Pos}" ControlMode="New" FieldName="Category" __designer:bind="ddwrt:DataBind('i',concat('ff14',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Category')}"/>
	<SharePoint:FieldDescription runat="server" id="ff14description{$Pos}" FieldName="Category" ControlMode="New"/>
</td>

The ControlMode attribute should be set to “New” for the NewForm or “Edit” for the edit form.

Also, the first parameter for the ddwrt:DataBind function, withitn the __designer:bind attribute, should be ‘i’ for the New form or ‘u’ for the Edit form.

Migrate all SQL databases

Here is a little bit of work in progress:

A couple of years ago I had to migrate all of the database from one SQL instance to another and so I looked into scripting as much as possible.

The following is a script to backup all of your databases to a specified folder, in this case ‘c:\sql backups\’:

Declare 
	@BackupPath varchar(250) = 'C:\SQL Backups\', 
	@DB_Name varchar(50)

Declare DB Cursor READ_ONLY
For
SELECT 
	[name]
FROM [master].[sys].[databases]
Where [name] <> 'master'
UNION ALL
SELECT 
	[name]
FROM [master].[sys].[databases]
Where [name] = 'master'

OPEN DB

FETCH NEXT FROM DB 
INTO @DB_Name

WHILE @@FETCH_STATUS = 0
BEGIN

	If @DB_Name <> 'master'
	Begin
		PRINT 'exec sp_dboption [' + @DB_Name + '], ''single user'', true'
	End
	
	PRINT 'BACKUP DATABASE [' + @DB_Name + '] TO DISK = ''' + @BackupPath + @DB_Name + '.BAK'' WITH INIT'
	
	If @DB_Name <> 'master'
	Begin
		PRINT 'exec sp_dboption [' + @DB_Name + '], ''offline'', true'
	End
	
	PRINT ''
	
    FETCH NEXT FROM DB 
    INTO @DB_Name
END 
CLOSE DB
DEALLOCATE DB

And here is a script I have created to restore all of the databases back again (Make sure you change #LOCAL_SERVER_INSTANCE# to the name of your local instance), beware I haven’t tested this version:

Declare 
	@BackupPath varchar(250) = 'C:\SQL Backups\', 
	@NewPath varchar(250) = 'C:\Program Files\Microsoft SQL Server\MSSQL10\MSSQL\Data\',
	@DB_Name varchar(50),
	@DB_FileGroup_ID int,
	@DB_File_Name varchar(50)

Declare DB Cursor READ_ONLY
For
SELECT 
	[name]
FROM [master].[sys].[databases]
Where [name] = 'master'
UNION ALL
SELECT 
	[name]
FROM [master].[sys].[databases]
Where [name] <> 'master'

OPEN DB

FETCH NEXT FROM DB 
INTO @DB_Name

WHILE @@FETCH_STATUS = 0
BEGIN

	PRINT '
RESTORE DATABASE [' + @DB_Name + '] FROM DISK = ''' + @BackupPath + @DB_Name + '.BAK'' 
With File = 1, '
	
	Declare @query varchar(max) = 'SET NOCOUNT ON; Select * INTO [file_info] From OpenQuery(#LOCAL_SERVER_INSTANCE#, ''SELECT * From [' + @DB_Name + '].sys.sysfiles'') as t1'
	Exec (@query)
	
	Declare DB_Files Cursor READ_ONLY
	For
	Select groupid, name 
	From [file_info]
	Where groupid > 0
	Union All
	Select groupid, name 
	From [file_info]
	Where groupid = 0

	OPEN DB_Files

	FETCH NEXT FROM DB_Files 
	INTO @DB_FileGroup_ID, @DB_File_Name

	WHILE @@FETCH_STATUS = 0
	BEGIN
		
		IF @DB_FileGroup_ID = 0
		Begin
			PRINT 'Move ''' + @DB_File_Name + ''' TO ''' + @NewPath + @DB_File_Name + '.ldf'','
		End
		Else
		Begin
			PRINT 'Move ''' + @DB_File_Name + ''' TO ''' + @NewPath + @DB_File_Name + '.mdf'','
		End
		
		FETCH NEXT FROM DB_Files 
		INTO @DB_FileGroup_ID, @DB_File_Name
	END 
	CLOSE DB_Files
	DEALLOCATE DB_Files
	
	Drop Table [file_info]
	
	PRINT 'NOUNLOAD, REPLACE, STATS = 10'
	
	--If @DB_Name <> 'master'
	--Begin
		PRINT 'exec sp_dboption [' + @DB_Name + '], ''single user'', false'
	--End
	
	PRINT ''
	
    FETCH NEXT FROM DB 
    INTO @DB_Name
END 
CLOSE DB
DEALLOCATE DB

Xbox live is the bane of my life at the moment

Once again I am having issues with Xbox live, now it could feasibly be something to do with my connection but, I am starting to fall out of love with it.