Help - Search - Members - Calendar
Full Version: vbs / bat to check for reg key and perform if/else
MSFN Forums > Coding, Scripting and Servers > Programming (C++, Delphi, VB, etc.)

   
Google Internet Forums Unattended CD/DVD Guide
dfnkt
I am currently trying to write a batch file to query the registry to determine if internet explorer 7 is installed and echo a message to the user appropriately.

The path in the registry is HKLM\Software\Microsoft\Internet Explorer\Version Vector

The key is: "IE"

IE 7 has a value of "7.0000" and 6 has a value of "6.0000". I am trying to develop a batch (wouldn't be opposed to VBS) to echo a msg to the user regarding what was found.

By simply using

@ECHO OFF
REG QUERY "HKLM\Software\Microsoft\Internet Explorer\Version Vector" /v IE

I can see what the value is but I would like to do something such as piping the key into find and evaluating it like so

@ECHO OFF
REG QUERY "HKLM\Software\Microsoft\Internet Explorer\Version Vector" /v IE |Find /I /C "7.0000"
IF (%ERRORLEVEL% NEQ 0 GOTO noie7) ELSE (goto foundie7)
:noie7
ECHO Internet Explorer 7 Not Found!
:foundie7
ECHO Internet Explorer 7 FOUND!
PAUSE

I have tried this exact batch only to get errors. It doesn't seem to want to recognize the ELSE part of the statement and just always says IE7 found regardless of what is actually present. I also looked at using vbs/wmi but I was unable to find the root\cimv2 or otherwise class for "add/remove" programs.

Help?
crahak
I wouldn't exactly recommend using HKLM\Software\Microsoft\Internet Explorer\Version Vector as it doesn't even exist on my box (not on this one anyhow, haven't checked the others).

You could do something like this:
CODE
const HKLM = &H80000002
strComputer = "."
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer &  "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Internet Explorer"
strValueName = "Version"
oWMI.GetStringValue HKLM,strKeyPath,strValueName,strValue
MsgBox "IE Version: " & strValue

if you prefer a jscript, or powershell version, or whatever else, just ask

Keep in mind IE8 is coming out soon too (beta 1 is already out), so testing for IE 7 only might be shortsighted.

I find .cmd/.bat works best for very simple things, but as soon as it's past basic command lines, a scripting language is far better (more versatile/powerful).
dfnkt
We have line of business apps that do not have any support for IE 7 let alone IE 8 (or vista for that matter) anywhere in sight. The purpose of this is to make it easier for our helpers who are less technically inclined at an upcoming conference determine if IE7 is installed (which they need to remove).

Thanks for the reply and I will take a look at it.
Scr1ptW1zard
With a little change, your script will work:

CODE

@ECHO OFF
REG QUERY "HKLM\Software\Microsoft\Internet Explorer\Version Vector" /v IE |Find /I /C "7.0000">nul
IF %ERRORLEVEL% NEQ 0 (
ECHO Internet Explorer 7 Not Found!
) ELSE (
ECHO Internet Explorer 7 FOUND!
)
PAUSE

dfnkt
Thanks guys! One final question, I've pieced the IE7 detection together with a service pack detection script I had written. I have the two working together however how would you make it so that checks if IE7 and SP3 are installed and THEN gives you a msg box telling you that you need to uninstall SP3/ Then uninstall IE7?

Here is the whole script I'm working with now:
CODE
const HKLM = &H80000002
strComputer = "."
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
Set objWMI2 = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMI2.ExecQuery("Select * from Win32_OperatingSystem")
strKeyPath = "Software\Microsoft\Internet Explorer"
strValueName = "Version"
objWMI.GetStringValue HKLM, strKeyPath,strValueName,strValue
If strValue >= "7" Then
MSGBOX "IE 7 Found! Please Go To Control Panel>Add/Remove Programs and Remove It."
ELSE
If strValue >= "6" Then
MSGBOX "IE 7 Not Found! You are OK!"
End If
End If
For each elem in colItems
If instr(elem.CSDVersion, "2") Then
msgbox "Found Service Pack2"
Else
If instr(elem.CSDVersion, "3") Then
msgbox "Found Service Pack3"
End If
End If
Next


Basically What this does now is says "Hey IE7 is installed, remove it" then it tells you which SP is present. Can it be coded to determine if there is a combination of both SP3 / IE7 and then give them a message box to the effect of "IE7 AND Service Pack 3 was found. You will need to remove Service Pack3 before removing IE7.

I assume its possible, I just seem to have lost my thinking cap today.
crahak
You can't do If strValue >= "7" Then
strValue is a string, 7 should be an integer, but you wrote it as a string comparison... Doesn't work like that.

How about this?
CODE
const HKLM = &H80000002
strComputer = "."
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Internet Explorer"
strValueName = "Version"
objWMI.GetStringValue HKLM, strKeyPath,strValueName,strValue
intIEVers = CInt(Left(strValue, InStr(strValue, ".")-1))
if intIEVers > 6 then blnBadIEVers = true else blnBadIEVers = false
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem")
For each elem in colItems
  intSP = elem.ServicePackMajorVersion
Next
if intIEVers < 7 then
  msgbox "Evrything OK!"
elseif intSP < 3 then
  msgbox "IE " & CStr(intIEVers) & " Found! Please Go To Control Panel>Add/Remove Programs and Remove It."
else
  msgbox "IE " & CStr(intIEVers) & " and SP" & CStr(intSP) & " Found! Please Go To Control Panel>Add/Remove Programs and Remove It."
end if


This checks for IE vers > 6 and blindly SP > 2 (regardless of if it's win2k, xp, or vista -- assuming all your boxes run XP here)
SP3 might have been installed before IE7 though, in which case, one shouldn't have to remove SP3.
dfnkt
Will try the code out! But thanks to microsoft once SP3 is installed, IE 7 is locked onto a machine.

http://blogs.msdn.com/ie/archive/2008/05/0...-and-xpsp3.aspx
dfnkt
Is there not a way to make a vbscript look at multiple if's before having to "then"?

If SP3 and IE7 found then
msgbox "remove sp3, then remove ie7, reinstall sp3"

if sp2 and IE7 found then
msgbox "remove ie7 then install sp3"

if SP3 and IE6 found then
msgbox "no further action needed"

if sp2 and ie6 found then
msgbox "please install sp3"

^^ something like that?
jaclaz
QUOTE (dfnkt @ Jun 18 2008, 09:57 PM) *
Is there not a way to make a vbscript look at multiple if's before having to "then"?

If SP3 and IE7 found then
msgbox "remove sp3, then remove ie7, reinstall sp3"

if sp2 and IE7 found then
msgbox "remove ie7 then install sp3"

if SP3 and IE6 found then
msgbox "no further action needed"

if sp2 and ie6 found then
msgbox "please install sp3"

^^ something like that?


Not what you asked, but this is how I would do that in batch:
CODE
...
REM routine to set variable found_something
REM If found SP2 SET /A found_something=20
REM If found SP3 SET /A found_something=30
REM If found IE6 SET /A found_something=%found_something%+6
REM If found IE7 SET /A found_something=%found_something%+7

GOTO :found%found_something%


:found37
ECHO remove sp3, then remove ie7, reinstall sp3
GOTO :EOF

:found27
ECHO remove ie7 then install sp3
GOTO :EOF

:found36
ECHO no further action needed
GOTO :EOF

:found26
ECHO please install sp3
GOTO :EOF


jaclaz
crahak
So you want to force SP3 as well? As in must be BOTH IE < 7 AND SP3? Ok...

CODE
const HKLM = &H80000002
strComputer = "."
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Internet Explorer"
strValueName = "Version"
objWMI.GetStringValue HKLM, strKeyPath,strValueName,strValue
intIEVers = CInt(Left(strValue, InStr(strValue, ".")-1))
if intIEVers > 6 then blnBadIEVers = true else blnBadIEVers = false
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem")
For each elem in colItems
  intSP = elem.ServicePackMajorVersion
Next
if intIEVers < 7 and intSP = 3 then
  msgbox "no further action needed"
elseif intIEVers < 7 and intSP < 3 then
  msgbox "please install sp3"
elseif intIEVers > 6 and intSP < 3 then
  msgbox "remove ie7 then install sp3"
else
  msgbox "remove sp3, then remove ie7, reinstall sp3"
end if


Anything else... just ask. (Normally I use the .wsf format, and I sign them, and add a few comments)

<Edit>
PowerShell version of the same, should anyone care:

CODE
$MachineName = "."
$SP = (Get-WmiObject -Class win32_OperatingSystem -namespace "root\CIMV2" -ComputerName $MachineName).ServicePackMajorVersion
$IE = (Get-ItemProperty 'HKLM:\Software\Microsoft\Internet Explorer\').Version.Split(".")[0]
if ($IE -lt 7 -and $SP -ge 3) { write-host "Everything OK!" }
elseif ($IE -lt 7 -and $SP -lt 3) { write-host "Install SP3" }
elseif ($IE -ge 7 -and $SP -lt 3) { write-host "Uninstall IE7" }
elseif ($IE -ge 7 -and $SP -ge 3) { write-host "Uninstall SP3 then uninstall IE7" }
else { write-host "This case shouldn't ever happen" }

It's a lot nicer and more concise, but you do need PowerShell installed (if you want MessageBoxes instead of text, then use the .popup method of the script.shell object)
</Edit>
frodo
Why not use AutoIt for this, the bonus apart from easier conditional programming is that you get a gui, so you dont have to suffer console screens......
Yzöwl
Is there any real need for the if this do this and this type messages?

If you want to make things as simple as possible for your helpers, just give them a single task not a possible list of them

You've only got to check for two conditions:
If Internet Explorer is version 7 then uninstall it!
If Service Pack is not 3 then install SP3

Using the most common language in the thread thus far, I'd suggest an idea similar to this:
CODE
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objItem in colItems
If InStr(objItem.Caption, "Windows XP") Then
strSP = objItem.ServicePackMajorVersion
Else
Wscript.Echo "This computer is not running Windows XP"
Wscript.Quit
End If
Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & _
"\root\cimv2\Applications\MicrosoftIE")
Set colIESettings = objWMIService.ExecQuery("Select * from MicrosoftIE_Summary")
For Each strIESetting in colIESettings
IEVer = split(strIESetting.Version, ".")
Next
If IEVer(0) = "7" Then
WScript.Echo "Remove IE7"
Wscript.Quit
ElseIf strSP = "3" Then
Wscript.Echo "No action needed"
Else
WScript.Echo "Install SP3"
End If
Notice the check for XP first!
crahak
QUOTE (frodo @ Jun 18 2008, 07:36 PM) *
Why not use AutoIt for this, the bonus apart from easier conditional programming is that you get a gui, so you dont have to suffer console screens......

AutoIt isn't exactly the best/most universal/most well known scripting kit. It's meant mostly to automate button clicks and such, which a LOT of ppl see as a last resort. And it needs the program installed to run scripts, whereas WSH is already installed on most PCs. With most network admin types (windows world, not linux), vbscript is pretty much the de facto standard, slowly being replaced by PowerShell. There are no console messages with vbscript (using wscript -- as long as you didn't force it to use cscript).

Yzöwl: Likely, he wants a messagebox popup for the end-users, and only one of them, hence all the nested if's. But yeah, my script blindly checked for SP and not OS like I said before (assuming he uses only XP)

Also, opening \root\cimv2\Applications\MicrosoftIE throws an exception here, hence why I went with the other method (reading from registry directly). Screenshot of debug session in VS:

frodo
Perhaps you need to visit autoItscript.com and you'll see its not as you describe "mostly to automate button clicks" and also not "a LOT of ppl see as a last resort". Ive written entire applications using it, including a Ghost clone thats indistinguishable form the real thing in every detail smile.gif

Its as powerful, if not more, no actually more, than anything you can come up with in a console, its free and is growing all the time due to one of the most active forums on the net.

And it DOES NOT need any program installed to run it, you complie your scripts to an .exe file.
Yzöwl
Okay boys, playtime's over, lets stick to programming/scripting.

All other stuff removed!


My post wasn't intended to correct anything with your scripting method crahak, it was more to example my statement of simplifying the conditional arguments. Ther helper runs the script it tells them what to do next. They run the script after doing that it'll let them know their next move. I think from my experience of helpers that if you just give on task at a time it saves your hair. All they need to learn to do is run script, follow advice, run script, follow advice…
crahak
QUOTE (Yzöwl @ Jun 19 2008, 05:40 AM) *
My post wasn't intended to correct anything with your scripting method crahak, it was more to example my statement of simplifying the conditional arguments.

Yeah I know. I'm just saying, I did this because I believe that's what he wanted (not that it's necessarily the better way to do it or anything).

Thanks for the cleanup.
dfnkt
===== Post Nº 1 =====


Wow thanks for all the responses!

The only problem for just checking for 2 conditions is that if IE7 is found as well as SP3, they just can't immediately remove IE7 without first removing SP3. I was wanting the script to be extra wordy to give them specific directions on what to do.

I have so far gotten 2 scripts, the first will show you what SP is installed followed by a message of what IE version is installed. The second script uses an "If xxxxxx then If xxxxx then else" and seems to function fairly well when I only try to look for the presence of an IE version >=7 but upon adding the statements for IE 6 strValue < "7" it fails to execute.

I will be working more with this today and try out the code suggestions that have been made, thank you again!

===== Post Nº 2 =====


QUOTE (crahak @ Jun 18 2008, 03:39 PM) *
So you want to force SP3 as well? As in must be BOTH IE < 7 AND SP3? Ok...

CODE
const HKLM = &H80000002
strComputer = "."
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!" & strComputer & "rootdefault:StdRegProv")
strKeyPath = "SoftwareMicrosoftInternet Explorer"
strValueName = "Version"
objWMI.GetStringValue HKLM, strKeyPath,strValueName,strValue
intIEVers = CInt(Left(strValue, InStr(strValue, ".")-1))
if intIEVers > 6 then blnBadIEVers = true else blnBadIEVers = false
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")
Set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem")
For each elem in colItems
  intSP = elem.ServicePackMajorVersion
Next
if intIEVers < 7 and intSP = 3 then
  msgbox "no further action needed"
elseif intIEVers < 7 and intSP < 3 then
  msgbox "please install sp3"
elseif intIEVers > 6 and intSP < 3 then
  msgbox "remove ie7 then install sp3"
else
  msgbox "remove sp3, then remove ie7, reinstall sp3"
end if


Anything else... just ask. (Normally I use the .wsf format, and I sign them, and add a few comments)

<Edit>
PowerShell version of the same, should anyone care:

CODE
$MachineName = "."
$SP = (Get-WmiObject -Class win32_OperatingSystem -namespace "rootCIMV2" -ComputerName $MachineName).ServicePackMajorVersion
$IE = (Get-ItemProperty 'HKLM:SoftwareMicrosoftInternet Explorer').Version.Split(".")[0]
if ($IE -lt 7 -and $SP -ge 3) { write-host "Everything OK!" }
elseif ($IE -lt 7 -and $SP -lt 3) { write-host "Install SP3" }
elseif ($IE -ge 7 -and $SP -lt 3) { write-host "Uninstall IE7" }
elseif ($IE -ge 7 -and $SP -ge 3) { write-host "Uninstall SP3 then uninstall IE7" }
else { write-host "This case shouldn't ever happen" }

It's a lot nicer and more concise, but you do need PowerShell installed (if you want MessageBoxes instead of text, then use the .popup method of the script.shell object)
</Edit>


The main goal with this is to get all these laptops we will be working with running Service Pack 3 with Internet Explorer 6 installed. I would love to have them use IE 7 however we have some web dependent apps that refuse to function properly on anything but IE 6. Personally instead of myself spending time organizing this project, I think we should be pressing the issue with the web app devs that are obviously behind times with their code. Just my 2c

===== Post Nº 3 =====


Ok here is what I have now, thoughts? Seems to be working, I had ie6 and sp2 it told me to install sp3, i upgraded to ie7 and it said to uninstall ie7 and then install sp3. I know i don't write the best code in the world so C&C is welcome.

CODE
const HKLM = &H80000002
strComputer = "."
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!" & strComputer & "rootdefault:StdRegProv")
Set objWMI2 = GetObject("winmgmts:{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")
Set colItems = objWMI2.ExecQuery("Select * from Win32_OperatingSystem")
strKeyPath = "SoftwareMicrosoftInternet Explorer"
strValueName = "Version"
objWMI.GetStringValue HKLM, strKeyPath,strValueName,strValue
For each elem in colItems
If strValue >= "7" and instr(elem.CSDVersion, "3") Then
MSGBOX "IE 7 and Service Pack 3 were found. You need to go to Control Panel>Add/Remove Programs and remove Service Pack 3 before you can remove Internet Explorer 7. Once completed, reinstall Service Pack 3."
ELSEIf strValue >= "7" and instr(elem.CSDVersion, "2") Then
MSGBOX "IE 7 found! Service Pack 3 NOT found! Please go to Control Panel>Add/Remove Programs and remove Internet Explorer 7 and then install Service Pack 3."
ELSEIf strValue <= "7" and instr(elem.CSDVersion, "2") Then
MSGBOX "IE 7 not found! Service Pack 3 not found! Please install Service Pack 3."
ELSEIf strValue <= "7" and instr(elem.CSDVersion, "3") Then
MSGBOX "IE 7 found! Service Pack 3 Found! No further action is needed."
ELSE
MSGBOX "Unable to determine configuration."
End If
Next
crahak
QUOTE (dfnkt @ Jun 19 2008, 08:41 AM) *
but upon adding the statements for IE 6 strValue < "7" it fails to execute.

Like I said before...
QUOTE
strValue is a string, 7 should be an integer, but you wrote it as a string comparison... Doesn't work like that.

Looks like you're still trying to do it (in your last post).
However, the script I wrote does EXACTLY what you asked for (it's tested).
If you're doubting Thomas newwink.gif and don't trust the conditional statements, try using combinations of intSP = 2 or intSP = 3, and intIEVers = 6 or intIEVers = 7 (or even intIEVers = 8) just before the if's. You'll see exactly how it behaves for each scenario. Adding an OS check would be a good idea though, unless all your boxes run XP.

QUOTE (dfnkt @ Jun 19 2008, 08:41 AM) *
Personally instead of myself spending time organizing this project, I think we should be pressing the issue with the web app devs that are obviously behind times with their code.

Absolutely. Nowadays, IE7 has a far bigger market share than IE6 and is still on the rise. And it's been out for a good while now (close to 2 years). There's just no excuse for not having updates/fixes by now, especially when it should only be minor changes required to the web apps in question. Similarly, there's no excuse nowadays for most web apps to not support non-IE browsers. Usually that just means they're using non standard compliant markup that only renders OK in IE, which is very sloppy at best. Some companies seemingly need to work on supporting their products a LOT better... And IE8 will be out soon, and it's not gonna get any better then. And Vista users can't downgrade to crappy IE 6 either, and Vista is quickly gaining market share too...

The only stupid web app I've had the displeasure to see in the last few years that was IE-only, was the web interface for Remedy (thanks to the use of ActiveX junk).
dfnkt
QUOTE (crahak @ Jun 19 2008, 08:11 AM) *
QUOTE (dfnkt @ Jun 19 2008, 08:41 AM) *
but upon adding the statements for IE 6 strValue < "7" it fails to execute.

Like I said before...
QUOTE
strValue is a string, 7 should be an integer, but you wrote it as a string comparison... Doesn't work like that.

Looks like you're still trying to do it (in your last post).
However, the script I wrote does EXACTLY what you asked for (it's tested).
If you're doubting Thomas newwink.gif and don't trust the conditional statements, try using combinations of intSP = 2 or intSP = 3, and intIEVers = 6 or intIEVers = 7 (or even intIEVers = 8) just before the if's. You'll see exactly how it behaves for each scenario. Adding an OS check would be a good idea though, unless all your boxes run XP.

QUOTE (dfnkt @ Jun 19 2008, 08:41 AM) *
Personally instead of myself spending time organizing this project, I think we should be pressing the issue with the web app devs that are obviously behind times with their code.

Absolutely. Nowadays, IE7 has a far bigger market share than IE6 and is still on the rise. And it's been out for a good while now (close to 2 years). There's just no excuse for not having updates/fixes by now, especially when it should only be minor changes required to the web apps in question. Similarly, there's no excuse nowadays for most web apps to not support non-IE browsers. Usually that just means they're using non standard compliant markup that only renders OK in IE, which is very sloppy at best. Some companies seemingly need to work on supporting their products a LOT better... And IE8 will be out soon, and it's not gonna get any better then. And Vista users can't downgrade to crappy IE 6 either, and Vista is quickly gaining market share too...

The only stupid web app I've had the displeasure to see in the last few years that was IE-only, was the web interface for Remedy (thanks to the use of ActiveX junk).


Yes crahak thank you, i tested your code and it does just what I need! I was also able to see the syntax of the "if and then" and modify what I had to work as well. With the script i posted in my last post, how can I fix the integer problem you talk about.

Our web app is written by siebel i believe, so frustrating. We also use Altiris HelpDesk which is IE only, doesn't render properly because it fails to recognize firefox as an uplevel browser. This is fixable by tweaking the web.config browsercaps section I just have not had the time to do this. Also the newer version is due out in a few months and I'm sure its been taken care of.
jaclaz
QUOTE (crahak @ Jun 19 2008, 03:11 PM) *
And it's been out for a good while now (close to 2 years). There's just no excuse for not having updates/fixes by now, especially when it should only be minor changes required to the web apps in question. Similarly, there's no excuse nowadays for most web apps to not support non-IE browsers. Usually that just means they're using non standard compliant markup that only renders OK in IE, which is very sloppy at best.



Yes thumbup.gif , programmers should also think about we "poor" users of Opera, Firefox, Konqueror....

jaclaz


dfnkt
QUOTE (jaclaz @ Jun 19 2008, 08:33 AM) *
QUOTE (crahak @ Jun 19 2008, 03:11 PM) *
And it's been out for a good while now (close to 2 years). There's just no excuse for not having updates/fixes by now, especially when it should only be minor changes required to the web apps in question. Similarly, there's no excuse nowadays for most web apps to not support non-IE browsers. Usually that just means they're using non standard compliant markup that only renders OK in IE, which is very sloppy at best.



Yes thumbup.gif , programmers should also think about we "poor" users of Opera, Firefox, Konqueror....

jaclaz


I have been a permanent firefox user since 2004, don't think I could ever go back.
crahak
QUOTE (dfnkt @ Jun 19 2008, 09:31 AM) *
Yes crahak thank you, i tested your code and it does just what I need! I was also able to see the syntax of the "if and then" and modify what I had to work as well. With the script i posted in my last post, how can I fix the integer problem you talk about.

Well, if you did that, you'd be left with a script that's basically identical to mine. The only real differences, are the messages. Here's the same script again, with your new messages

CODE
const HKLM = &H80000002
strComputer = "."
Set objWMI=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer &  "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Internet Explorer"
strValueName = "Version"
objWMI.GetStringValue HKLM, strKeyPath,strValueName,strValue
intIEVers = CInt(Left(strValue, InStr(strValue, ".")-1))
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem")
For each elem in colItems
  intSP = elem.ServicePackMajorVersion
Next
if intIEVers < 7 and intSP = 3 then
  msgbox "IE 7 not found! Service Pack 3 Found! No further action is needed."
elseif intIEVers < 7 and intSP < 3 then
  msgbox "IE 7 not found! Service Pack 3 not found! Please install Service Pack 3."
elseif intIEVers > 6 and intSP < 3 then
  msgbox "IE 7 found! Service Pack 3 NOT found! Please go to Control Panel>Add/Remove Programs and remove Internet Explorer 7 and then install Service Pack 3."
elseif intIEVers > 6 and intSP = 3 then
  msgbox "IE 7 and Service Pack 3 were found. You need to go to Control Panel>Add/Remove Programs and remove Service Pack 3 before you can remove Internet Explorer 7. Once completed, reinstall Service Pack 3."
else
  msgbox "Unable to determine configuration."
end if

(also removed the line with blnBadIEVers -- had no use for it, went for actual version checks instead of using the boolean for the conditional statements)

@jaclaz: totally. At a VERY strict minimum, it should work on IE as well as Firefox (that's at least 90% of users out there), but when you have it working on IE and FF, usually there's very little extra work required to test (and make updates) for Opera, Konqueror, Safari (for those poor guys with fruity computers laugh.gif ) and others. Usually that means standard compliant markup (that works with FF, Opera and all the others), and a IE-specific style sheet or such. I've been a permanent Firefox user for YEARS too (secure, fast, and all them GREAT extensions: the web dev toolbar, firebug, DOM inspector, etc etc)

Anything IE 6 - only is single-platform/windows-only, and even limiting which version of windows can use it (windows only, but even then not all versions!). And that prevents you from updating to a not as sucky version of that browser for your other needs -- you're just stuck with an older version the poorest browser there is (IMO)

Edit: oops, just noticed quoting my posts or copy/pasting from them removed backslashes, very strange... Fixed!
dfnkt
QUOTE (crahak @ Jun 19 2008, 10:02 AM) *
QUOTE (dfnkt @ Jun 19 2008, 09:31 AM) *
Yes crahak thank you, i tested your code and it does just what I need! I was also able to see the syntax of the "if and then" and modify what I had to work as well. With the script i posted in my last post, how can I fix the integer problem you talk about.

Well, if you did that, you'd be left with a script that's basically identical to mine. The only real differences, are the messages. Here's the same script again, with your new messages

CODE
const HKLM = &H80000002
strComputer = "."
Set objWMI=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer &  "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Internet Explorer"
strValueName = "Version"
objWMI.GetStringValue HKLM, strKeyPath,strValueName,strValue
intIEVers = CInt(Left(strValue, InStr(strValue, ".")-1))
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem")
For each elem in colItems
  intSP = elem.ServicePackMajorVersion
Next
if intIEVers < 7 and intSP = 3 then
  msgbox "IE 7 not found! Service Pack 3 Found! No further action is needed."
elseif intIEVers < 7 and intSP < 3 then
  msgbox "IE 7 not found! Service Pack 3 not found! Please install Service Pack 3."
elseif intIEVers > 6 and intSP < 3 then
  msgbox "IE 7 found! Service Pack 3 NOT found! Please go to Control Panel>Add/Remove Programs and remove Internet Explorer 7 and then install Service Pack 3."
elseif intIEVers > 6 and intSP = 3 then
  msgbox "IE 7 and Service Pack 3 were found. You need to go to Control Panel>Add/Remove Programs and remove Service Pack 3 before you can remove Internet Explorer 7. Once completed, reinstall Service Pack 3."
else
  msgbox "Unable to determine configuration."
end if

(also removed the line with blnBadIEVers -- had no use for it, went for actual version checks instead of using the boolean for the conditional statements)

@jaclaz: totally. At a VERY strict minimum, it should work on IE as well as Firefox (that's at least 90% of users out there), but when you have it working on IE and FF, usually there's very little extra work required to test (and make updates) for Opera, Konqueror, Safari (for those poor guys with fruity computers laugh.gif ) and others. Usually that means standard compliant markup (that works with FF, Opera and all the others), and a IE-specific style sheet or such. I've been a permanent Firefox user for YEARS too (secure, fast, and all them GREAT extensions: the web dev toolbar, firebug, DOM inspector, etc etc)

Anything IE 6 - only is single-platform/windows-only, and even limiting which version of windows can use it (windows only, but even then not all versions!). And that prevents you from updating to a not as sucky version of that browser for your other needs -- you're just stuck with an older version the poorest browser there is (IMO)

Edit: oops, just noticed quoting my posts or copy/pasting from them removed backslashes, very strange... Fixed!


Thanks again Crahak, much appreciated. I have used vbscript for a few months and I just don't use it heavily enough to learn all the ins and outs! Thanks for all your help again.
Google Internet Forums Unattended CD/DVD Guide
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.