Outlook VBA – remove reminders

August 27th, 2010

I synchronize my Windows Mobile Device with my corporate-exchange account. This way my calendar stays nicely up to date and gives me reminders for the tasks I have to do.

However I find it rather a hassle that I receive reminders for certain activities like holidays. Therefore I have written a small macro that disables the reminders for all future calendar entries with a certain subject.

Private Sub RemoveReminders(sProject As String)
Dim fldMailbox As MAPIFolder
Dim fldCalendar As MAPIFolder

Dim objItem As AppointmentItem
Dim iCntr As Integer
iCntr = 0

Set fldMailbox = Session.Folders(sMailboxName)
Set fldCalendar = fldMailbox.Folders("Calendar")
Set mcolCalItems = fldCalendar.Items

For Each objItem In mcolCalItems
If objItem.start > Now() Then
If objItem.ReminderSet = True Then
    If InStr(objItem.Body, sProject) > 0 Then
    iCntr = iCntr + 1
With objItem
.ReminderSet = False
.Save
End With

objItem.Save
End If
End If
End If
Next

MsgBox "Modified " & iCntr & " calendar entries"
End Sub

Public Sub RemoveHolidayReminders()
RemoveReminders ("Holiday")
End Sub

ESXi 3.5 and Server 2003 dualboot

January 31st, 2010

After some testing I managed to create a dualboot setup with ESXi 3.5 and Windows Server 2003.

  1. Install ESXi to harddisk 1
  2. Install Windows Server 2003 to harddisk 2.  Delete the existing partition on harddisk 2 if ESXi has created one.
    On the first reboot during the installation you should get an error “NTLDR is missing”
  3. Boot with a live linux cd-rom, eg KNOPPIX
  4. (Re-)install syslinux  bootloader to boot partition (Hypervisor0)
    sudo syslinux /dev/hda1
    file is read only. overwrite anyway (y/n)? y
    sudo mkdir /mnt/Hypervisor0
    sudo mount /dev/hda1 /mnt/Hypervisor0
    vi /mnt/Hypervisor0/syslinux.cfg
    

    original:

    default safeboot.c32
    

    modified:

    default menu.c32
    menu title Dual boot
    timeout 100
    
    label esx
    menu label ESXi 3.5
    COM32 safeboot.c32
    
    LABEL win
    MENU LABEL MS Windows Server 2003
    COM32 chain.c32
    APPEND boot ntldr=/NTLDR
    
  5. Copy syslinux modules menu.c32 and chain.c32 to boot partition (Hypervisor0)
    Use locate to find the folder on the live cd that contains the modules, eg locate menu.c32

    cp /usr/lib/syslinux/menu.c32 /mnt/Hypervisor0
    cp /usr/lib/syslinux/chain.c32 /mnt/Hypervisor0
    
  6. Reboot

Tool to query SQL databases

January 15th, 2010

For some tasks it is useful to run a custom query against a database.
The application using the database perhaps does not have the ability to generate certain reports.
Using SQL manager is a viable option, but then everyone who needs to have this installed to be able to run a query.
It is however possible to create some Excel-files which have the queries embedded.

But as an alternative solution I have created this PowerShell app.
It is a GUI-based tool allowing you to select a saved script or enter a custom query and run it.
The output is by default displayed in a datatable but the output can also be exported to an Excel-document.

The available SQL servers are defined in servers.xml
And to avoid the hassle of selecting a server and database after selecting a script you can predefine a combination of a shortname, server and database in shortnames.xml
Eg. if you have a SQL-file hlp_openincidents.sql and hlp is defined in shortnames.xml with server set to SQLSERVER and database to HELPDESK the tool will autoselect the server: SQLSERVER and the database: HELPDESK

SQL tool source code SQL tool source code

Script software deployment in PowerShell

January 10th, 2010

This is an example in PowerShell of how you can schedule the installation a software package by Altiris DS.
Instead of using the API, the command-line tool axsched is being called to schedule the software package.

