forked from damienvanrobaeys/PowerShell_WPF_lock_screen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSet_CtrlAltDel.ps1
More file actions
202 lines (167 loc) · 5.72 KB
/
Set_CtrlAltDel.ps1
File metadata and controls
202 lines (167 loc) · 5.72 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
Param(
[switch]$DisableLockWorkstation,
[switch]$EnableLockWorkstation,
[switch]$DisableTaskMgr,
[switch]$EnableTaskMgr,
[switch]$DisableLogOff,
[switch]$EnableLogOff,
[switch]$DisableChangePWD,
[switch]$EnableChangePWD,
[switch]$DisableSwitchUser,
[switch]$EnableSwitchUser,
[switch]$DisableAll,
[switch]$EnableAll
)
$Path_System = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\System'
$Path_Explorer = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer'
# Manage DisableLockWorkstation registry option
If ($DisableLockWorkstation -and $EnableLockWorkstation)
{
Write-Warning 'Please specify DisableLockWorkstation OR EnableLockWorkstation !!!'
return
}
ElseIf ($DisableLockWorkstation -or $EnableLockWorkstation)
{
If (!(Test-Path -Path $Path_System))
{
New-Item -Path $Path_System | Out-Null
}
If($DisableLockWorkstation)
{
$DisableLockWorkstation_Value = 1
}
If ($EnableLockWorkstation)
{
$DisableLockWorkstation_Value = 0
}
New-ItemProperty -Path $Path_System -Name DisableLockWorkstation -Value $DisableLockWorkstation_Value -Force -ErrorAction SilentlyContinue | Out-Null
}
# Manage DisableTaskMgr registry option
If ($DisableTaskMgr -and $EnableTaskMgr)
{
Write-Warning 'Please specify DisableTaskMgr OR EnableTaskMgr but not both !!!'
return
}
ElseIf ($DisableTaskMgr -or $EnableTaskMgr)
{
If (!(Test-Path -Path $Path_System))
{
New-Item -Path $Path_System | Out-Null
}
If($DisableTaskMgr)
{
$DisableTaskMgr_Value = 1
}
If ($EnableTaskMgr)
{
$DisableTaskMgr_Value = 0
}
New-ItemProperty -Path $Path_System -Name DisableTaskMgr -Value $DisableTaskMgr_Value -Force -ErrorAction SilentlyContinue | Out-Null
}
# Manage NoLogoff registry option
If ($DisableLogOff -and $EnableLogOff)
{
Write-Warning 'Please specify DisableLogOff OR EnableLogOff but not both !!!'
return
}
ElseIf ($DisableLogOff -or $EnableLogOff)
{
If (!(Test-Path -Path $Path_Explorer))
{
New-Item -Path $Path_Explorer | Out-Null
}
If($DisableLogOff)
{
$DisableLogOff_Value = 1
}
If ($EnableLogOff)
{
$DisableLogOff_Value = 0
}
New-ItemProperty -Path $Path_Explorer -Name NoLogoff -Value $DisableLogOff_Value -Force -ErrorAction SilentlyContinue | Out-Null
}
# Manage DisableChangePassword registry option
If ($DisableChangePWD -and $EnableChangePWD)
{
Write-Warning 'Please specify DisableChangePWD OR EnableChangePWD but not both !!!'
return
}
ElseIf ($DisableChangePWD -or $EnableChangePWD)
{
If (!(Test-Path -Path $Path_System))
{
New-Item -Path $Path_System | Out-Null
}
If($DisableChangePWD)
{
$DisableChangePWD_Value = 1
}
If ($EnableChangePWD)
{
$DisableChangePWD_Value = 0
}
New-ItemProperty -Path $Path_System -Name DisableChangePassword -Value $DisableChangePWD_Value -Force -ErrorAction SilentlyContinue | Out-Null
}
# Manage HideFastUserSwitching registry option
If ($DisableSwitchUser -and $EnableSwitchUser)
{
Write-Warning 'Please specify DisableSwitchUser OR EnableSwitchUser but not both !!!'
return
}
ElseIf ($DisableSwitchUser -or $EnableSwitchUser)
{
If (!(Test-Path -Path $Path_System))
{
New-Item -Path $Path_System | Out-Null
}
If($DisableSwitchUser)
{
$DisableSwitchUser_Value = 1
}
If ($EnableChangePWD)
{
$DisableSwitchUser_Value = 0
}
New-ItemProperty -Path $Path_System -Name HideFastUserSwitching -Value $DisableSwitchUser_Value -Force -ErrorAction SilentlyContinue | Out-Null
}
If ($DisableAll -and $EnableAll)
{
Write-Warning 'Please specify DisableAll OR EnableAll but not both !!!'
return
}
If ($EnableAll)
{
If (!(Test-Path -Path $Path_System))
{
New-Item -Path $Path_System | Out-Null
}
New-ItemProperty -Path $Path_System -Name DisableLockWorkstation -Value 0 -Force -ErrorAction SilentlyContinue | Out-Null
New-ItemProperty -Path $Path_System -Name HideFastUserSwitching -Value 0 -Force -ErrorAction SilentlyContinue | Out-Null
New-ItemProperty -Path $Path_System -Name DisableChangePassword -Value 0 -Force -ErrorAction SilentlyContinue | Out-Null
New-ItemProperty -Path $Path_System -Name DisableTaskMgr -Value 0 -Force -ErrorAction SilentlyContinue | Out-Null
If (!(Test-Path -Path $Path_Explorer))
{
New-Item -Path $Path_Explorer | Out-Null
}
New-ItemProperty -Path $Path_Explorer -Name NoLogoff -Value 0 -Force -ErrorAction SilentlyContinue | Out-Null
}
If ($DisableAll)
{
If (!(Test-Path -Path $Path_System))
{
New-Item -Path $Path_System | Out-Null
}
New-ItemProperty -Path $Path_System -Name DisableLockWorkstation -Value 1 -Force -ErrorAction SilentlyContinue | Out-Null
New-ItemProperty -Path $Path_System -Name HideFastUserSwitching -Value 1 -Force -ErrorAction SilentlyContinue | Out-Null
New-ItemProperty -Path $Path_System -Name DisableChangePassword -Value 1 -Force -ErrorAction SilentlyContinue | Out-Null
New-ItemProperty -Path $Path_System -Name DisableTaskMgr -Value 1 -Force -ErrorAction SilentlyContinue | Out-Null
If (!(Test-Path -Path $Path_Explorer))
{
New-Item -Path $Path_Explorer | Out-Null
}
New-ItemProperty -Path $Path_Explorer -Name NoLogoff -Value 1 -Force -ErrorAction SilentlyContinue | Out-Null
}
# .\Set_CtrlAltDel.ps1 -DisableLogOff -DisableChangePWD
# .\Set_CtrlAltDel.ps1 -EnableLogOff -EnableChangePWD
# .\Set_CtrlAltDel.ps1 -DisableLockWorkstation -DisableTaskMgr -DisableLogOff -DisableChangePWD
# .\Set_CtrlAltDel.ps1 -EnableLockWorkstation -EnableTaskMgr -EnableLogOff -EnableChangePWD