I have a script that creates a user agreement on PC log on. This script forces the user to click either "I Decline" which will automatically log the user off, or "I accept" which will close the agreement and let the user continue as normal.
The program works perfectly, the only issue is that the users can use task manager to close the agreement. All users has mostly normal access but everyone has access to the task manager to close programs.
I was wondering if there was something I could add to the script or some way of temporarily disabling CTRL+ALT+DEL/Task manager so that the agreement program cannot be closed without clicking "I Accept" or "I Decline".
The script is shown below:
AUP.hta
<html>
<head>
<HTA:APPLICATION
APPLICATIONNAME="LOGIN"
VERSION="1.0.0.0"
BORDER="none"
INNERBORDER="no"
CAPTION="no"
SYSMENU="no"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="no"
ICON="NO"
SCROLL="no"
SCROLLFLAT="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="maximize"
SHOWINTASKBAR="no"
CONTEXTMENU="no"
SELECTION="no"/>
<script language="VBScript">
Sub logon
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "C:\Users\chandlerb\Desktop\AUP_Files\AUP\AUP.vbs"
window.close
End Sub
Sub logoff
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "shutdown /l"
End Sub
</script>
<script language="JavaScript">
function document.onkeydown() {
var alt=window.event.altKey;
if (event.keyCode==116 || event.keyCode==27 || alt && event.keyCode==115) {
event.keyCode=0;
event.cancelBubble=true;
return false;
}
}
</script>
<style type="text/css">
body {
margin:40px;
font:11px Verdana, Geneva, sans-serif;
}
hr {
margin-bottom:15px;
height:1px;
}
.statement_title {
margin-bottom:15px;
font-size:18px;
}
.statement {
margin-bottom:20px;
}
.button {
float: right;
margin-left:10px;
background-color:#3d94f6;
border:1px solid #337fed;
display:inline-block;
color:#ffffff;
font-family:arial;
font-size:15px;
font-weight:bold;
padding:9px 25px;
text-decoration:none;
cursor:pointer;
}
</style>
</head>
<body>
<div class="statement_title">End User Licence Agreement</div>
<hr>
<div class="statement">
By clicking "I Accept" below you agree to adhere to our End User Licence Agreement. Any breaking of the Terms Of Service held withing the EULA
are grounds for user account termination and will result in a disciplinary. The EULA <strong>must</strong> be accepted to use any network
facilities and services.
</div>
<div class="statement">
By clicking "I Decline" you are declining our EULA and will be unable to use the network and you will be logged off the current computer.
</div>
<hr>
<div>
<a href onClick="logoff" class="button">I Decline</a>
</div>
<div>
<a href onClick="logon" class="button">I Accept</a>
</div>
</body>
</html>
Logon.VBS
On Error Resume Next
Set objShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
UserName = objShell.ExpandEnvironmentStrings("%USERNAME%")
If (fso.FileExists("C:\Users\chandlerb\Desktop\AUP_Files\AUP\" & UserName & ".txt")) Then
WScript.Quit()
Else
dim strComputer
dim wmiNS
dim wmiQuery
dim objWMIService
dim colItems
dim objItem
Dim strOUT
strComputer = "."
wmiNS = "\root\cimv2"
wmiQuery = "Select processID from win32_process where name = 'explorer.exe'"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & wmiNS)
Set colItems = objWMIService.ExecQuery(wmiQuery)
For Each objItem in colItems
objItem.terminate(1)
subLaunch
Next
Sub subLaunch
Dim objShell
Dim strProg
strProg = "C:\Users\chandlerb\Desktop\AUP_Files\AUP\AUP.hta"
Const MaxWindow = 3
Const blnWait = True
Set objShell = CreateObject("wscript.shell")
objShell.Run strProg,maxWindow,blnWait
subcreateProcess
End Sub
Sub subcreateProcess
Dim obj 'uses get method to get win32_process so we can launch new explorer
Set obj = objWMIService.Get("win32_process")
obj.create("explorer.exe")
End sub
End If
WScript.Quit()
AUP.vbs
On Error Resume Next
Set objShell = CreateObject("WScript.Shell")
UserName = objShell.ExpandEnvironmentStrings("%USERNAME%")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Users\chandlerb\Desktop\AUP_Files\AUP\" & UserName & ".txt", 2, True)
objFile.Write("*************************************************************" & vbCrLf & vbCrLf)
objFile.Write(UserName & " signed the User Agreement on " & Now & vbCrLf & vbCrLf)
objFile.Write("*************************************************************" & vbCrLf & vbCrLf & vbCrLf)
objFile.Write("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ultrices" & vbCrLf)
objFile.Write("interdum augue ut dictum. Quisque id purus faucibus nunc pulvinar volutpat et" & vbCrLf)
objFile.Write("porta neque. Vestibulum ut pulvinar arcu. Vestibulum scelerisque tempus turpis" & vbCrLf)
objFile.Write("Suspendisse vitae interdum mi. Suspendisse quis nunc sed ipsum sollicitudin" & vbCrLf)
objFile.Write("Morbi vulputate arcu commodo libero volutpat ac suscipit sem tempor. Etiam" & vbCrLf)
objFile.Write("vitae tristique posuere, ante nibh rutrum tortor, eu aliquet velit tellus quis" & vbCrLf)
objFile.Write("sed justo turpis, ut molestie ante. Cras faucibus blandit mauris eget venenatis." & vbCrLf)
objFile.Write("ante magna. Integer vel nibh ut enim iaculis porttitor nec quis turpis. Class" & vbCrLf)
objFile.Write("sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec" & vbCrLf)
objFile.Write("viverra erat eget convallis. Quisque ac libero a tellus condimentum rhoncus at" & vbCrLf)
objFile.Write("Vestibulum vel mauris non sem malesuada pretium cursus id erat. Maecenas et" & vbCrLf)
objFile.Write("Nunc pulvinar, dolor et malesuada consectetur, diam metus tincidunt ipsum, sed" & vbCrLf)
objFile.Write("felis nisi quis metus. Aenean ut mauris eget purus varius luctus. Proin sem" & vbCrLf)
objFile.Write("porta in, iaculis a erat. Phasellus aliquet ipsum felis, et semper ante." & vbCrLf)
objFile.Write("suscipit velit, eget iaculis quam consectetur in. Aliquam erat volutpat" & vbCrLf)
objFile.Write("amet urna ultrices accumsan in in purus. Quisque odio ipsum, fringilla" & vbCrLf)
objFile.Write("vel purus." & vbCrLf)
objFile.Close
To disable the task manager you should try this code :
Call DisableTaskMgr
'-----------------------------DisableTaskMgr-------------------------------------
sub DisableTaskMgr
Dim WshShell,System
System="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\"
Set WshShell=CreateObject("WScript.Shell")
Wshshell.RegWrite System, "REG_SZ"
WshShell.RegWrite System &"\DisableTaskMgr", 1, "REG_DWORD"
end sub
And to enable it again just you do like that:
Call EnableTaskMgr
'------------------------------EnableTaskMgr-------------------------------------
sub EnableTaskMgr
Dim WshShell,System
System="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\"
Set WshShell=CreateObject("WScript.Shell")
Wshshell.RegWrite System, "REG_SZ"
WshShell.RegWrite System &"\DisableTaskMgr", 0, "REG_DWORD"
end sub