function DeploySoftware
{
	param([String]$pcname, [String]$package, [String]$nexttime, [String]$folder)
	#Write-Host "Deploy $pcname '$package' /t $nexttime /f '$folder'"
	#\\ALTIRIS\express\axsched.exe "$pcname" "$package" / t "$nexttime" / f "$folder"

	$StartInfo = New-Object System.Diagnostics.ProcessStartInfo
	$StartInfo.CreateNoWindow = $true
	$StartInfo.UseShellExecute = $false
	$StartInfo.FileName = "\\ALTIRIS\express\axsched.exe"
	$StartInfo.WorkingDirectory = "C:\Temp"
	$StartInfo.Arguments = "`"$pcname`" `"$package`" /t `"$nexttime`" /f `"$folder`""
	$p = [System.Diagnostics.Process]::Start($StartInfo)
	$p.WaitForExit()
	if ($p.ExitCode -eq 0) { $TRUE } else { $FALSE }
}
#This function adds a number of minutes to the given date time and outputs the addition in the right format for AxSched.
function Get-ScheduleTime
{
	param([System.DateTime] $starttime, [int]$minutes)
	#$minutes = 12
	$tspan = New-Object System.TimeSpan(0, 0, $minutes, 0)
	$addtime = [System.DateTime]::op_Addition($starttime, $tspan)
	#"2008-10-20 15:00"
	$y = $addtime.Year
	$mo = $addtime.Month
	$d = $addtime.Day
	$h = $addtime.Hour
	$mi = $addtime.Minute
	$schedtime = "$y"
	$schedtime += "-"
	$schedtime += TwoDecimal("$mo")
	$schedtime += "-"
	$schedtime += TwoDecimal("$d")
	$schedtime += " "
	$schedtime += TwoDecimal("$h")
	$schedtime += ":"
	$schedtime += TwoDecimal("$mi")
	$schedtime
}
#Simple function to convert a single decimal to a two decimal, eg 7 becomes 07
function TwoDecimal
{
	param([String]$Number)
	while ($number.Length -lt 2) { $number = "0$number" }
	$number
}
$now = [System.DateTime]::Now
$pcname = "COMP007"
$jobname = "Install Outlook 2007"
$jobfolder = "Software"
#The installation of the package needs to be started after 5 minutes.
$nexttime = Get-ScheduleTime $now 5
DeploySoftware $pcname $jobname $nexttime $jobfolder

Powershell check requirements and load addins

January 10th, 2010

Powershell excerpts of how to check if .NET FrameWork 3.5, Quest AD, Altiris ASDK is installed

First the functions that execute the installer.

function Execute-Installer()
{
	param([String]$parameters,[String]$msiworkingdir)
	$msiworkingdir = Resolve-Path $msiworkingdir
	$StartInfo = New-Object System.Diagnostics.ProcessStartInfo
	$StartInfo.CreateNoWindow = $true
	$StartInfo.UseShellExecute = $false
	$StartInfo.FileName = "c:\windows\system32\msiexec.exe"
	$StartInfo.WorkingDirectory = "$msiworkingdir"
	$StartInfo.Arguments = "$parameters"
	$p = [System.Diagnostics.Process]::Start($StartInfo)
	$p.WaitForExit()
	if ($p.ExitCode -eq 0) { $TRUE } else { $FALSE }
}

function Execute-Program()
{
	param([String]$parameters,[String]$program)
	Write-Host "Execute-Program $program $parameters"
	#Write-Host "MSI WorkingDir: $msiworkingdir"
	#$msiworkingdir = Resolve-Path $msiworkingdir
	$program = Resolve-Path $program
	Write-Host "Program: $program"
	$StartInfo = New-Object System.Diagnostics.ProcessStartInfo
	$StartInfo.CreateNoWindow = $true
	$StartInfo.UseShellExecute = $false
	$StartInfo.FileName = $program
	$StartInfo.Arguments = "$parameters"
	$p = [System.Diagnostics.Process]::Start($StartInfo)
	$p.WaitForExit()
	if ($p.ExitCode -eq 0) { $TRUE } else { $FALSE }
}

The code that checks if .NET FrameWork 3.5 is installed.
A messagebox will be displayed if it is not installed.
If users answers yes to the messagebox the requirement will be installed.

#region Check if .NET 3.5 is installed (Requirement for QuestAD and AltirisASDK
function Check-DotNet35{
Write-Host "Check-DotNet35"
$net35 = get-itemproperty "hklm:\\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5"
if($net35 -eq $null){
Write-Host ".NET 3.5 is not installed."
$install = [Windows.Forms.MessageBox]::Show(".NET 3.5 Framework is not installed. This is required. Would you like to install it?", "My Application", [Windows.Forms.MessageBoxButtons]::YesNo, [Windows.Forms.MessageBoxIcon]::Question)
if ($install -eq [Windows.Forms.DialogResult]::Yes){
Execute-Program "/PASSIVE /NORESTART" "D:\Software\DotNet\3.5\dotnetfx35SP1.exe"
}
}else{
Write-Host "DotNet 3.5 FrameWork is installed"
}
}
Check-DotNet35
#endregion

The code to check if Quest AD is installed.
A messagebox will be displayed if it is not installed.
If users answers yes to the messagebox the requirement will be installed.
Also if the users has an outdated version he will receive a messagebox asking to perform an upgrade.

#region Load Quest AD plugin
function Load-QuestAD-Plugin
{
Write-Host "Load-QuestAD-Plugin"
$retVal = (Get-PSSnapin Quest.ActiveRoles.ADManagement 2>$null)
$qadversion = "1.2.2.1254"
#Write-Host $retVal
if ($retVal -eq $null)
{
Write-Host "Quest.ActiveRoles.ADManagement"
Add-PSSnapin Quest.ActiveRoles.ADManagement
$retVal = "$?"
if ($retVal -eq $false)
{
$install = [Windows.Forms.MessageBox]::Show("Quest.ActiveRoles.ADManagement is not installed. Would you like to install it?", "My Application", [Windows.Forms.MessageBoxButtons]::YesNo, [Windows.Forms.MessageBoxIcon]::Question)
if ($install -eq [Windows.Forms.DialogResult]::Yes)
{
Write-Host "Installing Quest.ActiveRoles.ADManagement"
Write-Host "msiexec.exe /i `"$WorkingDir\Requirements\arps.$qadversion.msi`" /qn /norestart /l*c:\windows\temp\arsps.log"
$retVal = Execute-Installer "/i `"$WorkingDir\Requirements\arps.$qadversion.msi`" /qn /norestart /l* c:\windows\temp\arsps.log" "c:\temp"
if($retVal -eq $true){
Write-Host "Install finished"
}
}
else
{
Write-Host "No install of Quest.ActiveRoles.ADManagement"
}
}
else
{
Write-Host "QAD installed"
$pssnapinversion = (Get-PSSnapin Quest.ActiveRoles.ADManagement).version
$textversion = $pssnapinversion.Major.tostring() + "." + $pssnapinversion.Minor.tostring() + "." + $pssnapinversion.Build.tostring() + "." + $pssnapinversion.Revision.tostring()
Write-Host "Required version: $qadversion - Current version: $textversion "
if ($textversion -ne $qadversion)
{
$install = [Windows.Forms.MessageBox]::Show("Quest.ActiveRoles.ADManagement is not up to date. Would you like to update it?", "My Application", [Windows.Forms.MessageBoxButtons]::YesNo, [Windows.Forms.MessageBoxIcon]::Question)
#if ($install.tolower() -eq "y")
if ($install -eq [Windows.Forms.DialogResult]::Yes)
{
Remove-PSSnapin Quest.ActiveRoles.ADManagement
Write-Host "Installing Quest.ActiveRoles.ADManagement"
Write-Host "msiexec.exe /i `"$WorkingDir\Requirements\arps.$qadversion.msi`" /qn /norestart /l*c:\windows\temp\arsps.log"
$retVal = Execute-Installer "/i `"$WorkingDir\Requirements\arps.$qadversion.msi`" /qn /norestart /l* c:\windows\temp\arsps.log" "c:\temp"
if($retVal -eq $true){
Write-Host "Install finished"
}
}
else
{
Write-Host "No install of Quest.ActiveRoles.ADManagement"
}
}
}
}
}
Load-QuestAD-Plugin
#endregion

Check if Altiris ASDK for NS is installed.
A messagebox will be displayed if it is not installed.
If users answers yes to the messagebox the requirement will be installed.
If it is already installed the connections will be made to the server.

#region Load Altiris ASDK
function Load-AltirisASDK
{
Write-Host "Load-AltirisASDK"
$altirisserver="ALTIRIS"
$global:nsColl = New-Object -comObject Altiris.ASDK.NS.CollectionManagement
if($? -eq $false){
Write-Host "AltirisASDK is not installed"
$install = [Windows.Forms.MessageBox]::Show("Altiris ASDK is not installed. Would you like to install it?", "My Application", [Windows.Forms.MessageBoxButtons]::YesNo, [Windows.Forms.MessageBoxIcon]::Question)
#if ($install.tolower() -eq "y")
if ($install -eq [Windows.Forms.DialogResult]::Yes)
{
#Execute-Program "/S" "$WorkingDir\Requirements\Altiris_ASDK_1_4_209.exe"
$retVal = Execute-Installer "/i `"$WorkingDir\Requirements\Symantec_ASDK_NS_COM_x86.msi`" /qn /norestart /l* c:\windows\temp\asdkNS.log" "c:\temp"
if($retVal -eq $true){
Write-Host "ASDK has been installed"
}else{
Write-Host "ASDK installation failed"
}
}

}else{
$global:nsItem = New-Object -comObject Altiris.ASDk.NS.ItemManagement
$global:nsRes = New-Object -comObject Altiris.ASDK.NS.ResourceManagement
$global:nsReport = New-Object -comObject Altiris.ASDK.NS.ReportManagement
$global:nsReport.targetserver = $altirisserver
$global:nsReport.authenticate()
$global:nsItem.targetserver = $altirisserver
$global:nsItem.authenticate()
$global:nsColl.targetserver = $altirisserver
$global:nsColl.authenticate()
$global:nsRes.targetserver = $altirisserver
$global:nsRes.authenticate()
}
}
Load-AltirisASDK
#endregion

