-
Notifications
You must be signed in to change notification settings - Fork 3
/
LogonMessageBox.vbs
52 lines (36 loc) · 1.15 KB
/
LogonMessageBox.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
' LogonMessage.vbs
' by Riccardo Bicelli <[email protected]>
' This program is a proof of concept script for demonstrating how to write ADMX Templates
' Registry Base
Const REG_BASE = "HKEY_CURRENT_USER\Software\Policies\MyCompany\LogonMessage"
' Used variables
Dim MsgBoxEnabled
Dim MsgBoxButtons
Dim MsgBoxIcons
Dim MsgBoxTitle
Dim MsgBoxPrompt
'Read Values From Registry
MsgBoxEnabled = readFromReg("MessageEnable", 0)
MsgBoxButtons = readFromReg("MessageButtons", 0)
MsgBoxIcon = readFromReg("MessageIcon", 0)
MsgBoxTitle = readFromReg("MessageTitle", "")
MsgBoxPrompt = readFromReg("MessagePrompt", "")
If MsgBoxEnabled=1 Then
MsgBox MsgBoxPrompt, MsgBoxButtons + MsgBoxIcon, MsgBoxTitle
End If
' Functions Library
' ReadFromReg Function
' Reads a Registry Key from REG_BASE
function readFromReg (sRegKey, sDefaultValue )
Dim WSHShell, value
On Error Resume Next
Set WSHShell = CreateObject("WScript.Shell")
value = WSHShell.RegRead( REG_BASE & "\" & sRegKey )
if err.number <> 0 then
readFromReg = sDefaultValue
else
readFromReg = value
end if
'msgbox ReadFromReg
set WSHShell = nothing
end function