Oct
08
2008

Disable Print Screen Function Via VBS Script (By using GPO Startup/Shutdown Script)

Disable Print Screen Function Via VBS Script (By using GPO Startup/Shutdown Script)

Another requirement, now customer need to disable default windows Print Screen function on all of their user desktop,

So, we started our searching again, and easily we able to find out how to disable print screen on windows by importing following registry.

1
2
3
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,00,00,37,e0,00,00,54,00,\
00,00,00,00

So, again we start working to create a custom adm file. As because this is a HKLM key, so we need Privilege to import it into registry, and only way to do so is to apply some policy via Computer Configuration, whit which we can force policy on each computer not on individual user.

But suddenly we discover that ADM files don’t support reg_binary values, so we have to find out any other alternatives.



Now we have to create tow .VBS file, one for to disable print screen and another for to re-enable print screen,

VBS Script for disable print screen,

1
2
3
4
5
6
7
8
'Disable Print Screen Function
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SYSTEM\ControlSet001\Control\Keyboard Layout"
strComputer = "."
BinaryValueName = "Scancode Map"
iValues = Array(&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H03,&H00,&H00,&H00,&H00,&H00,&H37,&He0,&H00,&H00,&H54,&H00,&H00,&H00,&H00,&H00)
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
disablePS = oReg.SetBinaryValue(HKEY_LOCAL_MACHINE,strKeyPath,BinaryValueName,iValues)

VBS Script for re-enable print screen

1
2
3
4
5
6
7
'Re-Enable Print Screen Function
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SYSTEM\ControlSet001\Control\Keyboard Layout"
strComputer = "." 
strStringValueName = "Scancode Map"
set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
enablePS = objReg.DeleteValue(HKEY_LOCAL_MACHINE,strKeyPath,strStringValueName)

Now we can easily implement above two script via GPO by using system Startup/Shutdown script.

Thanks.. :)

If you Liked It, then Share It!!
  • Google Bookmarks
  • LinkedIn
  • Digg
  • del.icio.us
  • Twitter
  • Facebook
  • Ping.fm
  • MySpace
  • Live
  • Yahoo! Bookmarks
  • MSN Reporter
  • Print

16 Responses to “Disable Print Screen Function Via VBS Script (By using GPO Startup/Shutdown Script)”

  1. Timur Says:

    I really liked this post. Can I copy it to my blog?
    Thanks in advance.

    Sincerely, Timur.

  2. Saugata Says:

    Yes, but you must add this site link on your post as source.. :)

  3. Blind_IT Says:

    Hi ,
    Thanks for the info but sad to know Reg_binary is not supported by ADM
    Thanks

  4. Saugata Says:

    But still u can use above script for the same..

  5. tibrahim Says:

    good work

  6. will Says:

    I am sorry but somehow it does not seem to work.
    Even when applied directly in XP. The registry is changed. but after pressing the printscreen button, I can still paste the screen captured result in word or painter.
    What am I missing here?

  7. Saugata Says:

    Did you restart your system after executing the script?

    if still it’s not working, can u upload ur script(in zip/txt format) to rapidsahre or somewhere else so i can re-check the script..

  8. will Says:

    You are right! When appied directly to XP desktop, it works perfectly after logout and login.
    Now I really want it to work also when users login to my server(using Remote Desktop Connection).
    I followed exactly the steps above. Added the DPrintScreen.vbs in my windows 2000 server GPO’s Computer Startup script and the User login script. Then restarted the server.
    But the problem is that it will still allow the user to printscreen. Any ideas? Thanks for your kind help.

  9. Saugata Says:

    This script required admin rights to modify registry settings, So, if u put it as user logon script, it will not work, u have to set it as computer logon script, so it can execute with system account privilege.

    Check the screen shot, i have applied it on Computer Configuration startup script.

    Hope this will solve your problem.

    Thanks
    Saugata :)

  10. will Says:

    Yes! I have applied DPrintScreen.vbs on GPO’s Computer Configuration Startup Script as well.
    Also given the user administrators previlege.
    But when the user login using Remote Desktop Connection, he can still print screen.

  11. Babu Says:

    *.vbs file not working some xp systems.

  12. Saugata Says:

    Did you execute this script with admin privilege?

  13. Ineloquucius Says:

    Just found this; the .vbs errors out on the second line of either, i.e. the declaration of the constant.

  14. Ashutosh Sapre Says:

    For script to run without error replace & with &

  15. Ashutosh Sapre Says:

    replace “& amp ;” with &

  16. Saugata Says:

    Script Updated!

Leave a Reply

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes