Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Installation script??

13 views
Skip to first unread message

Mike Deering

unread,
Jan 27, 2003, 11:52:06 AM1/27/03
to

Hello group,
As I am new to this WSH world, I have few clues on how to do what I must.
Namely, I need to find out machine type and based on the response list
below, install a particular version of a program for assett management. I
must also (use a .flg file??) determine whether is is already installed. It
does leave a registry key. And if it is, not install anything. Another
wonderful thing would be to have it determine connection type to install yet
another version of the software.

Any help that you can provide me would be greatly appreciated.
Thanks,
Mike Deering
Value
Description

1
Other

2
Unknown

3
Desktop

4
Low Profile Desktop

5
Pizza Box

6
Mini Tower

7
Tower

8
Portable

9
Laptop

10
Notebook

11
Hand Held

12
Docking Station

13
All in One

14
Sub Notebook

15
Space-Saving

16
Lunch Box

17
Main System Chassis

18
Expansion Chassis

19
Sub Chassis

20
Bus Expansion Chassis

21
Peripheral Chassis

22
Storage Chassis

23
Rack Mount Chassis

24
Sealed-Case PC

Mike Deering

unread,
Jan 27, 2003, 12:14:40 PM1/27/03
to
Opps, forgot to add that this is what I have so far. It will echo a machine
typ.

Again, thanks for any help you might provide.

Mike Deering


"Mike Deering" <mbd...@adelphia.net> wrote in message
news:WsdZ9.10808$ni5.1...@news1.news.adelphia.net...

Mike Deering

unread,
Jan 27, 2003, 12:15:30 PM1/27/03
to

Dim g_sSysType
strComputer = "MKD06"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colChassis = objWMIService.ExecQuery _
("SELECT * FROM Win32_SystemEnclosure")
For Each objChassis in colChassis
For Each intType in objChassis.ChassisTypes
g_sSysType = Cstr(intType)
If g_sSysType = "8" Or g_sSysType = "9" Or g_sSysType = "10" Or g_sSysType =
"14" Then Wscript.Echo "This computer is a notebook."

If g_sSysType = "2" Then WScript.Echo "This must be an Epiq"

If g_sSysType = "23" Then WScript.Echo "This is a Rack Mounted Server"
Next
Next


"Mike Deering" <mbd...@adelphia.net> wrote in message
news:WsdZ9.10808$ni5.1...@news1.news.adelphia.net...
>

Alex K. Angelopoulos (MVP)

unread,
Jan 27, 2003, 11:37:25 PM1/27/03
to
First, let me suggest you wrap that into a function for easy use. Below is my
routine for this; it returns the chassis type number.

What registry key does the asset management software write to?

chassis = wmiChassisType("MKD06")

function wmiChassisType(computer)
Dim WmiService, colChassis, Chassis, intType
Set WmiService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& computer & "\root\cimv2")
Set colChassis = WmiService.ExecQuery _
("SELECT ChassisTypes FROM Win32_SystemEnclosure")
For Each Chassis in colChassis
For Each intType in Chassis.ChassisTypes
wmiChassisType = Cstr(intType)
Next
Next
end function

--
Please respond in the newsgroup so everyone may benefit.
http://dev.remotenetworktechnology.com
----------
Subscribe to Microsoft's Security Bulletins:
http://www.microsoft.com/technet/security/bulletin/notify.asp


"Mike Deering" <mbd...@adelphia.net> wrote in message

news:SOdZ9.10937$ni5.1...@news1.news.adelphia.net...

Torgeir Bakken (MVP)

unread,
Jan 27, 2003, 11:57:25 PM1/27/03
to
Mike Deering wrote:

> I must also (use a .flg file??) determine whether is is already installed.
> It does leave a registry key.

Using VBScripts RegRead method, unless all your client computers are guaranteed
running English versions of the OS, it is much better to test for the existence
of a value instead of a key, see the RegValueExists function below


Documentation for the function:

RegValueExists(sRegValue)
Input param:
sRegValue ' NB! Value, not Value Data. Abbreviasjon
like eg. HKLM is allowed.

Return value:
Is True if registry value exists, else False.
Note: If sRegValue has a trailing \, True will be returned if
Defalt value (="@" in a registry file) is set (but its
value data can still be empty!), else False will be
returned (seen as "(value not set)" with Regedit.exe)

Example on use:
bRetVal = RegValueExists("HKCU\Software\Bogus\Some value")


Code:

Function RegValueExists(sRegValue)
Dim RegReadReturn
RegValueExists = True
On Error Resume Next
RegReadReturn = oShell.RegRead(sRegValue)
If Err Then
RegValueExists = False
Err.clear
End if
On Error Goto 0
End Function


If you absolutely must test on a key, you should use WMI's StdRegProv instead of
WSH's RegRead.

In the link below, you will find two functions using WMI, one to check for
registry key and another one checking if a value exists. See further down in the

post for a functions that only uses WSH RegRead to check if a key exists. Note
that to use WSHs RegRead method to do this correctly, you need to test on the
error message text and not the error number, and this error message may differ
in non-English versions of WSH ! The WMI method does not suffer under this
limitation.

From: Torgeir Bakken (Torgeir.B...@hydro.com)
Subject: Re: Check if registry key exists
Newsgroups: microsoft.public.scripting.vbscript, microsoft.public.scripting.wsh
Date: 2002-09-19 14:32:04 PST
http://groups.google.com/groups?selm=3D8A41AD.44D95564%40hydro.com

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and a ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter


0 new messages