Page 1 of 1 1
Topic Options
#24200 - 2002-07-01 10:44 PM Help with IF statements
Anonymous
Unregistered


I am trying to load software based on OS type. However this script doesn's seem to work properly.
The install doesn't run and the WMI script that follows this bombs out because WMI is not loaded. Thanks for the help.
code:
$OS = (@PRODUCTTYPE)

IF $OS="Windows 95" or "Windows 98"
? "Inventory Software Installation, Please be Patient."
SHELL "\\SERVER\NETLOGON\WMI9x /s"
ELSE
IF $OS="Windows NT" or "Windows NT Workstation"
? "Inventory Software Installation, Please be Patient."
SHELL "\\SERVER\NETLOGON\WMINT4 /s"

ENDIF
ENDIF


Top
#24201 - 2002-07-01 10:50 PM Re: Help with IF statements
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You need to make valid comparisons on each side of your "OR".
code:
$OS = (@PRODUCTTYPE)

IF $OS="Windows 95" or $OS="Windows 98"
? "Inventory Software Installation, Please be Patient."
SHELL "\\SERVER\NETLOGON\WMI9x /s"
ELSE
IF $OS="Windows NT" or $OS="Windows NT Workstation"
? "Inventory Software Installation, Please be Patient."
SHELL "\\SERVER\NETLOGON\WMINT4 /s"

ENDIF
ENDIF

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#24202 - 2002-07-01 10:54 PM Re: Help with IF statements
Anonymous
Unregistered


aahhh!! I see. Thanks for the help.

Jural

Top
#24203 - 2002-07-01 11:38 PM Re: Help with IF statements
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Well Jural,

I was gonna tell you to modify this, but I got called off to restart a server.

Then when I get back HB beat me to the punch.

IF $OS="Windows 95" or $OS="Windows 98"

Top
#24204 - 2002-07-02 03:19 AM Re: Help with IF statements
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Actually for what you're doing here, @InWin would be a better fit.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#24205 - 2002-07-02 06:51 AM Re: Help with IF statements
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Les,

Initially one would think so, but by further analyzing the code I think you may change your mind.

This current code would Execute on Windows 95/98 and Windows NT 4.0, but would not execute on Windows 2000 (which is good, since 2000/XP already have the latest version of WMI installed)

Try this code on your NT 4.0 workstation and then try it on your Windows 2000/XP workstation.

code:
$OS = (@PRODUCTTYPE)

IF $OS="Windows 95" or $OS="Windows 98"
? "Windows 9x Inventory Software Installation, Please be Patient."

ELSE
IF $OS="Windows NT" or $OS="Windows NT Workstation"
? "Windows NT Inventory Software Installation, Please be Patient."
ELSE
? "Unsupported OS version..."
ENDIF
ENDIF

Nice to see your still around... The TOP SUIT people have not beat you up too much. [Big Grin]

Top
#24206 - 2002-07-02 05:20 PM Re: Help with IF statements
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You might also want to check whether WMI has already been installed. You should reboot after WMI installation.

code:
;-------------------------------------
; subroutine to check whether WMI 1.5 has been installed on Windows 9x and NT computers
;
; uses CompareVersions(), ActiveService(), ServiceMode()
;-------------------------------------
:CHECKWMI
; Windows 2000 = 1.50.1085.29
; Windows NT 4.0 = 1.50.1085.0001
; Windows 9x = 1.50.1085.0001
; install DCOM98 on Windows 98 (dcom2w98.dll version 2.10.35.35)

Dim $retcode, $wmifile, $wmiversion, $requiredwmiversion, $shellcommand
Dim $dcomfile, $dcomversion, $requireddcomversion

if @INWIN=2
$wmifile='%WINDIR%\system\wbem\winmgmt.exe'
$requiredwmiversion='1.50.1085.0001'
else
$wmifile='%WINDIR%\system32\wbem\winmgmt.exe'
$requiredwmiversion='1.50.1085.29'
endif

$wmiversion=getfileversion($wmifile,'FileVersion')
if compareversions($requiredwmiversion, $wmiversion)=1
? 'Checking for correct version of WMI 1.5'
? 'Updating WMI to current version '+$requiredwmiversion
shell 'wmicore.exe /s'
shell $wmifile+' /regserver'
$REBOOTREQUIRED=1
else
? 'WMI '+$requiredwmiversion+' is installed'
endif

if @INWIN=2
$requireddcomversion='4.71.0.3328'
$dcomversion=readvalue('HKEY_CLASSES_ROOT\CLSID\{bdc67890-4fc0-11d0-a805-00aa006d2ea4}\InstalledVersion','')
if compareversions($requireddcomversion, $dcomversion)=1
? 'Updating DCOM to current version '+$requireddcomversion
shell 'dcom98.exe /q'
$REBOOTREQUIRED=1
else
? 'DCOM 4.71.0.3328 is installed'
endif
$requireddcomversion='5.00.1603.1'
$dcomfile='%WINDIR%\SYSTEM\DCOMCNFG.EXE'
$dcomversion=getfileversion($dcomfile,'FileVersion')
if compareversions($requireddcomversion, $dcomversion)=1
? 'Updating DCOM Configurator to current version '+$requireddcomversion
shell 'dcm95cfg.exe /q'
$REBOOTREQUIRED=1
else
? 'DCOM Configurator 5.00.1603.1 is installed'
endif
endif

if @INWIN=1
if not activeservice('winmgmt')
if servicemode('winmgmt')<>'Automatic'
? 'Setting WMI service to start automatically'
$retcode=servicemode('winmgmt','automatic')
endif
? 'Starting WMI service'
shell 'winmgmt /regserver'
shell 'net start winmgmt'
endif
else
$regkey='HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices'
$regentry='MicrosoftWBEMCIM'
$regvalue='%WINDIR%\system32\wbem\winmgmt.exe'
$retcode=writevalue($regkey,$regentry,$regvalue,'REG_SZ')
endif

return

_________________________
There are two types of vessels, submarines and targets.

Top
#24207 - 2002-07-02 07:02 PM Re: Help with IF statements
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Jens,

Very cool script. I would add the check to see if the user were a LOCAL ADMIN or not though. (you probably already do somewhere else in your main script) just mentioning it for other users here that may not realize it.

If the user is not a local admin they will not be able to install it.

Top
#24208 - 2002-07-02 07:34 PM Re: Help with IF statements
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
NTDOC, yes I run it under admin context, part of my Maintenance Client script scheduled through the Task Scheduler. I guess I should publish that one at some point since it also installs/upgrades other components (ADSI) and applications (Adobe Acrobat/Acrobat Reader, NAV, Office, IE,...)
_________________________
There are two types of vessels, submarines and targets.

Top
#24209 - 2002-07-03 06:24 PM Re: Help with IF statements
Tarfin Offline
Fresh Scripter

Registered: 2001-11-14
Posts: 26
Loc: Jenison, MI USA
Installing NAV via Kix? Please do tell. [Big Grin]
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 640 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.063 seconds in which 0.014 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org