Migrating software to new workstations (Altiris NS)

January 4th, 2010

The web-interface of Altiris Notification Server can sometimes be a bit sluggish.
Certainly if you have to add a computer to 10 or more collections.
To speed things a bit up I have written this Powershell script, which uses the Altiris ASDK to perform queries to Altiris NS.
This script was intended to ensure that a new workstation receives the same software as the old workstation.
It also can be used to just clone the software of a workstation to a new workstation.

#Active Directory Domain
$domain = "LCODE"
#Host name of Altiris Notification Server
$nsserver = "ALTIRISNS"
#Major resource collection
$maincollection = "LCODE Software Collections"
#Sub resource collection
$softinstallcollection = "Software Installation"

#This is a schematic of the structure maintained in Notification Server
#The major resource collection is a child of Software Management
#The name of the sub resource collection is just the first part of the full name (Software Installation)
# as this is being matched with the children of the major resource collection
# all children beginning with that name are being enumerated
# eg. "Software Installation" causes "Software Installation 1" and "Software Installation 2" to be enumerated
#
#Resources tab
# Resource Management
# [-] Collections
#      [-] Software Management
#           [-] LCODE Software Collections
#        [-] Software Installation 1
#            [] SW Package 1
#            [] SW Package 2
#        [-] Software Installation 2
#            [] SW Package 3
#            [] SW Package 4
#

