Monday, January 14, 2008

Learning Visual Studio 2005 Express Video Series for Beginners

This is what makes learning a bit fun sometimes - having free learning resources you can use to keep yourself up-to-date with the latest technologies. This is the Absolute Beginner's Video Series for Visual Basic 2005 Express. It covers topics from using the tool, creating a Windows Form, object-oriented programming concepts, accessing a SQL Server database, etc. Plus, these videos jump into the how-to's instead of going thru a lot of marketing stuff that developers are not really concerned about. There is a similar link for C# 2005 Express. Enjoy learning

Saturday, January 12, 2008

Visual Studio Asset System error when installing Visual Studio 2008

So I did follow the steps outlined in this site to uninstall previous versions of Visual Studio 2008 as I have installed the beta versions previously. While running the installation program after the cleanup, I encountered the error telling me that Visual Studio Asset System is still installed. I checked high and low searching for the Visual Studio Asset System on my Add/Remove Programs but couldn't find anything. A post on the MSDN Forums helped me fix this issue. Rename these registry keys using Registry Editor

HKEY_CURRENT_USER\Software\Microsoft\Installer\Features\0506ED384F3618342946DF7F03FF75E5
HKEY_CURRENT_USER\Software\Microsoft\Installer\Products\0506ED384F3618342946DF7F03FF75E5


I just appended _old to both key names and my installation worked like a charm (of course, modifying your registry comes with your own share of risks, if you know what I mean)

And just for the record, the installation of Visual Studio 2008 wasn't just a "walk in the park." I get these "DepCheck indicates Microsoft .NET Framework 2.0a is not installed" errors when I tried to install .NET Framework 3.5 manually. I tried doing this since Visual Studio 2008 installation could not proceed even though I've managed to go thru the selection on which components to install. I ended up uninstalling .NET Framework 2.0 and did a couple of reboots. I even checked if I have Visual Studio 2005 Service Pack 1 and .NET Framework 2.0 Service Pack 1 installed before going any further but no luck. Once .NET Framework 2.0 was uninstalled, my Visual Studio 2008 installation went fine. I wish Microsoft would fix this for those people having Visual Studio 2005 prior to installing Visual Studio 2008.

Monday, December 24, 2007

Using the VMWare Workstation Command Line - vmrun.exe

