In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to use vbs to detect whether ActiveX is enabled in Internet Explorer. It has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
Q:
How do I know if ActiveX is enabled in Internet Explorer?
A:
You must ask this question, don't you? In fact, this is not a particularly difficult question to answer, but it is just a bit complicated. However, that is closely related to the way Internet Explorer is configured, not so much to do with writing a script to retrieve this information.
First, Internet Explorer does not manage the object model; instead, the only way we can programmatically retrieve Internet Explorer settings and property values is by writing a script to get this information from the registry. This is fairly easy; we often use scripts read in the registry in this column. The trickiest part is figuring out which registry value to read and how to interpret the returned data.
Note: another tricky part is knowing which ActiveX setting you are interested in; for better or worse, Internet Explorer has multiple settings related to the ActiveX control. In today's column, we assume that you want to read the value of this setting: run ActiveX controls and plug-ins.
Let's start by figuring out which registry values need to be modified. In fact, Internet Explorer security settings do not have global settings; instead, these settings are managed by the Internet Explorer zone. There are four such security zones; the zone domain name and its values are shown in the following table:
Zone domain name
Regional value
Intranet site
one
Trusted sites
two
Internet site
three
Restricted sit
four
The settings for the Internet Explorer security zone can be found in the HKEY_CURRENT_USER\ Software\ Microsoft\ Windows\ CurrentVersion\ Internet Settings\ Zones\ section of the registry; to access a specific zone, you need to access the subkey corresponding to that zone. To determine the corresponding subkey, simply append the region value to the previous registry path. For example, to get the settings for the Internet site area (value 3), you need to access the following registry subkey:
HKEY_CURRENT_USER\ Software\ Microsoft\ Windows\ CurrentVersion\ Internet Settings\ Zones\ 3
You can see that 3 is appended to the end. Do you want to access the settings for the Intranet site area (value 1)? No problem:
HKEY_CURRENT_USER\ Software\ Microsoft\ Windows\ CurrentVersion\ Internet Settings\ Zones\ 1
After you find the correct registry subkey, you need to know which registry value to read. Unfortunately (at least for script writers), the names of these registry values are a little vague; for example, the name we are interested in is 1200. Why is this so? We don't know. If you are interested in using scripts to read / manage Internet Explorer settings, you may want to read Managing Internet Explorer Enhanced Security Configuration whitepaper. Only part of the document involves scripting, but this section does map these vague registry values to the corresponding properties in the user interface. Of course, many of these settings can be found in Tweakomatic. (unlike white papers, Tweakomatic actually writes scripts for you. )
So, are we ready to finally write a script and actually do something here? Almost. The other thing you need to know is that the configuration information is stored in the registry as a double-byte (digital) value. Would it help if you knew that the ActiveX control was configured as 3 instead of 65536? Maybe not. However, the following table may be helpful:
Registry valu
User interface value
0
Enabled
one
Prompt
three
Disabled
65536
Administrator Approved
No, the last value is not a typographical error, it is 65536. Think for yourself.
Well, now we're going to write a script. The following example script retrieves the setting information for the Intranet site area (area value 1):
HKEY_CURRENT_USER = & H80000001strComputer = "." Set objReg = GetObject ("winmgmts:\\" & strComputer & "\ root\ default:StdRegProv") strKeyPath = "Software\ Microsoft\ Windows\ CurrentVersion\ Internet Settings\ Zones\ 1" ValueName = "1200" objReg.GetDWORDValue HKEY_CURRENT_USER, strKeyPath, ValueName DwValueWscript.Echo "Run ActiveX Controls and Plug-ins" If IsNull (dwValue) Then Wscript.Echo "Intranet sites: The value is either Null or could not be found in the registry." ElseIf dwValue = 0 Then Wscript.Echo "Intranet sites: Enabled" ElseIf dwValue = 1 Then Wscript.Echo "Intranet sites: Prompt" ElseIf dwValue = 3 Then Wscript.Echo "Intranet sites: Disabled" ElseIf dwValue = 65536 Then Wscript.Echo "Intranet sites: Administrator Approved" End If
We first define a constant named HKEY_CURRENT_USER and set its value to & H80000001; this will tell the script which registry hive we want to use. Then we connect to the WMI service; notice that the StdRegProv (standard registry provider) class is in the root\ default namespace. (many script writers agree that this class, like most WMI classes, is located in root\ cimv2. This is not the case. )
Next we will assign values to a pair of variables:
StrKeyPath = "Software\ Microsoft\ Windows\ CurrentVersion\ Internet Settings\ Zones\ 1" ValueName = "1200"
As you can see, the variable strKeyPath contains the registry path in HKEY_CURRENT_USER (do not include HKEY_CURRENT_USER in that path, otherwise the script will fail). At the same time, set the variable ValueName to 1200, which happens to be the registry value we want to read.
Then we call the GetDWORDValue method so that we can read the double-byte value in the registry:
ObjReg.GetDWORDValue HKEY_CURRENT_USER, strKeyPath, ValueName, dwValue
Note that we need to pass several parameters to GetDWORDValue:
HKEY_CURRENT_USER, a constant that tells the script which registry hive to use.
StrKeyPath, which contains variables for the registry path.
ValueName, a variable that represents the registry value we want to read.
DwValue, which ends storing the output parameters for values read from the registry. If you're thinking, "Please wait a moment, we don't assign a value to dwValue," you're right. This is how we design it: we do not assign values to the output parameters. Instead, GetDWORDValue will read any value that happens to be stored in the discussed registry value (1200), and then the method assigns that value to dwValue.
It's really nice, isn't it?
At this point, we can echo only the values retrieved from the registry. However, as we pointed out, the retrieval value will be a value such as 1, 3, or 65536. Therefore, we set up a simple and small If Then ElseIf block to check the return value and echo a more meaningful message:
If IsNull (dwValue) Then Wscript.Echo "Intranet sites: The value is either Null or could not be found in the registry." ElseIf dwValue = 0 Then Wscript.Echo "Intranet sites: Enabled" ElseIf dwValue = 1 Then Wscript.Echo "Intranet sites: Prompt" ElseIf dwValue = 3 Then Wscript.Echo "Intranet sites: Disabled" ElseIf dwValue = 65536 Then Wscript.Echo "Intranet sites: Administrator Approved" End If
You are right: once you know where the values are stored in the registry and how to store the values in the registry, this is quite easy.
Just to save the pain of typing (and / or copying and pasting), the following script returns information for all four security zones:
HKEY_CURRENT_USER = & H80000001strComputer = "." Set objReg = GetObject ("winmgmts:\\" & strComputer & "\ root\ default:StdRegProv") strKeyPath = "Software\ Microsoft\ Windows\ CurrentVersion\ Internet Settings\ Zones\ 1" ValueName = "1200" objReg.GetDWORDValue HKEY_CURRENT_USER, strKeyPath, ValueName DwValueWscript.Echo "Run ActiveX Controls and Plugins" If IsNull (dwValue) Then Wscript.Echo "Intranet sites: The value is either Null or could not be found in the registry." ElseIf dwValue = 0 Then Wscript.Echo "Intranet sites: Enabled" ElseIf dwValue = 1 Then Wscript.Echo "Intranet sites: Prompt" ElseIf dwValue = 3 Then Wscript.Echo "Intranet sites: Disabled" ElseIf dwValue = 65536 Then Wscript.Echo "Intranet sites: Administrator Approved" End IfstrKeyPath = "Software\ Microsoft\ Windows\ CurrentVersion\ Internet Settings\ Zones\ 2" ValueName = "1200" objReg.GetDWORDValue HKEY_CURRENT_USER, strKeyPath, ValueName DwValueIf IsNull (dwValue) Then Wscript.Echo "Trusted sites: The value is either Null or could not be found in the registry." ElseIf dwValue = 0 Then Wscript.Echo "Trusted sites: Enabled" ElseIf dwValue = 1 Then Wscript.Echo "Trusted sites: Prompt" ElseIf dwValue = 3 Then Wscript.Echo "Trusted sites: Disabled" ElseIf dwValue = 65536 Then Wscript.Echo "Trusted sites: Administrator Approved" End IfstrKeyPath = "Software\ Microsoft\ Windows\ CurrentVersion\ Internet Settings\ Zones\ 3" ValueName = "1200" objReg.GetDWORDValue HKEY_CURRENT_USER, strKeyPath, ValueName DwValueIf IsNull (dwValue) Then Wscript.Echo "Internet sites: The value is either Null or could not be found in the registry." ElseIf dwValue = 0 Then Wscript.Echo "Internet sites: Enabled" ElseIf dwValue = 1 Then Wscript.Echo "Internet sites: Prompt" ElseIf dwValue = 3 Then Wscript.Echo "Internet sites: Disabled" ElseIf dwValue = 65536 Then Wscript.Echo "Internet sites: Administrator Approved" End IfstrKeyPath = "Software\ Microsoft\ Windows\ CurrentVersion\ Internet Settings\ Zones\ 4" ValueName = "1200" objReg.GetDWORDValue HKEY_CURRENT_USER, strKeyPath, ValueName DwValueIf IsNull (dwValue) Then Wscript.Echo "Restricted sites: The value is either Null or could not be found in the registry." ElseIf dwValue = 0 Then Wscript.Echo "Restricted sites: Enabled" ElseIf dwValue = 1 Then Wscript.Echo "Restricted sites: Prompt" ElseIf dwValue = 3 Then Wscript.Echo "Restricted sites: Disabled" ElseIf dwValue = 65536 Then Wscript.Echo "Restricted sites: Administrator Approved" End If
Run the script and return output similar to the following:
Run ActiveX Controls and PluginsIntranet sites: EnabledTrusted sites: EnabledInternet sites: EnabledRestricted sites: Disabled
Is there anything else we can do here? Maybe; after all, we can also configure this registry value. But that's what we're going to discuss some other day.
Thank you for reading this article carefully. I hope the article "how to use vbs to detect whether ActiveX is enabled in Internet Explorer" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.