#Load Altiris ASDK
$coll = New-Object -comObject Altiris.ASDK.NS.CollectionManagement
$item = New-Object -comObject Altiris.ASDk.NS.ItemManagement
$res = New-Object -comObject Altiris.ASDK.NS.ResourceManagement
$report = New-Object -comObject Altiris.ASDK.NS.ReportManagement

#Establish connections to Altiris Notification Server
$report.targetserver = $nsserver
$report.authenticate()
$item.targetserver = $nsserver
$item.authenticate()
$coll.targetserver = $nsserver
$coll.authenticate()
$res.targetserver = $nsserver
$res.authenticate()

#Retrieve GUID of the Major resource collection
$maincollectionguid = ($item.getItemsByName($maincollection)).GetValue(0).Guid

#Ask user to enter hostnames of old and new pc
$oldpc = Read-Host "Old PC"
$newpc = Read-Host "New PC"

#Retrieve GUIDs of computers
$oldpcguid = $res.getComputerByNameAndDomain($oldpc,$domain)
$newpcguid = $res.getComputerByNameAndDomain($newpc,$domain)

#Check if we don't have an empty GUID for one of the computers
if(($oldpcguid.length -gt 0) -and ($newpcguid.length -gt 0)){

#Retrieve all software collections
$softwarecoll = $item.GetItemsInFolder($maincollectionguid) | foreach-object -process { $item.GetItemsInFolder($_.Guid) | where-object { $_.parentfoldername -match $softinstallcollection } }

#Enumerate all software collections
$softwarecoll | foreach-object -process{
$softguid = $_.guid

#Check if OldPC is in software collection
$result = $coll.getinclusions($softguid,"Resource") | where-object { $_.name -eq $oldpc}
if($result -ne $null){
$softname = $_.Name

#Display and log that OldPC has this piece of software
Write-Host "$oldpc $softname"
Add-Content ".\$newpc.txt" -value "$oldpc $softname"

#Add NewPC to software collection
$coll.addinclusions($softguid,$newpcguid)

#Check if NewPC is in software collection
$result = $coll.getinclusions($softguid,"Resource") | where-object { $_.name -eq $newpc}
if($result -ne $null){

#Display and log that NewPC has this piece of software
Write-Host "$newpc $softname"
Add-Content ".\$newpc.txt" -value "$newpc $softname"
}

#Refresh the software collection
$coll.updatecollections($softguid)
}
#Write-Host "Result:$result"
}
}else{

#One of the GUIDs could not be found. Most likely computername is wrong or it does not exist in Notification Server
Write-Host "Problem finding GUID for Old/New PC"
Write-Host "Old PC: $oldpcguid"
Write-Host "New PC: $newpcguid"
}