As the last blog post for this year (we all do need a break once in a while), I would like to focus on the use of a command-line utility for administering VMWare. The reason for this is that I need to start/stop VMWare images using the command-line whenever I do Microsoft presentations (I don't want them to know that I am no longer using Virtual PC unless they read this blog entry). Since I started using multimedia in my presentations, running multiple virtual machines simultaneously uses a lot of resources on my machine, causing my videos to stall. That's not a pleasant scene if you happen to be the audience. My solution is to use the command-line utility to start/stop the virtual images from within PowerPoint. VMware has a command-line utility called vmrun.exe (VMWare Server uses vmware-run.exe) which you can use to start/stop VMWare images. You'll find this in the VMWare Workstation folder, typically inside the C:\Program Files folder. There are a lot of parameters for this command but I will only focus on what I need. To see a list of virtual images running, you can use the list parameter as follows: vmrun list. This will show you the number of images running and the corresponding filenames for those images. This typically includes the path and the filename of the file hosting the image. Take note of this as you will use this as a value to the parameters you need to pass to the vmrun.exe command. To understand this a bit better, let's say you want to start an image named test.vmx in a folder named D:\test to start that image, you need to run this command
vmrun start D:\test\test.vmx
Just make sure that you are in the directory where vmrun.exe is located. If the location happens to include spaces between names, just enclose the path with double-quotes.To stop the image, just replace the start parameter with stop. Now, what I did with my VMWare console is that I have configured my images to run in the background when I close the console so that I no longer have to switch back and forth just to manage the image. Besides, Windows has the Remote Desktop feature that allows me to log in to the server. This keeps my machine from showing any hints of running VMWare except for the icon in the System Tray.

And if I accidentally open anything VMWare during any of my presentations, I have a very good excuse - "Technology doesn't revolve around Microsoft." This is bass_player signing off for 2007

Wednesday, December 19, 2007

Check if an application is installed on workstations

Last week, a friend of mine asked me if there is a way to determine if an application is installed in a workstation. He was planning to deploy IBM Lotus Sametime Connect on their network but didn't know which workstations already have it. I already have a script which audits a workstation's hardware and software so I was thinking of using this ith a little modification. He has a list of workstations in their network and he wants to use this as a reference. Here's a script which reads the text file computerList.txt containing the hostnames of workstations in your network, tries to run a PING test to see if the workstation is reachable and, if it is, runs the script to check if the application is installed. All of these generates a result which is written to a text file in CSV format so that anybody can open it in Excel to generate reports. Management loves Excel.

One thing to note is that you can change the application name to anything you wish provided you know the complete application name as stored in your Add/Remove Programs or the registry. If you want to read the hostnames from your Active Directory infrastructure, check out the script written by Matthew Jenkins (I actually validated my script against his as it is always good to have your work checked). So Raymond, this post is for you. You no longer have to go thru all 2000+ workstations in your network

Dim loopCount, directory, objFSO,objFile,objFSO2,objFile2


'Gets the directory where our script is running from
directory = CreateObject("Scripting.FileSystemObject").GetParentFolderName(Wscript.ScriptFullName)






Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(directory & "\computerList.txt", 1)






'===LOG of servers with successful PING
strFilePath = directory & "\Results.csv"
Set objFSO2 = CreateObject("Scripting.FileSystemObject")
' Open the file for write access.
On Error Resume Next
Set objFile2 = objFSO2.OpenTextFile(strFilePath, 2, True, 0)
If (Err.Number <> 0) Then
On Error GoTo 0
Wscript.Echo "File " & strFilePath & " cannot be opened"
Set objFSO2 = Nothing
End If
On Error GoTo 0






'Write HEADER
objFile2.WriteLine "SERVER,PING STATUS, SOFTWARE INSTALLED"



'variable to search for a specified application
strApp="IBM Lotus Sametime Connect"



Do Until objFile.AtEndOfStream
strComputer = objFile.ReadLine
If Reachable(strComputer)="Success" Then
intResult = SearchApp(strComputer, strApp)
If(intResult = 1) Then
strInstalled = "INSTALLED"
ElseIf(intResult = 2) Then
strInstalled = "NONE"
ElseIf(intResult = 3) Then
strInstalled = "UNABLE TO QUERY"
End If



objFile2.WriteLine strComputer & ",SUCCESS," & strInstalled
Else
objFile2.WriteLine strComputer & "," & Reachable(strComputer) & ",N/A"
End If
Loop




objFile.Close
Set objFSO =NOTHING
Set objFile = NOTHING



objFile2.Close
Set objFSO2 =NOTHING
Set objFile2 = NOTHING



MSGBOX "Finished"





'===================================
' Function SearchApp(strComputer, sApplication)
On Error Resume Next



' Initialize some variables first
SearchApp = 2
sProgramName = ""
sProgramVersion = ""
sKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" ' key containing uninstall info



' Attempt to connect to client's registry
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Set oReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")



' Ensure we connected ok to the client, if not just return false, it's probably not a valid Windows box
If Err.Number <> 0 Then
SearchApp = 3
Exit Function
End If



' Enumerate client registry looking for application
oReg.EnumKey HKLM, sKeyPath, arrSubKeys ' get installed programs' subkeys
For Each subKey In arrSubKeys ' get info from each installed program subkey
' attempt to get DisplayName
If(oReg.GetStringValue(HKLM, sKeyPath & subKey, "DisplayName", sProgramName) <> 0) Then
' if no DisplayName try for QuietDisplayName
oReg.GetStringValue HKLM, sKeyPath & subKey, "QuietDisplayName", sProgramName
End If



' attempt to get DisplayVersion
If(oReg.GetStringValue(HKLM, sKeyPath & subKey, "DisplayVersion", sProgramVersion) <> 0) Then
' if no DisplayName try for QuietDisplayName
oReg.GetDWORDValue HKLM, sKeyPath & subKey, "VersionMajor", sProgramVersion
End If



' If the name exists, return true
If sProgramName = sApplication Then
SearchApp = 1
Exit Function
End If
Next
End Function



'===================
Function Reachable(strComputername)



Dim wmiQuery, objWMIService, objPing, objStatus


wmiQuery = "Select * From Win32_PingStatus Where Address = '" & strComputer & "'"


Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set objPing = objWMIService.ExecQuery(wmiQuery)



For Each objStatus in objPing


SELECT CASE objStatus.StatusCode
CASE 0
Reachable="Success"
CASE 11001
Reachable="Buffer Too Small"
CASE 11002
Reachable="Destination Net Unreachable"
CASE 11003
Reachable="Destination Host Unreachable"
CASE 11004
Reachable="Destination Protocol Unreachable"
CASE 11005
Reachable="Destination Port Unreachable"
CASE 11006
Reachable="No Resources"
CASE 11007
Reachable="Bad Option"
CASE 11008
Reachable="Hardware Error"
CASE 11009
Reachable="Packet Too Big"
CASE 11010
Reachable="Request Timed Out"
CASE 11011
Reachable="Bad Request"
CASE 11012
Reachable="Bad Route"
CASE 11013
Reachable="TimeToLive Expired Transit"
CASE 11014
Reachable="TimeToLive Expired Reassembly"
CASE 11015
Reachable="Parameter Problem"
CASE 11016
Reachable="Source Quench"
CASE 11017
Reachable="Option Too Big"
CASE 11018
Reachable="Bad Destination"
CASE 11032
Reachable="Negotiating IPSEC"
CASE 11050
Reachable="General Failure"
END SELECT
Next
End Function
Google