Monday, March 01, 2010

Detecting 32bit or 64bit OS in VBscript

As part of the process of updating some machines to 64bit this week, I realized that I'll have to adjust existing code to automate updates and service packs on the affected machines. I wrote previously about a similar function in lisp here.

Here is the VBScript version:

On Error Resume Next

Dim WshShell
Dim OsType

Set WshShell = CreateObject("WScript.Shell")

OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")

If OsType = "x86" then
wscript.echo "Windows 32bit system detected"
elseif OsType = "AMD64" then
wscript.echo "Windows 64bit system detected"
end if

Labels: ,


Post a Comment

Links to this post:

Create a Link

<< Home