Exchange 2007 upgrade CAS ‘owa’ already exists

October 25th, 2009

Currently I am using a test-environment to become familiar with Exchange 2007.
Today I tried to upgrade from Exchange 2007 RTM to SP2.
Whilst trying to upgrade my CAS-server I encountered the following error

The virtual directory ‘owa’ already exists under ‘ExchCAS/Default Web Site’ Parameter name: VirtualDirectoryName

The solution that I used to solve this was to delete the offending virtual directory and all other Exchange related virtual directories by issuing the following lines in the Exchange Management Shell.

Get-OwaVirtualDirectory| foreach-object -process { $id=$_.server.tostring() + ‘\’ + $_.name.tostring(); write-host ‘Going to remove $id’;  Remove-OwaVirtualDirectory -Identity $id }

Get-OabVirtualDirectory | foreach-object -process { $id=$_.server.tostring() + ‘\’ + $_.name.tostring(); write-host ‘Going to remove $id’; Remove-OabVirtualDirectory -Identity $id }

Get-AutodiscoverVirtualDirectory | foreach-object -process { $id=$_.server.tostring() + ‘\’ + $_.name.tostring(); write-host ‘Going to remove $id’; Remove-AutodiscoverVirtualDirectory -Identity $id }

Get-UMVirtualDirectory | foreach-object -process { $id=$_.server.tostring() + ‘\’ + $_.name.tostring(); write-host $id;
Remove-UMVirtualDirectory -Identity $id }

Get-ActiveSyncVirtualDirectory | foreach-object -process { $id=$_.server.tostring() + ‘\’ + $_.name.tostring(); write-host $id; Remove-ActiveSyncVirtualDirectory -Identity $id }

Get-WebServicesVirtualDirectory | foreach-object -process { $id=$_.server.tostring() + ‘\’ + $_.name.tostring(); write-host $id;
Remove-WebServicesVirtualDirectory -Identity $id }

Batch-scripting

March 21st, 2008

Batch-scripting is not as powerful as WSH-scripting or PowerShell.
But with some tools you can perform some simple but useful actions.
One tool I often use is robocopy.

1. Asking for values in a batch-script

@echo off
@set /P pctocheck=Enter name of pc:
@cscript.exe "script.vbs" %pctocheck%
pause

2. Copy non-existing folders back to C-drive

