Friday, February 18, 2011

Script of the Day - Open IE on Login (Just One Time)

There may be a situation where you need to launch a web page upon login and have it go "full screen", in order to satisfy some legal person who says it's a good idea.  And then they say, "but they only need to see it once (per user)".  So you could do this any number of ways, but here's just ONE way it could be done:

  • Script that checks for a custom registry key/value under HKCU
  • If the key exists, skip the browser launch and move on
  • If the key is not found, open the browser and create the registry key/value
'****************************************************************
Dim objIE, objShell, keyval
Const delay  = 5000
Const regkey = "HKCU\Software\MyCustomKey\PageViewed"

Set objShell = CreateObject("Wscript.Shell")
keyval = ""
On Error Resume Next
keyval = objShell.RegRead(regkey)
If keyval = "" or IsNull(keyval) Then
    'wscript.echo "registry key was not found - opening browser"
    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Navigate("http://mysite/legal")
    objIE.Visible = True
    objIE.FullScreen = True
    objShell.RegWrite regkey, Now, "REG_SZ"
Else
    'wscript.echo "page already viewed"
End If

Set objShell = Nothing

Post a Comment