#24200 - 2002-07-01 10:44 PM
Help with IF statements
|
Anonymous
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
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
|
|
Top
|
|
|
|
#24202 - 2002-07-01 10:54 PM
Re: Help with IF statements
|
Anonymous
Anonymous
Unregistered
|
aahhh!! I see. Thanks for the help.
Jural
|
|
Top
|
|
|
|
#24205 - 2002-07-02 06:51 AM
Re: Help with IF statements
|
NTDOC
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.
|
|
Top
|
|
|
|
#24206 - 2002-07-02 05:20 PM
Re: Help with IF statements
|
Sealeopard
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
|
|
|
|
#24209 - 2002-07-03 06:24 PM
Re: Help with IF statements
|
Tarfin
Fresh Scripter
Registered: 2001-11-14
Posts: 26
Loc: Jenison, MI USA
|
Installing NAV via Kix? Please do tell.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1057 anonymous users online.
|
|
|