@echo off
rem Check if the script was called with parameter RUN
IF "%1"=="RUN" GOTO run
rem Since we are not running the script with parameter RUN, start it using cmd whilst enabling delayed environment variable expansion (/V:ON)
cmd /V:ON /C H:\copy_c-drive.cmd RUN
GOTO :EOF
:run
echo ...Copying extra folders on C-drive
rem  List all existing files and directories on the C-drive, including hidden ones.
dir /a:d /b C:\ >C:\WINDOWS\TEMP\rc_existsystemdirs.txt
dir /a:hd /b C:\ >>C:\WINDOWS\TEMP\rc_existsystemdirs.txt
dir /a:-d /b C:\ >C:\WINDOWS\TEMP\rc_existsystemfiles.txt
dir /a:h-d /b C:\ >>C:\WINDOWS\TEMP\rc_existsystemfiles.txt
rem Build up variables
set existingdirs=
FOR /F "delims=," %%i IN (C:\WINDOWS\TEMP\rc_existsystemdirs.txt) do set existingdirs=!existingdirs! /XD "%%i"
set existingfiles=
FOR /F "delims=," %%i IN (C:\WINDOWS\TEMP\rc_existsystemfiles.txt) do set existingfiles=!existingfiles! /XF "%%i"
rem Do the copy thing
robocopy /COPYALL /E X:\ C:\ /TEE /LOG+:C:\WINDOWS\TEMP\rc_system.log /XO /R:1 /W:3 %existingdirs% %existingfiles%

WSH Scripting

March 21st, 2008

Using WSH with WMI enables you to query lots of information of a system.
Here are some examples of code that I regularly use.

1. Determine UpTime of a computer

strComputer = InputBox("Enter computername","Determine Uptime",".")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * From Win32_PerfFormattedData_PerfOS_System")
intSystemUptime = 0
For Each objOS in colOperatingSystems
Dim intSystemUptimeSec
Dim intSystemUptimeMin
Dim intSystemUptimeHour
Dim intSystemUptimeDay
intSystemUptimeDay = Int(objOS.SystemUpTime / 86400)
intSystemUptimeHour = Int(objOS.SystemUpTime / 3600) - (intSystemUptimeDay*24)
intSystemUptimeMin = Int(objOS.SystemUpTime / 60) - (intSystemUptimeHour*60) - (intSystemUptimeDay*24*60)
intSystemUptimeSec = Int(objOS.SystemUpTime) - (intSystemUptimeMin*60) - (intSystemUptimeHour*60*60) - (intSystemUptimeDay*24*60*60)
intSystemUptime = Int(objOS.SystemUpTime / 60)
MsgBox("Uptime for " & strcomputer &  " = " & intSystemUptimeDay & "d " & intSystemUptimeHour & "h " & intSystemUptimeMin & "m " & intSystemUptimeSec & "s")
Next

2. Ping a computer

strComputer = InputBox("Enter computername","Ping a computer",".")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select * from Win32_PingStatus where address = '"_
& strComputer & "'")
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
MsgBox("Ping failed")
else
MsgBox("Ping succeeded")
End If
Next

3. Map a Networkdrive

Set oNet = CreateObject("wscript.network")
oNet.MapNetworkDrive "X:", "\\" & strComputer & "\c$"

4. Get Computers from an OU in Active Directory

Set ObjOU = GetObject("LDAP://OU=Desktops,OU=Computers,DC=corp,DC=contoso,DC=com")
ObjOU.Filter = Array("Computer")
For Each ObjComp in ObjOU

5. List running processes

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process")
For Each objProcess in colProcess
WScript.Echo objProcess
Next

6. Count DiskErrors

Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'System'" _
& " and SourceName = 'disk'")
iDiskErrors = colLoggedEvents.count

7. Show logged on user

Set Users = objWMIService.InstancesOf("Win32_ComputerSystem")
for each User in Users
If isNull(User.UserName) then
WScript.Echo "No User is logged on"
else
WScript.Echo User.UserName
end if
Next

8. Enumerate all profiles stored in Documents and Settings

