Scripting:Powershell

Auto lock system after 15min of idle:

Dim objResult

Set objShell = WScript.CreateObject("WScript.Shell")    

Do While True
  objResult = objShell.sendkeys("{NUMLOCK}{NUMLOCK}")
  Wscript.Sleep (6000)
Loop

Disable a particular user from installing the given .EXE file

$username=$args[0]
$user = New-Object System.Security.Principal.NTAccount($username) 
$sid = $user.Translate([System.Security.Principal.SecurityIdentifier]) 
$sid_value = $sid.Value
Get-ChildItem registry::HKEY_USERS\.DEFAULT
$path3 = 'registry::HKEY_USERS\' + $sid_value + 
'\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\'
$path1 = 'registry::HKEY_USERS\' + $sid_value + 
'\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer'
$path2 = 'registry::HKEY_USERS\' + $sid_value + 
'\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun
'
$name = $args[1]
$value = $args[2]
If (-NOT (Test-Path $path1)) {

    New-Item -Path $path3 -Name 'Explorer'
} 
If ((Get-Item -Path $path1).GetValue('DisallowRun') -ne '1') {
    New-ItemProperty -Path $path1 -Name 'DisallowRun'  -Value 1 
-PropertyType DWord
} 
If (-NOT (Test-Path $path2)) {
    New-Item -Path $path1 -Name 'DisallowRun'
}  
New-ItemProperty -Path $path2 -Name $name -Value $value