The script below works perfect on my localhost, but it doesn't when copying the webpage to the active online production website, what i'm doing wrong here,
Help is appreciated.
Thanks
<script type="text/vbscript">
On Error Resume Next
Sub addkey
Dim DomainArray, strComputer, strHTTP, strHTTPS
Dim dwordZone, regPath, objReg, counter, subkeyPath, icounter
That's because your site in PROD will use ASPNET account to run and that will not have the necessary privilege to modify the registry settings. It works okay in your local system because the process assumes your current account (the one currently logged
on) to run the process.
With that said, if you provide the necessary permission to the ASPNET account, you will be able to run this script without any issues but that's NOT recommended.
Hope this helps.
Please remember to click “Mark as Answer” on the post that helps you and to unmark it if a marked post does not actually answer your question.
Thank you!
----------------------
"Microsoft Community Contributor Award 2011"
Denying ASPNET account from making changes to the registry settings makes a whole lot of sense, since any website can put such ascript in the background and add itself to such security zone.
But what interesting, if I add the website manually to the trusted sites zone, and then click on the button that triggers this script, the script gets executed completely and i get the last message of "website has been added to the trusted sites zone". This
is something I could't explain really.
You must check trusted sites permissions (Probably they are generous).
You are using a script, so this permissions must be checked on the client side.
If it will be a public site, hardly it will work.
But that doesn't answer my question I posted in my second post, which is, the script was successfully executed and went all the way till the end. Even though it maked no changes to the registry since the website has already been added to the trusted sites
zone manually!!!!!!
The right approach is let user choose which site he want to trust manually. It is impossible for an internet web page to change the end user's registry. Why you need to add the site to the trusted zone. Which settings in the trusted zone your web sites depends
on?
hitech
Member
15 Points
66 Posts
Programmatically adding a Site to Internet Explorer’s Trusted Sites Zone?
Jul 06, 2012 08:24 PM|LINK
The script below works perfect on my localhost, but it doesn't when copying the webpage to the active online production website, what i'm doing wrong here,
Help is appreciated.
Thanks
<script type="text/vbscript">
On Error Resume Next
Sub addkey
Dim DomainArray, strComputer, strHTTP, strHTTPS
Dim dwordZone, regPath, objReg, counter, subkeyPath, icounter
Dim subkeyValue
Const HKEY_CURRENT_USER = &H80000001
DomainArray = "mydomain.ca"
strComputer = "."
strHTTP = "http"
strHTTPS = "https"
dwordZone = "2"
regPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" &_
"\ZoneMap\Domains\"
'Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}\\" & strComputer & "\root\default:StdRegProv")
subkeyPath = regPath & DomainArray
objReg.CreateKey HKEY_CURRENT_USER,subkeyPath
regPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" &_
"\ZoneMap\Domains\mydomain.ca\"
subkeyPath = regPath & "www"
objReg.CreateKey HKEY_CURRENT_USER,subkeyPath
objReg.SetDWORDValue HKEY_CURRENT_USER,subkeyPath,strHTTPS,dwordZone
MsgBox("https://www.mydomain.ca has been added to the Trusted Sites Zone.")
objReg.DeleteValue HKEY_CURRENT_USER, subkeyPath, strHTTPEnd Sub
</script>
santa_1975
Star
8574 Points
1499 Posts
Re: Programmatically adding a Site to Internet Explorer’s Trusted Sites Zone?
Jul 06, 2012 09:00 PM|LINK
Hi,
That's because your site in PROD will use ASPNET account to run and that will not have the necessary privilege to modify the registry settings. It works okay in your local system because the process assumes your current account (the one currently logged on) to run the process.
With that said, if you provide the necessary permission to the ASPNET account, you will be able to run this script without any issues but that's NOT recommended.
Hope this helps.
Thank you!
----------------------
"Microsoft Community Contributor Award 2011"
hitech
Member
15 Points
66 Posts
Re: Programmatically adding a Site to Internet Explorer’s Trusted Sites Zone?
Jul 06, 2012 11:57 PM|LINK
Denying ASPNET account from making changes to the registry settings makes a whole lot of sense, since any website can put such ascript in the background and add itself to such security zone.
But what interesting, if I add the website manually to the trusted sites zone, and then click on the button that triggers this script, the script gets executed completely and i get the last message of "website has been added to the trusted sites zone". This is something I could't explain really.
Can you?
Thank you.
DiegoCouto
Member
54 Points
17 Posts
Re: Programmatically adding a Site to Internet Explorer’s Trusted Sites Zone?
Jul 07, 2012 01:54 AM|LINK
You must check trusted sites permissions (Probably they are generous).
You are using a script, so this permissions must be checked on the client side.
If it will be a public site, hardly it will work.
hitech
Member
15 Points
66 Posts
Re: Programmatically adding a Site to Internet Explorer’s Trusted Sites Zone?
Jul 07, 2012 04:56 AM|LINK
But that doesn't answer my question I posted in my second post, which is, the script was successfully executed and went all the way till the end. Even though it maked no changes to the registry since the website has already been added to the trusted sites zone manually!!!!!!
Thank you.
hitech
Member
15 Points
66 Posts
Re: Programmatically adding a Site to Internet Explorer’s Trusted Sites Zone?
Jul 07, 2012 02:26 PM|LINK
Any idea or workaround.
Thanks
aaroncheung
Member
70 Points
15 Posts
Re: Programmatically adding a Site to Internet Explorer’s Trusted Sites Zone?
Jul 23, 2012 04:26 AM|LINK
The right approach is let user choose which site he want to trust manually. It is impossible for an internet web page to change the end user's registry. Why you need to add the site to the trusted zone. Which settings in the trusted zone your web sites depends on?