Login to Account Create an Account
Disable the Close Program "X" button on a command prompt
Posted 20 November 2008 - 06:49 PM
As part of the startup of our SOE PC's for the first time, I have automatic login enabled for one single login. When the machine logs in, it runs a command script that refreshes the domain group policy, adds an account into the local administrator group and imports a registry key that is cleared by sysprep. The script then uses the sleep tool to wait 60 seconds before rebooting the machine.
I'm wanting to disable the close program button for this script so our users cannot kill the script and gain access to windows. Does anyone know of a way to disable the Close Program or "X" button on a command prompt window please?
Posted 04 December 2008 - 07:30 AM
here is a simple example that will find the command prompt window by it's window caption and disable the "x"
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal _
wFlags As Long) As Long
Private Const MF_BYPOSITION = &H400
Private Sub Command1_Click()
Dim cmdHwnd As Long, SysMenu As Long, Res As Long
cmdHwnd = FindWindow(vbNullString, "C:\WINDOWS\system32\cmd.exe")
If cmdHwnd <> 0 Then
SysMenu = GetSystemMenu(cmdHwnd, 0)
Res = RemoveMenu(SysMenu, 6, MF_BYPOSITION)
I have access to Visual Studio somewhere so I could attempt to build this for you at somepoint if you are not able to, just PM me if you want anything like this.
Edited by infiniti25, 04 December 2008 - 07:32 AM.
Posted 04 December 2008 - 10:05 AM
There are many ways of doing that, third party 'hide' utilities or vbscripting being the most common methods.
Posted 04 December 2008 - 04:06 PM
Whilst this message isn't essential it's nice to have it there so the user's don't panic at not being able to use the desktop or interact with their PC.
The utility that regenerates the SID's in our antivirus is also closeable so I guess it doesn't make much difference...
Thanks for your suggestions!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users