Script for Popup Box to Accept Terms on Windows Login

Home Forums Scripting General Scripting Script for Popup Box to Accept Terms on Windows Login

This topic contains 6 replies, has 7 voices, and was last updated by Avatar Anonymous 10 years, 5 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • Avatar
    bchnc10
    Member
    #145238

    I’m looking to create a pop-up box with my company’s Network Terms & Conditions on a user’s first login to the domain. In this box I want the user to have a choice to either accept or decline the terms. If the user declines, I would like for windows to log the user off.

    How should I go about this?

    Thanks!

    Avatar
    Anonymous
    #367841

    Re: Script for Popup Box to Accept Terms on Windows Login

    Did you manage to find a solution?

    Avatar
    g7rpo
    Member
    #346303

    Re: Script for Popup Box to Accept Terms on Windows Login

    Can do it through AD if you like, dont think that there is much scope for a lot of text but you can at least flash up a warning stating that by logging on you accept the terms an conditions etc etc

    Default Domain Policy: Computer Configuration/Windows Settings/Security Settings/Local Policies/Security Options. Then Interactive logon: Message text… and Interactive logon: Message title…

    Avatar
    vonPryz
    Member
    #347380

    Re: Script for Popup Box to Accept Terms on Windows Login

    Use a logon script and flag file or registry key. When the logon script runs, it checks whether the flag is present. If not, it will show a message to the user. If user accepts, set the flag file. If user declines, just run logoff.exe.

    A VBScript soluiton works quite nicely. Use a msgbox and look for return values.

    -vP

    Avatar
    igor7
    Member
    #295059

    Re: Script for Popup Box to Accept Terms on Windows Login

    You can use this code as logon script:

    Logon policy acceptance script

    >

    sHorizontal = “500”
    sVertical = “600”
    cnt = 60 ‘seconds before auto logoff
    Set objWMIService = GetObject _
    (“winmgmts:rootcimv2”)
    set objShell = CreateObject _
    (“WScript.Shell”)
    Set Fso = CreateObject(“Scripting.FileSystemObject”)
    Set tempfolder = Fso.GetSpecialFolder(2)
    supportingcode = tempfolder & “” & Fso.GetTempName
    Sub Window_OnLoad
    ‘Size Window
    Window.resizeTo sHorizontal,sVertical
    ‘Center window
    Set colItems = objWMIService.ExecQuery _
    (“Select * From Win32_DesktopMonitor”,,48)
    For Each objItem In colItems
    sWidth = objItem.ScreenWidth
    sHeight = objItem.ScreenHeight
    If sWidth > intHorizontal _
    then intHorizontal = sWidth
    If sHeight > intVertical _
    then intVertical = sHeight
    Next
    intLeft = (intHorizontal – sHorizontal) /2
    intTop = (intVertical – sVertical) /2
    Window.moveTo intLeft, intTop
    ‘default window content
    window.location.href=”#Top”
    ‘iTimerID = window.setInterval(“ShowSplash”, 15000)
    iTimerID = window.setInterval(“y”, 1000, “VBScript”)
    End Sub
    function y()
    Text1.innerHTML= “Time Left To Make A Decision: ” & Cnt
    cnt = cnt – 1
    If cnt < 0 then call logoff
    end function
    Sub reloadHTA()
    location.reload True
    End Sub
    Sub ShowSplash
    Splash.Style.Display = "None"
    End Sub
    Function HTA_Sleep(mSec)
    strRun = supportingcode & ".vbs"
    With Fso.OpenTextFile(strRun, 2, true)
    .WriteLine "On Error Resume Next"
    .WriteLine "Wscript.sleep wScript.Arguments(0)"
    .close
    strCommand = "cscript.exe //NoLogo " & strRun & " " & mSec
    objShell.run(strCommand), 0, True
    Fso.DeleteFile(strRun)
    End With
    End Function
    '——————————————————————-
    Sub DeclineScript( oBtt )
    sAction = "LogOff"
    oBtt.style.color = "white"
    oBtt.style.backgroundcolor = "red"
    oBtt.style.fontstyle = "italic"
    call logoff
    End Sub
    Sub logoff
    If Not sAction = "LogOn" Then
    session = objShell.ExpandEnvironmentStrings("%sessionname%")
    If UCase(session) = UCase("Console") Then session = Empty
    strCommand = "%comspec% /c %WinDir%system32logoff.exe " & session
    objShell.Run(strCommand),0 ,True
    Cleanup
    End If
    End Sub
    Sub AcceptScript( oBtt )
    sAction = "LogOn"
    oBtt.style.color = "white"
    oBtt.style.backgroundcolor = "green"
    oBtt.style.fontstyle = "italic"
    HTA_Sleep(100)
    'run vbScript from within this script:
    ' strVBS = "[URL="file://server/share/folder/file.vbs"]\serversharefolderfile.vbs[/URL]"
    ' objShell.run("cscript.exe //NoLogo " & strVBS), 0, True
    Cleanup
    End Sub
    Sub Cleanup
    Set objWMIService = Nothing
    set objShell = Nothing
    Set Fso = Nothing
    Set tempfolder = Nothing
    Self.Close()
    End Sub

    Table.Normal
    {
    font: 8.25pt Verdana;
    color:#000080;
    font-weight:bold;
    filter:progid:DXImageTransform.Microsoft.Gradient
    (GradientType=0,StartColorStr=’#E9E9E9′,EndColorStr=’#9E9E9E’);
    padding-top:1;
    padding-bottom:1;
    Text-Align:;
    vertical-align:;
    }

    TD.MenuNormal
    {
    font: 8.25pt Verdana;
    color:#000080;
    font-weight:bold;
    filter:progid:DXImageTransform.Microsoft.Gradient
    (GradientType=0,StartColorStr=’#eeeeee’,EndColorStr=’#5e9ab9′);
    padding-top:1;
    padding-bottom:1;
    Text-Align:;
    vertical-align:;
    cursor:Hand;
    }

    Body.Normal
    {
    font: 10.25pt Verdana;
    color:#000080;
    font-weight:bold;
    filter:progid:DXImageTransform.Microsoft.Gradient
    (GradientType=0,StartColorStr=’#86cceb’,endColorStr=’#5589ab’);
    padding-top:1;
    padding-bottom:1;
    Text-Align:;
    }


    If you want use this computer
    You need to accept following rules

    © 1985-2005 Microsoft Corporation. All rights reserved.

    • ewgsh hhxd rv hv dbvl edr hwef
      ssv vdrjsrvjeje jeyjv
    • rth rgb ughbh ht jh 456 brjtj
    • tjt fgcy byj bbby v a ryhu
    • itui gb gj 777
    • tuktu hfetygjf gg ryjgyjgrthggyj 8
    • ewgsh hhxd rv hv dbvl edr hwef
    • rth rgb ughbh ht jh 456 brjtj
    • tjt fgcy byj bbby v a ryhu
    • itui gb gj 777
    • tuktu hfetygjf gg ryjgyjgrthggyj 8
    • rgdv

     

    [/CODE]

    Save it as “Logon policy acceptance.hta” and assign it as logon script for company users.[CODE]

    Logon policy acceptance script
    <hta:application
    ApplicationName=”Logon HTA”
    SingleInstance=”Yes”
    WindowsState=”Normal”
    Scroll=”No”
    SCROLLFLAT=”No”
    Navigable=”No”
    SysMenu=”No”
    Caption=”No”
    Select=яes”
    MaximizeButton=”No”
    MinimizeButton=”No”
    BORDER = “thick”
    INNERBORDER = “yes”
    SHOWINTASKBAR=”No”
    CONTEXTMENU=”No”
    Icon = “%SystemRoot%Explorer.exe”>
    >

    sHorizontal = “500”
    sVertical = “600”
    cnt = 60 ‘seconds before auto logoff
    Set objWMIService = GetObject _
    (“winmgmts:rootcimv2”)
    set objShell = CreateObject _
    (“WScript.Shell”)
    Set Fso = CreateObject(“Scripting.FileSystemObject”)
    Set tempfolder = Fso.GetSpecialFolder(2)
    supportingcode = tempfolder & “” & Fso.GetTempName
    Sub Window_OnLoad
    ‘Size Window
    Window.resizeTo sHorizontal,sVertical
    ‘Center window
    Set colItems = objWMIService.ExecQuery _
    (“Select * From Win32_DesktopMonitor”,,48)
    For Each objItem In colItems
    sWidth = objItem.ScreenWidth
    sHeight = objItem.ScreenHeight
    If sWidth > intHorizontal _
    then intHorizontal = sWidth
    If sHeight > intVertical _
    then intVertical = sHeight
    Next
    intLeft = (intHorizontal – sHorizontal) /2
    intTop = (intVertical – sVertical) /2
    Window.moveTo intLeft, intTop
    ‘default window content
    window.location.href=”#Top”
    ‘iTimerID = window.setInterval(“ShowSplash”, 15000)
    iTimerID = window.setInterval(“y”, 1000, “VBScript”)
    End Sub
    function y()
    Text1.innerHTML= “Time Left To Make A Decision: ” & Cnt
    cnt = cnt – 1
    If cnt < 0 then call logoff
    end function
    Sub reloadHTA()
    location.reload True
    End Sub
    Sub ShowSplash
    Splash.Style.Display = “None”
    End Sub
    Function HTA_Sleep(mSec)
    strRun = supportingcode & “.vbs”
    With Fso.OpenTextFile(strRun, 2, true)
    .WriteLine “On Error Resume Next”
    .WriteLine “Wscript.sleep wScript.Arguments(0)”
    .close
    strCommand = “cscript.exe //NoLogo ” & strRun & ” ” & mSec
    objShell.run(strCommand), 0, True
    Fso.DeleteFile(strRun)
    End With
    End Function


    Sub DeclineScript( oBtt )
    sAction = “LogOff”
    oBtt.style.color = “white”
    oBtt.style.backgroundcolor = “red”
    oBtt.style.fontstyle = “italic”
    call logoff
    End Sub
    Sub logoff
    If Not sAction = “LogOn” Then
    session = objShell.ExpandEnvironmentStrings(“%sessionname%”)
    If UCase(session) = UCase(“Console”) Then session = Empty
    strCommand = “%comspec% /c %WinDir%system32logoff.exe ” & session
    objShell.Run(strCommand),0 ,True
    Cleanup
    End If
    End Sub
    Sub AcceptScript( oBtt )
    sAction = “LogOn”
    oBtt.style.color = “white”
    oBtt.style.backgroundcolor = “green”
    oBtt.style.fontstyle = “italic”
    HTA_Sleep(100)
    ‘run vbScript from within this script:
    ‘ strVBS = “[URL=”file://server/share/folder/file.vbs”]\serversharefolderfile.vbs[/URL]”
    ‘ objShell.run(“cscript.exe //NoLogo ” & strVBS), 0, True
    Cleanup
    End Sub
    Sub Cleanup
    Set objWMIService = Nothing
    set objShell = Nothing
    Set Fso = Nothing
    Set tempfolder = Nothing
    Self.Close()
    End Sub

    Table.Normal
    {
    font: 8.25pt Verdana;
    color:#000080;
    font-weight:bold;
    filter:progid:DXImageTransform.Microsoft.Gradient
    (GradientType=0,StartColorStr=’#E9E9E9′,EndColorStr=’#9E9E9E’);
    padding-top:1;
    padding-bottom:1;
    Text-Align:;
    vertical-align:;
    }

    TD.MenuNormal
    {
    font: 8.25pt Verdana;
    color:#000080;
    font-weight:bold;
    filter:progid:DXImageTransform.Microsoft.Gradient
    (GradientType=0,StartColorStr=’#eeeeee’,EndColorStr=’#5e9ab9′);
    padding-top:1;
    padding-bottom:1;
    Text-Align:;
    vertical-align:;
    cursor:Hand;
    }

    Body.Normal
    {
    font: 10.25pt Verdana;
    color:#000080;
    font-weight:bold;
    filter:progid:DXImageTransform.Microsoft.Gradient
    (GradientType=0,StartColorStr=’#86cceb’,endColorStr=’#5589ab’);
    padding-top:1;
    padding-bottom:1;
    Text-Align:;
    }

    <div id="Splash" STYLE="Height:200;Width:400;Border:0.5mm solid green;
    font:14pt arial;
    filter:progid:DXImageTransform.Microsoft.Gradient
    (GradientType=0, StartColorStr=’#5589ab’, EndColorStr=’#86cceb’)
    progid:DXImageTransform.Microsoft.dropshadow(OffX=0, OffY=0,
    Color=’green’, Positive=’true’)”>

    If you want use this computer

    You need to accept following rules

    © 1985-2005 Microsoft Corporation. All rights reserved.

    • ewgsh hhxd rv hv dbvl edr hwef

      ssv vdrjsrvjeje jeyjv

    • rth rgb ughbh ht jh 456 brjtj
    • tjt fgcy byj bbby v a ryhu
    • itui gb gj 777
    • tuktu hfetygjf gg ryjgyjgrthggyj 8
    • ewgsh hhxd rv hv dbvl edr hwef
    • rth rgb ughbh ht jh 456 brjtj
    • tjt fgcy byj bbby v a ryhu
    • itui gb gj 777
    • tuktu hfetygjf gg ryjgyjgrthggyj 8
    • rgdv

     

    [/CODE]

    Save it as “Logon policy acceptance.hta” and assign it as logon script for company users.

    Rems
    Rems
    Moderator
    #227602

    Re: Script for Popup Box to Accept Terms on Windows Login

    igor7;186834 wrote:
    You can use this code as logon script:

    […]

    Save it as “Logon policy acceptance.hta” and assign it as logon script for company users.

    You cannot assign HTA applications directly as logonscript, it’ll need to be invoked through a logon -batch, -vbscript or -exe. Or else copy the file to the Start folder in the users profile path.

    You can lauch HTA fom within a batch or from within a vbscript,
    OR, you could also try to specify “%SystemRoot%System32mshta.exe” as the name of the logonscript and provide the “\serversharefile.hta” UNC path (included the quotes) as the Script Parameters.

    Whether you create the popup with vbs (vonPryz’s suggestion) or, with HTA (igor7’s suggestion) you’ll probably also want to Enable the policy “Run logon scripts Synchronously”. But then make sure that the logon script that starts the HTA script should now always wait for the mshta.exe task to return.
    (Therefore copying the hta file to the Start folder in the user’s profile path was actually not a good solution because this way the script will still be loaded Asynchronously)

    If “Run logon scripts Synchronously” for some reason cannot be enabled then alternatively you could instead of lauch it from within a logon script use a computer startup script that is copying the hta file to the local computers (ie the c:windows folder). The startup script then also add the following entry to the registry on that computer:

    Code:
    key:
    [COLOR=”DarkSlateBlue”]HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionRunOnce[/COLOR]

    ValueName:
    [COLOR=”DarkSlateBlue”][B]![/B]AcceptCompanyTerms[/COLOR] [I](in this scenario the name of the entry must be prefixed with an exclamation point to defer deletion of the value until after the command has been completed)[/I]

    Type: [COLOR=”DarkSlateBlue”]REG_SZ[/COLOR]

    Value:
    [COLOR=”DarkSlateBlue”]mshta.exe “%windir%AcceptCompanyTerms.HTA”[/COLOR]

    [U]NOTES[/U] !
    [I]The RunOnce key under HKLM is an exception to all other “auto Run”-keys that
    can be found in the registry even to the RunOnce key that can be found under
    HKCU. Only the RunOnce key under HKLM and its entries are loaded
    synchronously ([B]before explorer.exe will be loaded[/B]) in an undefined order
    [B]when a user logs-on[/B].
    ** One problem with the RunOnce solution is that, the popup message will
    re-appear when a user logs-on after a previous user was forced logged-off
    because s/he had Decline the terms, BUT when the previous user had accepted
    the terms and later on logs-off the computer instead of shutting it down and a
    new user logs-on to that computer s/he will not get the pop-up!!. Therefore for
    this scenario, the hta can best be invoked throug a user logon script or exe[/I].[/CODE]

    The original HTA script comes from this post
    [url]http://forums.petri.com/showthread.php?p=83619#post83619[/url]
    save the hta-script with a HTA extension and go ahead double click on it to see how it runs.

    The sample below is the same script with a little modification on how the window will be centered on the screen.
    [B]AcceptCompanyTerms.HTA[/B][code]

    Logon policy acceptance Screen

    >

    ‘Size of Window
    sHorizontal = “500”
    sVertical = “600”

    cnt = 60 ‘seconds before auto logoff

    Dim objWMIService, objShell, Fso
    Dim supportingcode, tempfolder

    Sub Window_OnLoad
    Window.resizeTo:Window.moveTo
    ‘Center Window on the monitor
    With createobject(“internetexplorer.application”)
    .navigate2″about:blank”
    With .document.parentWindow.screen
    intLeft = (.width – sHorizontal) /2
    intTop = (.height – sVertical) /2
    End with
    .quit ‘!!!
    End with
    ‘make visible
    Window.moveTo intLeft, intTop
    Window.resizeTo sHorizontal,sVertical

    Set objWMIService = GetObject _
    (“winmgmts:rootcimv2”)
    set objShell = CreateObject _
    (“WScript.Shell”)
    Set Fso = CreateObject(“Scripting.FileSystemObject”)
    Set tempfolder = Fso.GetSpecialFolder(2)
    supportingcode = tempfolder & “” & Fso.GetTempName

    ‘default window content
    window.location.href=”#Top”
    ‘iTimerID = window.setInterval(“ShowSplash”, 5000)
    iTimerID = window.setInterval(“y”, 1000, “VBScript”)
    End Sub

    function y()
    Text1.innerHTML= “Time Left Before auto-Logging Off : ” & Cnt
    cnt = cnt – 1
    If cnt < 0 then call logoff
    end function

    Sub reloadHTA()
    location.reload True
    End Sub

    Sub ShowSplash
    Splash.Style.Display = "None"
    End Sub

    Function HTA_Sleep(mSec)
    strRun = supportingcode & ".vbs"
    With Fso.OpenTextFile(strRun, 2, true)
    .WriteLine "On Error Resume Next"
    .WriteLine "Wscript.sleep wScript.Arguments(0)"
    .close
    strCommand = "cscript.exe //NoLogo " & strRun & " " & mSec
    objShell.run(strCommand), 0, True
    Fso.DeleteFile(strRun)
    End With
    End Function

    '——————————————————————-
    Sub DeclineScript( oBtt )
    sAction = "LogOff"
    oBtt.style.color = "white"
    oBtt.style.backgroundcolor = "red"
    oBtt.style.fontstyle = "italic"
    call logoff
    End Sub

    Sub logoff
    If Not sAction = "LogOn" Then
    session = objShell.ExpandEnvironmentStrings("%sessionname%")
    If UCase(session) = UCase("Console") Then session = Empty
    strCommand = "%comspec% /c %WinDir%system32logoff.exe " & session
    objShell.Run(strCommand),0 ,True
    Cleanup
    End If
    End Sub

    Sub AcceptScript( oBtt )
    sAction = "LogOn"
    oBtt.style.color = "white"
    oBtt.style.backgroundcolor = "green"
    oBtt.style.fontstyle = "italic"
    HTA_Sleep(100)
    'run vbScript from within this script:
    ' strVBS = "\serversharefolderfile.vbs"
    ' objShell.run("cscript.exe //NoLogo " & strVBS), 0, True
    Cleanup
    End Sub

    Sub Cleanup
    Set objWMIService = Nothing
    set objShell = Nothing
    Set Fso = Nothing
    Set tempfolder = Nothing
    Self.Close()
    End Sub

    Table.Normal
    {
    font: 8.25pt Verdana;
    color:#000080;
    font-weight:bold;
    filter:progid:DXImageTransform.Microsoft.Gradient
    (GradientType=0,StartColorStr=’#E9E9E9′,EndColorStr=’#9E9E9E’);
    padding-top:1;
    padding-bottom:1;
    Text-Align:;
    vertical-align:;
    }

    TD.MenuNormal
    {
    font: 8.25pt Verdana;
    color:#000080;
    font-weight:bold;
    filter:progid:DXImageTransform.Microsoft.Gradient
    (GradientType=0,StartColorStr=’#eeeeee’,EndColorStr=’#5e9ab9′);
    padding-top:1;
    padding-bottom:1;
    Text-Align:;
    vertical-align:;
    cursor:Hand;
    }

    Body.Normal
    {
    font: 10.25pt Verdana;
    color:#000080;
    font-weight:bold;
    filter:progid:DXImageTransform.Microsoft.Gradient
    (GradientType=0,StartColorStr=’#86cceb’,endColorStr=’#5589ab’);
    padding-top:1;
    padding-bottom:1;
    Text-Align:;
    }


    A Sample HTA
    The Microsoft Scripting Guys

    Copyright 2005 Microsoft Corporation. All rights reserved.

    • ewgsh hhxd rv hv dbvl edr hwef
      ssv vdrjsrvjeje jeyjv
    • rth rgb ughbh ht jh 456 brjtj
    • tjt fgcy byj bbby v a ryhu
    • itui gb gj 777
    • tuktu hfetygjf gg ryjgyjgrthggyj 8
    • ewgsh hhxd rv hv dbvl edr hwef
    • rth rgb ughbh ht jh 456 brjtj
    • tjt fgcy byj bbby v a ryhu
    • itui gb gj 777
    • tuktu hfetygjf gg ryjgyjgrthggyj 8
    • rgdv

     

    Rems

    Avatar
    Anonymous
    #367624

    Re: Script for Popup Box to Accept Terms on Windows Login

    Awesome ideas, this is exactly what I was hoping for. The HTA rocks! I’ll test this using a batch file sometime this weekend and let you know how things go.

    Thank you guys for your help!

    Brad

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.