Set objFolder = objFSO.GetFolder("\\" & strComputer & "\c$\Documents And Settings")
valStoredprofiles = ""
For Each Subfolder in objFolder.SubFolders
If IsStandardUserProfile(SubFolder.Path) then
arrPath = split(Subfolder.Path,"\")
'sSize = Round(SubFolder.Size/1024/1024,2)
'valStoredprofiles = valStoredprofiles & arrPath(UBound(arrPath,1)) & " [" & sSize & "MB]" & " - "
valStoredprofiles = valStoredprofiles & arrPath(UBound(arrPath,1)) & " - "
end if
Next
Function IsStandardUserProfile(sFolder)
Dim iMatches
iMatches = 0
If Instr(sFolder,"Administrator") > 0 then iMatches = iMatches + 1
If Instr(sFolder,"All Users") > 0 then iMatches = iMatches + 1
If Instr(sFolder,"Default User") > 0 then iMatches = iMatches + 1
If Instr(sFolder,"LocalService") > 0 then iMatches = iMatches + 1
If Instr(sFolder,"NetworkService") > 0 then iMatches = iMatches + 1
If iMatches = 0 then
IsStandardUserProfile= true
Else
IsStandardUserProfile= false
end if
End Function

9. Read and write an XML-file

Set objXML = CreateObject("Microsoft.XMLDOM")
objXML.load "result.xml"
'WScript.Echo objXML.parseError.errorCode
If (objXML.parseError.errorCode <> 0) Then
Dim myErr
Set myErr = objXML.parseError
MsgBox("You have error " & myErr.reason)
Else
'WScript.Echo objXML.xml
'WScript.Echo objXML.documentElement.attributes.item(0).nodeValue
Dim i
i = 1
ReDim PreServe arrPcs(i+1)
Set pcs = objXML.getElementsByTagName("pc")
'WScript.Echo pcs
for each pc in pcs
arrPcs(i-1) = pc.getAttribute("id") & ";" & pc.getAttribute("location")
i=i+1
ReDim PreServe arrPcs(i)
next
End If
for each pc in pcs
pcID = pc.getAttribute("id")
if pcID = current PC then
'<ip>192.168.1.19</ip>
'<uptime>0</uptime>
'<diskerrors>0</diskerrors>
'<user>NONE</user>
'<storedprofiles>0</storedprofiles>
'WScript.Echo pc.childNodes.length
pc.childNodes.Item(0).firstChild.nodeValue = valIP
pc.childNodes.Item(2).firstChild.nodeValue = valUptime
pc.childNodes.Item(3).firstChild.nodeValue = valDiskerrors
'WScript.Echo valUser
pc.childNodes.Item(4).firstChild.nodeValue = valUser
pc.childNodes.Item(5).firstChild.nodeValue = valStoredprofiles
exit for
end if
next
objXML.documentElement.Attributes.Item(0).nodeValue = now
objXML.save("result.xml")

Installing VMWare-tools in ClarkConnect

October 12th, 2006

Installing VMWareTools in ClarkConnect is very simple.
I found this solution on the ClarkConnect Forum.

Step 1: Determining your kernel version
With the following command you can retrieve your kernel version. On my system it is currently version 2.6.9-42.cc


[root@s1 /]# uname -r
2.6.9-42.cc

Step 2: Preparing your system
First you need to update your package list using the apt-get update command, and secondly you need to install all the required packages.

apt-get update
apt-get install kernel-devel#2.6.9-27.cc
apt-get install binutils
apt-get install gcc
apt-get install make

Step 3: Verifying your installation
After installing the packages you can verify your installation with the following commands:

[root@s1 /]# updatedb
[root@s1 /]# locate linux/version.h
/usr/src/kernels/2.6.9-42.cc-i686/include/linux/version.h
/usr/include/linux/version.h
[root@s1 /]# rpm -q kernel-devel
kernel-devel-2.6.9-42.cc

The first command updates the locate filedatabase. Second command queries that database for a file called version.h in a folder called linux. The third command searches the installed packages called kernel-devel.

Step 4: Installing and configuring VMWare Tools
First you need to mount your cd-rom drive.

[root@s1 /]# mkdir /mnt/cdrom
[root@s1 /]# mount /dev/hdc /mnt/cdrom

Then you can start the installation and configuration of VMWare Tools. Normally the installer gives the good defaults so you just need to press enter on each question to accept the default.

[root@s1 /]# cd /mnt/cdrom
[root@s1 cdrom]# rpm -Uvh VMwareTools-1.0.1-29996.i386.rpm
[root@s1 cdrom]# vmware-config-tools.pl

Step 5: Reset your network

 /etc/init.d/networking stop
 rmmod pcnet32
 rmmod vmxnet
 depmod -a
 modprobe vmxnet
 /etc/init.d/networking start

That’s really all needed to install VMwareTools on ClarkConnect.