• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 652
  • Last Modified:

Add trusted site using VBScript in HTML code

Hi Experts:

I have this VBScript inside HTML code to be used in my website.  What I want to do is add my site to trusted site, whenver a User opens my website.  If I run the VBScript individually it is adding the webiste as trusted code, but when I use it inside HTML code it does nothing.

Please help.

Thanks,

<code>
<HTML>
<HEAD>
<TITLE>Working With VBScript</TITLE>
<SCRIPT LANGUAGE="VBScript">
OPTION EXPLICIT
Dim HKEY_CURRENT_USER
Dim strComputer
Dim objReg
Dim strKeyPath
Dim strValueName
Dim iValue
  HKEY_CURRENT_USER = &H80000001
        strComputer = "."
        Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
        strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\" _
        & "ZoneMap\Domains\cnn.net"
        objReg.CreateKey HKEY_CURRENT_USER, strKeyPath
        strValueName = "*"
        iValue = 2
        objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName,iValue
</SCRIPT>
</HEAD>
</HTML>
</code>
0
adamssap
Asked:
adamssap
1 Solution
 
Chris StanyonCommented:
I don't think you'll be able to do that. I would hope not anyway, otherwise all sorts of nefarious sites would be adding themselves to your Trusted sites :(


0
 
adamssapAuthor Commented:
Hi:

I made some progress on this:

<code>
<html>
  <head>
    <script language=vbscript>
      Option Explicit
      Dim WSHShell
      Dim Path

      Sub SetPath()
        Dim PathParts, X

        PathParts = Split(Mid(window.location.pathname, 2), "%")
        For X = 1 To UBound(PathParts)
          PathParts(X) = _
              Chr(CInt("&H" & Left(PathParts(X), 2))) _
            & Mid(PathParts(X), 3)
        Next
        Path = Join(PathParts, "")
        Path = Left(Path, InStrRev(Path, "\"))
      End Sub

      Sub btnWScript_onclick()
        'Run: wscript "{path}test.vbs" "{path}"
        WSHShell.Run _
          "wscript """ & Path & "test.vbs"" """ & Path & """"
        window.status = "Script has been run via WScript"
      End Sub

      Sub window_onload()
        Set WSHShell = CreateObject("WScript.Shell")
        SetPath
      End Sub

      Sub window_onunload()
        Set WSHShell = Nothing
      End Sub
    </script>
  </head>
  <body>
    <input type=button id=btnWScript value="Add as Trusted Site">
  </body>
</html>
<,/code>

I am calling the test.vbs script to add as trusted site from the button click event.  It works fine but is it possible to use the VBScript directly instead of calling?
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now