+ Post New Thread
Results 1 to 10 of 10
Windows Server 2008 R2 Thread, Disable Alt+F4 in Technical; Hi All, I have created an exam environment user interface script that also kills the explorer task and removes task ...
  1. #1

    Join Date
    May 2013
    Posts
    29
    Thank Post
    4
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Disable Alt+F4

    Hi All,

    I have created an exam environment user interface script that also kills the explorer task and removes task manager etc.. however you are able to close the UI using ALT+F4 and once you have done this you can't do anything at all (not even log off). You have to manually reboot the machine.

    Is it possible to disable ALT+F4 for a security group? I wan't to avoid regedit unless it can be used for a security group on its own and doesn't affect the machine after the exam user is logged off.

    Any help appreciated.

    Cheers.

  2. #2


    Join Date
    Oct 2006
    Posts
    3,411
    Thank Post
    184
    Thanked 356 Times in 285 Posts
    Rep Power
    149
    Probably best to make the application the shell, then it should reopen should they close it. Also that way explorer never runs.

    Doable using GPO/GPP

  3. #3

    Join Date
    Mar 2011
    Location
    Bournemouth
    Posts
    280
    Thank Post
    16
    Thanked 74 Times in 64 Posts
    Rep Power
    21
    No, it is not. Alt-F4 is the windows shortcut key for closing an application, it is handled by the application and can only be disabled by a specific application.

    What I suggest is instead of running your "exams" software directly, create a batch file that runs the exams software using start /wait and then afterwards run logoff.exe to log off the user. Oooor you could write a batch file with a never-ending loop which runs the application again if it is executed.

    The run this batch file instead.

  4. #4

    Join Date
    May 2013
    Posts
    29
    Thank Post
    4
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    That's a good idea, at the moment I have a batch script that runs on logon and a kix sctipt that starts the software and kills explorer.exe so maybe an if statement for if the file is closed it should run again?

  5. #5

    Join Date
    Mar 2011
    Location
    Bournemouth
    Posts
    280
    Thank Post
    16
    Thanked 74 Times in 64 Posts
    Rep Power
    21
    Quote Originally Posted by ChristianDavies View Post
    That's a good idea, at the moment I have a batch script that runs on logon and a kix sctipt that starts the software and kills explorer.exe so maybe an if statement for if the file is closed it should run again?
    Im not a kix expert but im sure you can make the kix script wait for the program to finish executing when you run it somehow.

  6. #6

    Join Date
    May 2013
    Posts
    29
    Thank Post
    4
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    I'll have a look into it tomorrow morning, might be back

  7. #7


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,919
    Thank Post
    226
    Thanked 2,676 Times in 1,973 Posts
    Rep Power
    787
    It's really easy to completely disable Alt + F4 with the following AutoHotkey script.

    NoAltF4.ahk
    Code:
    #NoTrayIcon
    !F4::Return
    If you compile the script to an EXE (right-click the AHK file » Compile Script), all you have to do is run it when the users login and they won't be able to close any programs with Alt + F4.

  8. Thanks to Arthur from:

    ChristianDavies (16th August 2013)

  9. #8

    Join Date
    Mar 2011
    Location
    Bournemouth
    Posts
    280
    Thank Post
    16
    Thanked 74 Times in 64 Posts
    Rep Power
    21
    Quote Originally Posted by Arthur View Post
    It's really easy to completely disable Alt + F4 with the following AutoHotkey script.

    NoAltF4.ahk
    Code:
    #NoTrayIcon
    !F4::Return
    If you compile the script to an EXE (right-click the AHK file » Compile Script), all you have to do is run it when the users login and they won't be able to close any programs with Alt + F4.
    #
    Nice! Good one m8. I assume it blocks the windows message chain or something? Probably need to run this 1st?

  10. #9


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,919
    Thank Post
    226
    Thanked 2,676 Times in 1,973 Posts
    Rep Power
    787
    Quote Originally Posted by ChrisMiles View Post
    I assume it blocks the windows message chain or something?
    Yeah. As long as the script is running, the key combo gets intercepted.

    Quote Originally Posted by ChrisMiles View Post
    Probably need to run this 1st?
    You only have to install AutoHotkey on your PC in order to compile the .ahk script into an EXE. Once that is done, it can be run via a login script, the HKLM 'Run' key below, or another method.

    Code:
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
    "NoAltF4"="C:\\Scripts\\NoAltF4.exe"
    Another way to disable Alt + F4 would be to modify the keyboard scan code map in the registry on each PC they are doing exams on. The following .reg file and PowerShell script both do this, although you could also use Group Policy Preferences to deploy the Scancode Map.

    NoAltF4.reg
    Code:
    Windows Registry Editor Version 5.00
    
    ; Disable Left & Right ALT keys and F4
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
    "Scancode Map"=hex:00,00,00,00,00,00,00,00,04,00,00,00,00,00,3e,00,00,00,38,00,\
      00,00,38,e0,00,00,00,00
    or

    NoAltF4.ps1
    Code:
    # Disable Left & Right ALT keys and F4
    Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\Keyboard Layout" -name "Scancode Map" -Value ([byte[]](0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x38,0xe0,0x00,0x00,0x00,0x00))
    These will disable Alt + F4 for every user who logs onto that PC. For the changes to take effect, reboot the computer.

    To re-enable Alt + F4 simply delete the "Scancode Map" registry value and reboot again.

  11. Thanks to Arthur from:

    ChrisMiles (16th August 2013)

  12. #10

    Join Date
    May 2013
    Posts
    29
    Thank Post
    4
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Brilliant! It works!

    Just added a line in my VB Script that says:

    Code:
    WshShell.Run("\\ad1\NETLOGON\NoAltF4.exe")
    Cheers!

SHARE:
+ Post New Thread

Similar Threads

  1. CTL+ALT+Arrow Keys .. Disable?
    By soveryapt in forum Windows 7
    Replies: 7
    Last Post: 9th February 2012, 10:20 PM
  2. alt
    By russdev in forum General Chat
    Replies: 2
    Last Post: 19th December 2010, 04:30 PM
  3. Disabling internet in one room.
    By eejit in forum Network and Classroom Management
    Replies: 161
    Last Post: 4th August 2010, 02:21 PM
  4. Replies: 6
    Last Post: 10th June 2010, 11:42 AM
  5. Replies: 9
    Last Post: 1st December 2008, 06:08 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •